Browse Source

[error prone] fix ReferenceEquality warning in CommitBuilder

Comparing with UTF_8 constant in StandardCharsets doesn't require to use
equals.

Change-Id: I6c73a929367f32c9e76ce99f6c0af268480d9230
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Matthias Sohn 5 years ago
parent
commit
4b9ed3f678
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java

5
org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java

@ -57,6 +57,7 @@ import java.text.MessageFormat;
import java.util.List; import java.util.List;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.util.References;
/** /**
* Mutable builder to construct a commit recording the state of a project. * Mutable builder to construct a commit recording the state of a project.
@ -365,7 +366,7 @@ public class CommitBuilder {
os.write('\n'); os.write('\n');
} }
if (getEncoding() != UTF_8) { if (!References.isSameObject(getEncoding(), UTF_8)) {
os.write(hencoding); os.write(hencoding);
os.write(' '); os.write(' ');
os.write(Constants.encodeASCII(getEncoding().name())); os.write(Constants.encodeASCII(getEncoding().name()));
@ -474,7 +475,7 @@ public class CommitBuilder {
r.append(gpgSignature != null ? gpgSignature.toString() : "NOT_SET"); r.append(gpgSignature != null ? gpgSignature.toString() : "NOT_SET");
r.append("\n"); r.append("\n");
if (encoding != null && encoding != UTF_8) { if (encoding != null && !References.isSameObject(encoding, UTF_8)) {
r.append("encoding "); r.append("encoding ");
r.append(encoding.name()); r.append(encoding.name());
r.append("\n"); r.append("\n");

Loading…
Cancel
Save