Skip to content

Commit 0fb490f

Browse files
authored
[ErrorProne] Enable EmptyCatch Error Prone check and document ignored exceptions (#37754)
1 parent 90c2ab2 commit 0fb490f

14 files changed

Lines changed: 15 additions & 1 deletion

File tree

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-
"EmptyCatch",
15421541
"EqualsGetClass",
15431542
"EqualsUnsafeCast",
15441543
"EscapedEntity",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void onStatus(Status status) {
7373
try {
7474
queue.offer(status);
7575
} catch (Exception ignored) {
76+
// Ignore exceptions during enqueueing.
7677
}
7778
}
7879

runners/flink/src/main/java/org/apache/beam/runners/flink/metrics/MetricsAccumulator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public Accumulator<MetricsContainerStepMap, MetricsContainerStepMap> clone() {
5656
try {
5757
super.clone();
5858
} catch (CloneNotSupportedException ignored) {
59+
// Ignore CloneNotSupportedException
5960
}
6061
MetricsAccumulator metricsAccumulator = new MetricsAccumulator();
6162
metricsAccumulator.getLocalValue().updateAll(this.getLocalValue());

runners/prism/java/src/main/java/org/apache/beam/runners/prism/PrismExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void stop() {
7979
try {
8080
boolean ignored = executorService.awaitTermination(5000L, TimeUnit.MILLISECONDS);
8181
} catch (InterruptedException ignored) {
82+
// Ignore InterruptedException during shutdown.
8283
}
8384
if (process == null) {
8485
return;
@@ -90,6 +91,7 @@ void stop() {
9091
try {
9192
process.waitFor();
9293
} catch (InterruptedException ignored) {
94+
// Ignore InterruptedException during shutdown.
9395
}
9496
}
9597

sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GceMetadataUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static String fetchMetadata(String key) {
6060
}
6161
}
6262
} catch (IOException ignored) {
63+
LOG.debug("Failed to fetch GCE metadata.", ignored);
6364
}
6465

6566
// The return value can be an empty string, which may mean it's running on a non DataflowRunner.

sdks/java/io/amazon-web-services2/src/test/java/org/apache/beam/sdk/io/aws2/common/AsyncBatchWriteHandlerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ private void eventually(int attempts, Runnable fun) {
253253
fun.run();
254254
return;
255255
} catch (AssertionError | InterruptedException t) {
256+
// Ignore and try again.
256257
}
257258
}
258259
fun.run();

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/changestreams/dao/DaoFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public void close() {
7272
BigtableChangeStreamAccessor.getOrCreate(changeStreamConfig).close();
7373
}
7474
} catch (Exception ignored) {
75+
// Ignore exceptions on close.
7576
}
7677
}
7778

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,7 @@ private int parseBundleStatus(String status) {
15401540
try {
15411541
statusCode = Integer.parseInt(status.substring(0, 3));
15421542
} catch (IndexOutOfBoundsException | NumberFormatException ignored) {
1543+
// Ignore parsing exception so we can return the default 404
15431544
}
15441545
return statusCode;
15451546
}

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ public List<PubsubMessage> waitForNMessages(int n, Duration timeoutDuration)
340340
try {
341341
Thread.sleep(1000);
342342
} catch (InterruptedException ignored) {
343+
// Ignore interrupt and continue polling.
343344
}
344345
}
345346

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsubSignal.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ private String pollForResultForDuration(
323323
try {
324324
Thread.sleep(1000);
325325
} catch (InterruptedException ignored) {
326+
// Ignore interrupt and continue polling.
326327
}
327328
}
328329

0 commit comments

Comments
 (0)