void (String name) { final StringBuilder sb = new StringBuilder(); sb.append("Hello, ").append(name != null ? name : "world"); foo(sb::toString); final StringBuilder sb2 = new StringBuilder(); sb2.append("Hello, ").append(name != null ? name : "world"); foo2(sb2::append); // StringBuilder can leak, because it's returned from function final StringBuilder <warning descr="Contents of 'StringBuilder sb3' are updated, but never queried">sb3</warning> = new StringBuilder(); sb3.append("Hello, ").append(name != null ? name : "world"); foo3(sb3::append); // StringBuilder cannot leak }