Skip to content

Commit d16f5d1

Browse files
authored
[ErrorProne] Fix EqualsGetClass warnings and enable Error Prone check (#37758)
* addressed all EqualsGetClass warnings * Fix GetterBasedSchemaProvider.equals * supress equalsGetClass in ProtoCoder and DynamicProtoCoder.
1 parent c05733a commit d16f5d1

File tree

138 files changed

+229
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+229
-225
lines changed

buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,6 @@ class BeamModulePlugin implements Plugin<Project> {
15381538
"ComparableType",
15391539
"DoNotMockAutoValue",
15401540
"EmptyBlockTag",
1541-
"EqualsGetClass",
15421541
"EqualsUnsafeCast",
15431542
"EscapedEntity",
15441543
"ExtendsAutoValue",

examples/java/iceberg/src/main/java/org/apache/beam/examples/iceberg/IcebergRestCatalogStreamingWriteExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public boolean equals(@Nullable Object o) {
211211
if (this == o) {
212212
return true;
213213
}
214-
if (o == null || getClass() != o.getClass()) {
214+
if (!(o instanceof Accum)) {
215215
return false;
216216
}
217217
Accum accum = (Accum) o;

examples/java/src/main/java/org/apache/beam/examples/complete/TrafficRoutes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public boolean equals(Object object) {
140140
if (object == null) {
141141
return false;
142142
}
143-
if (object.getClass() != getClass()) {
143+
if (!(object instanceof StationSpeed)) {
144144
return false;
145145
}
146146
StationSpeed otherStationSpeed = (StationSpeed) object;

examples/java/src/main/java/org/apache/beam/examples/complete/game/UserScore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public boolean equals(Object o) {
121121
if (this == o) {
122122
return true;
123123
}
124-
if (o == null || o.getClass() != this.getClass()) {
124+
if (!(o instanceof GameActionInfo)) {
125125
return false;
126126
}
127127

examples/java/twitter/src/main/java/org/apache/beam/examples/twitterstreamgenerator/ReadFromTwitterDoFn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public boolean equals(@Nullable Object o) {
6464
if (this == o) {
6565
return true;
6666
}
67-
if (o == null || getClass() != o.getClass()) {
67+
if (!(o instanceof OffsetHolder)) {
6868
return false;
6969
}
7070
OffsetHolder that = (OffsetHolder) o;

examples/java/twitter/src/main/java/org/apache/beam/examples/twitterstreamgenerator/TwitterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public boolean equals(@Nullable Object o) {
5353
if (this == o) {
5454
return true;
5555
}
56-
if (o == null || getClass() != o.getClass()) {
56+
if (!(o instanceof TwitterConfig)) {
5757
return false;
5858
}
5959
TwitterConfig that = (TwitterConfig) o;

runners/core-java/src/main/java/org/apache/beam/runners/core/construction/SerializablePipelineOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean equals(@Nullable Object o) {
8989
if (this == o) {
9090
return true;
9191
}
92-
if (o == null || getClass() != o.getClass()) {
92+
if (!(o instanceof SerializablePipelineOptions)) {
9393
return false;
9494
}
9595
SerializablePipelineOptions that = (SerializablePipelineOptions) o;

runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/BoundedTrieData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public final boolean equals(@Nullable Object other) {
286286
if (this == other) {
287287
return true;
288288
}
289-
if (other == null || this.getClass() != other.getClass()) {
289+
if (!(other instanceof BoundedTrieData)) {
290290
return false;
291291
}
292292
BoundedTrieData that = (BoundedTrieData) other;
@@ -590,7 +590,7 @@ public boolean equals(@Nullable Object other) {
590590
if (this == other) {
591591
return true;
592592
}
593-
if (other == null || getClass() != other.getClass()) {
593+
if (!(other instanceof BoundedTrieNode)) {
594594
return false;
595595
}
596596
BoundedTrieNode that = (BoundedTrieNode) other;

runners/flink/2.0/src/main/java/org/apache/beam/runners/flink/FlinkExecutionEnvironments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public Map<String, String> toMap() {
309309

310310
@Override
311311
public boolean equals(Object obj) {
312-
if (obj == null || this.getClass() != obj.getClass()) {
312+
if (!(obj instanceof GlobalJobParametersImpl)) {
313313
return false;
314314
}
315315

runners/flink/2.0/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public boolean equals(@Nullable Object o) {
110110
if (this == o) {
111111
return true;
112112
}
113-
if (o == null || getClass() != o.getClass()) {
113+
if (!(o instanceof CoderTypeInformation)) {
114114
return false;
115115
}
116116

0 commit comments

Comments
 (0)