Error Prone: Enable and fix StringEquality

There is one instance that needs to be suppressed because the JGit API
depends on returning a sentinel that is used with reference equality.
Arguably, this static method should be moved to JGit, but for now it's
easy enough to suppress. The benefits of avoiding bugs in this case
outweighs this annoyance.

Change-Id: I636dbedaa299c169926471f75fc3ef5c7d48285e
This commit is contained in:
Dave Borowitz
2019-05-24 10:09:53 -07:00
committed by David Pursehouse
parent 650070ee81
commit fabead2ec8
2 changed files with 7 additions and 1 deletions

View File

@@ -139,7 +139,7 @@ public class UploadArchive extends AbstractGitCommand {
PacketLineIn packetIn = new PacketLineIn(in);
for (; ; ) {
String s = packetIn.readString();
if (s == PacketLineIn.END) {
if (isPacketLineEnd(s)) {
break;
}
if (!s.startsWith(argCmd)) {
@@ -163,6 +163,11 @@ public class UploadArchive extends AbstractGitCommand {
}
}
@SuppressWarnings("StringEquality") // JGit API depends on reference equality with sentinel.
private static boolean isPacketLineEnd(String s) {
return s == PacketLineIn.END;
}
@Override
protected void runImpl() throws IOException, PermissionBackendException, Failure {
PacketLineOut packetOut = new PacketLineOut(out);

View File

@@ -41,6 +41,7 @@ java_package_configuration(
"-XepDisableWarningsInGeneratedCode",
"-Xep:AmbiguousMethodReference:ERROR",
"-Xep:BadComparable:ERROR",
"-Xep:StringEquality:ERROR",
"-Xep:MissingCasesInEnumSwitch:ERROR",
"-Xep:WildcardImport:ERROR",
],