Commit 00f0b342 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Fix errorprone ReferenceEquality warnings

Fix errorprone ReferenceEquality warnings and make
sure it is treated as error after this CL.

http://errorprone.info/bugpattern/ReferenceEquality

Bug: 802075

Change-Id: Icd9d0ccd0f625b1eef1d92d88600641b67a8587a
Reviewed-on: https://chromium-review.googlesource.com/911609Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Rob Buis <rob.buis@samsung.com>
Cr-Commit-Position: refs/heads/master@{#543225}
parent 4ff5fd38
......@@ -25,8 +25,6 @@ ERRORPRONE_WARNINGS_TO_TURN_OFF = [
'SynchronizeOnNonFinalField',
# TODO(crbug.com/802073): Follow steps in bug.
'TypeParameterUnusedInFormals',
# TODO(crbug.com/802075): Follow steps in bug.
'ReferenceEquality',
# TODO(crbug.com/803484): Follow steps in bug.
'CatchFail',
# TODO(crbug.com/803485): Follow steps in bug.
......@@ -99,6 +97,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'StaticGuardedByInstance',
'StaticQualifiedUsingExpression',
'UseCorrectAssertInTests',
'ReferenceEquality',
]
......
......@@ -295,6 +295,7 @@ public class MediaNotificationInfo {
}
@Override
@SuppressWarnings("ReferenceEquality")
public boolean equals(Object obj) {
if (obj == this) return true;
if (!(obj instanceof MediaNotificationInfo)) return false;
......
......@@ -1777,8 +1777,9 @@ public class LocationBarLayout extends FrameLayout
* @param skipCheck Whether to skip an out of bounds check.
* @return The url to navigate to.
*/
private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int selectedIndex,
boolean skipCheck) {
@SuppressWarnings("ReferenceEquality")
private String updateSuggestionUrlIfNeeded(
OmniboxSuggestion suggestion, int selectedIndex, boolean skipCheck) {
// Only called once we have suggestions, and don't have a listener though which we can
// receive suggestions until the native side is ready, so this is safe
assert mNativeInitialized
......
......@@ -322,7 +322,7 @@ public class SavePasswordsPreferences
// Constructs the successful result: a valid URI and no error.
public ExportResult(Uri uri) {
assert uri != null && uri != Uri.EMPTY;
assert uri != null && !uri.equals(Uri.EMPTY);
mUri = uri;
mError = null;
}
......@@ -624,7 +624,7 @@ public class SavePasswordsPreferences
assert mExportState == EXPORT_STATE_CONFIRMED;
mExportState = EXPORT_STATE_INACTIVE;
if (mExportFileUri == Uri.EMPTY) return;
if (mExportFileUri.equals(Uri.EMPTY)) return;
Intent send = new Intent(Intent.ACTION_SEND);
send.setType("text/csv");
......
......@@ -886,12 +886,11 @@ public class AccountSigninView extends FrameLayout {
+ "by setText() or setTextNonRecordable().";
// Ensure that the text hasn't changed since the assignment.
assert view.getText().toString()
== metadata.getString()
assert view.getText().toString().equals(metadata.getString())
: "The text '"
+ view.getText().toString()
+ "' has been modified after it was assigned by setText() "
+ "or setTextNonRecordable().";
+ view.getText().toString()
+ "' has been modified after it was assigned by setText() "
+ "or setTextNonRecordable().";
return metadata.getId();
}
......
......@@ -45,6 +45,7 @@ public class OfflineItem {
}
@Override
@SuppressWarnings("ReferenceEquality")
public boolean equals(Object obj) {
if (obj instanceof Progress) {
Progress other = (Progress) obj;
......
......@@ -598,8 +598,8 @@ public class VideoCaptureCamera
if (flashModes != null) {
builder.setSupportsTorch(
flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_TORCH));
builder.setTorch(parameters.getFlashMode()
== android.hardware.Camera.Parameters.FLASH_MODE_TORCH);
builder.setTorch(android.hardware.Camera.Parameters.FLASH_MODE_TORCH.equals(
parameters.getFlashMode()));
builder.setRedEyeReduction(
flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_RED_EYE));
......
......@@ -47,7 +47,7 @@ public class AndroidProxySelectorTest {
}
static String toString(Proxy proxy) {
if (proxy == Proxy.NO_PROXY) return "DIRECT";
if (proxy.equals(Proxy.NO_PROXY)) return "DIRECT";
// java.net.Proxy only knows about http and socks proxies.
Proxy.Type type = proxy.type();
switch (type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment