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 = [ ...@@ -25,8 +25,6 @@ ERRORPRONE_WARNINGS_TO_TURN_OFF = [
'SynchronizeOnNonFinalField', 'SynchronizeOnNonFinalField',
# TODO(crbug.com/802073): Follow steps in bug. # TODO(crbug.com/802073): Follow steps in bug.
'TypeParameterUnusedInFormals', 'TypeParameterUnusedInFormals',
# TODO(crbug.com/802075): Follow steps in bug.
'ReferenceEquality',
# TODO(crbug.com/803484): Follow steps in bug. # TODO(crbug.com/803484): Follow steps in bug.
'CatchFail', 'CatchFail',
# TODO(crbug.com/803485): Follow steps in bug. # TODO(crbug.com/803485): Follow steps in bug.
...@@ -99,6 +97,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [ ...@@ -99,6 +97,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'StaticGuardedByInstance', 'StaticGuardedByInstance',
'StaticQualifiedUsingExpression', 'StaticQualifiedUsingExpression',
'UseCorrectAssertInTests', 'UseCorrectAssertInTests',
'ReferenceEquality',
] ]
......
...@@ -295,6 +295,7 @@ public class MediaNotificationInfo { ...@@ -295,6 +295,7 @@ public class MediaNotificationInfo {
} }
@Override @Override
@SuppressWarnings("ReferenceEquality")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) return true; if (obj == this) return true;
if (!(obj instanceof MediaNotificationInfo)) return false; if (!(obj instanceof MediaNotificationInfo)) return false;
......
...@@ -1777,8 +1777,9 @@ public class LocationBarLayout extends FrameLayout ...@@ -1777,8 +1777,9 @@ public class LocationBarLayout extends FrameLayout
* @param skipCheck Whether to skip an out of bounds check. * @param skipCheck Whether to skip an out of bounds check.
* @return The url to navigate to. * @return The url to navigate to.
*/ */
private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int selectedIndex, @SuppressWarnings("ReferenceEquality")
boolean skipCheck) { 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 // 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 // receive suggestions until the native side is ready, so this is safe
assert mNativeInitialized assert mNativeInitialized
......
...@@ -322,7 +322,7 @@ public class SavePasswordsPreferences ...@@ -322,7 +322,7 @@ public class SavePasswordsPreferences
// Constructs the successful result: a valid URI and no error. // Constructs the successful result: a valid URI and no error.
public ExportResult(Uri uri) { public ExportResult(Uri uri) {
assert uri != null && uri != Uri.EMPTY; assert uri != null && !uri.equals(Uri.EMPTY);
mUri = uri; mUri = uri;
mError = null; mError = null;
} }
...@@ -624,7 +624,7 @@ public class SavePasswordsPreferences ...@@ -624,7 +624,7 @@ public class SavePasswordsPreferences
assert mExportState == EXPORT_STATE_CONFIRMED; assert mExportState == EXPORT_STATE_CONFIRMED;
mExportState = EXPORT_STATE_INACTIVE; mExportState = EXPORT_STATE_INACTIVE;
if (mExportFileUri == Uri.EMPTY) return; if (mExportFileUri.equals(Uri.EMPTY)) return;
Intent send = new Intent(Intent.ACTION_SEND); Intent send = new Intent(Intent.ACTION_SEND);
send.setType("text/csv"); send.setType("text/csv");
......
...@@ -886,8 +886,7 @@ public class AccountSigninView extends FrameLayout { ...@@ -886,8 +886,7 @@ public class AccountSigninView extends FrameLayout {
+ "by setText() or setTextNonRecordable()."; + "by setText() or setTextNonRecordable().";
// Ensure that the text hasn't changed since the assignment. // Ensure that the text hasn't changed since the assignment.
assert view.getText().toString() assert view.getText().toString().equals(metadata.getString())
== metadata.getString()
: "The text '" : "The text '"
+ view.getText().toString() + view.getText().toString()
+ "' has been modified after it was assigned by setText() " + "' has been modified after it was assigned by setText() "
......
...@@ -45,6 +45,7 @@ public class OfflineItem { ...@@ -45,6 +45,7 @@ public class OfflineItem {
} }
@Override @Override
@SuppressWarnings("ReferenceEquality")
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Progress) { if (obj instanceof Progress) {
Progress other = (Progress) obj; Progress other = (Progress) obj;
......
...@@ -598,8 +598,8 @@ public class VideoCaptureCamera ...@@ -598,8 +598,8 @@ public class VideoCaptureCamera
if (flashModes != null) { if (flashModes != null) {
builder.setSupportsTorch( builder.setSupportsTorch(
flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_TORCH)); flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_TORCH));
builder.setTorch(parameters.getFlashMode() builder.setTorch(android.hardware.Camera.Parameters.FLASH_MODE_TORCH.equals(
== android.hardware.Camera.Parameters.FLASH_MODE_TORCH); parameters.getFlashMode()));
builder.setRedEyeReduction( builder.setRedEyeReduction(
flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_RED_EYE)); flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_RED_EYE));
......
...@@ -47,7 +47,7 @@ public class AndroidProxySelectorTest { ...@@ -47,7 +47,7 @@ public class AndroidProxySelectorTest {
} }
static String toString(Proxy proxy) { 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. // java.net.Proxy only knows about http and socks proxies.
Proxy.Type type = proxy.type(); Proxy.Type type = proxy.type();
switch (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