HADOOP-17599. Remove NULL checks before instanceof (#2804)

This commit is contained in:
Jack Jiang 2021-03-23 23:46:11 +08:00 committed by GitHub
parent d77c7ab4e0
commit d8ec8ab965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 20 additions and 21 deletions

View File

@ -1353,7 +1353,7 @@ public abstract class AbstractFileSystem implements PathCapabilities {
@Override //Object @Override //Object
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null || !(other instanceof AbstractFileSystem)) { if (!(other instanceof AbstractFileSystem)) {
return false; return false;
} }
return myUri.equals(((AbstractFileSystem) other).myUri); return myUri.equals(((AbstractFileSystem) other).myUri);

View File

@ -97,7 +97,7 @@ public class DelegationTokenRenewer
public boolean equals(final Object that) { public boolean equals(final Object that) {
if (this == that) { if (this == that) {
return true; return true;
} else if (that == null || !(that instanceof RenewAction)) { } else if (!(that instanceof RenewAction)) {
return false; return false;
} }
return token.equals(((RenewAction<?>)that).token); return token.equals(((RenewAction<?>)that).token);

View File

@ -47,7 +47,7 @@ public abstract class FileChecksum implements Writable {
if (other == this) { if (other == this) {
return true; return true;
} }
if (other == null || !(other instanceof FileChecksum)) { if (!(other instanceof FileChecksum)) {
return false; return false;
} }

View File

@ -93,7 +93,7 @@ public class RpcCallCache {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null || !(obj instanceof ClientRequest)) { if (!(obj instanceof ClientRequest)) {
return false; return false;
} }
ClientRequest other = (ClientRequest) obj; ClientRequest other = (ClientRequest) obj;

View File

@ -188,8 +188,7 @@ public class MockWasbAuthorizerImpl implements WasbAuthorizerInterface {
return true; return true;
} }
if (obj == null if (!(obj instanceof AuthorizationComponent)) {
|| !(obj instanceof AuthorizationComponent)) {
return false; return false;
} }

View File

@ -45,7 +45,7 @@ public abstract class GetAllResourceProfilesResponse {
if (this == other) { if (this == other) {
return true; return true;
} }
if (other == null || !(other instanceof GetAllResourceProfilesResponse)) { if (!(other instanceof GetAllResourceProfilesResponse)) {
return false; return false;
} }
return ((GetAllResourceProfilesResponse) other).getResourceProfiles() return ((GetAllResourceProfilesResponse) other).getResourceProfiles()

View File

@ -45,7 +45,7 @@ public abstract class GetAllResourceTypeInfoResponse {
if (this == other) { if (this == other) {
return true; return true;
} }
if (other == null || !(other instanceof GetAllResourceTypeInfoResponse)) { if (!(other instanceof GetAllResourceTypeInfoResponse)) {
return false; return false;
} }
return ((GetAllResourceTypeInfoResponse) other).getResourceTypeInfo() return ((GetAllResourceTypeInfoResponse) other).getResourceTypeInfo()

View File

@ -45,7 +45,7 @@ public abstract class GetResourceProfileRequest {
if (this == other) { if (this == other) {
return true; return true;
} }
if (other == null || !(other instanceof GetResourceProfileRequest)) { if (!(other instanceof GetResourceProfileRequest)) {
return false; return false;
} }
return this.getProfileName() return this.getProfileName()

View File

@ -54,7 +54,7 @@ public abstract class GetResourceProfileResponse {
return true; return true;
} }
if (other == null || !(other instanceof GetResourceProfileResponse)) { if (!(other instanceof GetResourceProfileResponse)) {
return false; return false;
} }
return this.getResource() return this.getResource()

View File

@ -139,7 +139,7 @@ public class LightWeightResource extends Resource {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null || !(obj instanceof Resource)) { if (!(obj instanceof Resource)) {
return false; return false;
} }
Resource other = (Resource) obj; Resource other = (Resource) obj;

View File

@ -68,7 +68,7 @@ public class Log4jWarningErrorMetricsAppender extends AppenderSkeleton {
@Override @Override
public boolean equals(Object e) { public boolean equals(Object e) {
if (e == null || !(e instanceof PurgeElement)) { if (!(e instanceof PurgeElement)) {
return false; return false;
} }
if (e == this) { if (e == this) {

View File

@ -43,7 +43,7 @@ public class VolumeId {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof VolumeId)) { if (!(obj instanceof VolumeId)) {
return false; return false;
} }
return StringUtils.equalsIgnoreCase(volumeId, return StringUtils.equalsIgnoreCase(volumeId,

View File

@ -135,7 +135,7 @@ public class PrivilegedOperation {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null || !(other instanceof PrivilegedOperation)) { if (!(other instanceof PrivilegedOperation)) {
return false; return false;
} }

View File

@ -49,7 +49,7 @@ public class AssignedDevice implements Serializable, Comparable {
@Override @Override
public int compareTo(Object o) { public int compareTo(Object o) {
if (o == null || !(o instanceof AssignedDevice)) { if (!(o instanceof AssignedDevice)) {
return -1; return -1;
} }
AssignedDevice other = (AssignedDevice) o; AssignedDevice other = (AssignedDevice) o;
@ -62,7 +62,7 @@ public class AssignedDevice implements Serializable, Comparable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null || !(o instanceof AssignedDevice)) { if (!(o instanceof AssignedDevice)) {
return false; return false;
} }
AssignedDevice other = (AssignedDevice) o; AssignedDevice other = (AssignedDevice) o;

View File

@ -44,7 +44,7 @@ public class AssignedGpuDevice extends GpuDevice {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof AssignedGpuDevice)) { if (!(obj instanceof AssignedGpuDevice)) {
return false; return false;
} }
AssignedGpuDevice other = (AssignedGpuDevice) obj; AssignedGpuDevice other = (AssignedGpuDevice) obj;
@ -54,7 +54,7 @@ public class AssignedGpuDevice extends GpuDevice {
@Override @Override
public int compareTo(Object obj) { public int compareTo(Object obj) {
if (obj == null || (!(obj instanceof AssignedGpuDevice))) { if ((!(obj instanceof AssignedGpuDevice))) {
return -1; return -1;
} }

View File

@ -43,7 +43,7 @@ public class GpuDevice implements Serializable, Comparable {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof GpuDevice)) { if (!(obj instanceof GpuDevice)) {
return false; return false;
} }
GpuDevice other = (GpuDevice) obj; GpuDevice other = (GpuDevice) obj;
@ -52,7 +52,7 @@ public class GpuDevice implements Serializable, Comparable {
@Override @Override
public int compareTo(Object obj) { public int compareTo(Object obj) {
if (obj == null || (!(obj instanceof GpuDevice))) { if (!(obj instanceof GpuDevice)) {
return -1; return -1;
} }

View File

@ -54,7 +54,7 @@ public final class ContainerRuntimeContext {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof Attribute)){ if (!(obj instanceof Attribute)){
return false; return false;
} }