Merge pull request #3428 from adangel:issue-3420-inefficientstringbuffering
[java] Fix NPE in InefficientStringBuffering with Records #3428
This commit is contained in:
@ -83,7 +83,7 @@ public class InefficientStringBufferingRule extends AbstractJavaRule {
|
||||
if (name.getNameDeclaration() != null && name.getNameDeclaration() instanceof VariableNameDeclaration) {
|
||||
VariableNameDeclaration vnd = (VariableNameDeclaration) name.getNameDeclaration();
|
||||
AccessNode accessNodeParent = vnd.getAccessNodeParent();
|
||||
if (accessNodeParent.isFinal()) {
|
||||
if (accessNodeParent != null && accessNodeParent.isFinal()) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
@ -451,6 +451,24 @@ public class Foo {
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] NPE in InefficientStringBuffering with Records #3420</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
package a;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
public record A(long from, long to) {
|
||||
public InputStream a() {
|
||||
return ByteStreams.limit(null, to - from);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user