Skip to content

Commit 2a499b6

Browse files
authored
Update spotbugs version, fix runner ubuntu version, fix found spotbugs issues (apache#35303)
1 parent e16bb9a commit 2a499b6

File tree

14 files changed

+27
-9
lines changed

14 files changed

+27
-9
lines changed

.github/workflows/beam_PreCommit_Java_Solace_IO_Direct.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
(github.event_name == 'schedule' && github.repository == 'apache/beam') ||
7575
github.event_name == 'workflow_dispatch' ||
7676
github.event.comment.body == 'Run Java_Solace_IO_Direct PreCommit'
77-
runs-on: ubuntu-20.04
77+
runs-on: ubuntu-latest
7878
steps:
7979
- uses: actions/checkout@v4
8080
- name: Setup repository

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class BeamModulePlugin implements Plugin<Project> {
647647
def solace_version = "10.21.0"
648648
def spark2_version = "2.4.8"
649649
def spark3_version = "3.5.0"
650-
def spotbugs_version = "4.0.6"
650+
def spotbugs_version = "4.8.3"
651651
def testcontainers_version = "1.19.7"
652652
// [bomupgrader] determined by: org.apache.arrow:arrow-memory-core, consistent with: google_cloud_platform_libraries_bom
653653
def arrow_version = "15.0.2"

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/auth/GoogleADCIdTokenProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.beam.sdk.io.aws2.auth;
1919

20+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2021
import java.io.IOException;
2122
import java.util.Arrays;
2223
import org.apache.beam.vendor.grpc.v1p69p0.com.google.auth.oauth2.GoogleCredentials;
@@ -40,6 +41,7 @@
4041
* "durationSeconds": 3600
4142
* }}</pre>
4243
*/
44+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
4345
public class GoogleADCIdTokenProvider implements WebIdTokenProvider {
4446
private final IdTokenProvider idTokenProvider;
4547

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/kinesis/GetKinesisRecordsResult.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
*/
1818
package org.apache.beam.sdk.io.aws2.kinesis;
1919

20+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2021
import java.util.List;
2122
import java.util.stream.Collectors;
2223
import software.amazon.kinesis.retrieval.KinesisClientRecord;
2324

2425
/** Represents the output of 'get' operation on Kinesis stream. */
26+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
2527
class GetKinesisRecordsResult {
2628

2729
private final List<KinesisRecord> records;

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/kinesis/KinesisIO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static software.amazon.awssdk.services.kinesis.model.ShardFilterType.AT_LATEST;
2626

2727
import com.google.auto.value.AutoValue;
28+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2829
import java.io.Serializable;
2930
import java.math.BigInteger;
3031
import java.security.MessageDigest;
@@ -326,6 +327,7 @@
326327
* then opt to retry the current partition in entirety or abort if the max number of retries of the
327328
* runner is reached.
328329
*/
330+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
329331
public final class KinesisIO {
330332

331333
/** Returns a new {@link Read} transform for reading from Kinesis. */

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/kinesis/KinesisPartitioner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import java.io.Serializable;
2121
import java.math.BigInteger;
22-
import java.util.Random;
22+
import java.util.concurrent.ThreadLocalRandom;
2323
import javax.annotation.Nonnull;
2424
import javax.annotation.Nullable;
2525
import org.apache.commons.lang3.StringUtils;
@@ -94,7 +94,7 @@ static <T> KinesisPartitioner<T> explicitRandomPartitioner(int shards) {
9494
@Nonnull
9595
@Override
9696
public String getExplicitHashKey(T record) {
97-
return hashKeys[new Random().nextInt(shards)];
97+
return hashKeys[ThreadLocalRandom.current().nextInt(shards)];
9898
}
9999
};
100100
}

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/kinesis/ShardRecordsIterator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
2121

22+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2223
import java.util.ArrayList;
2324
import java.util.List;
2425
import java.util.concurrent.atomic.AtomicReference;
@@ -34,6 +35,7 @@
3435
* ShardRecordsIterator#readNextBatch()}. Client has to confirm processed records by calling {@link
3536
* ShardRecordsIterator#ackRecord(KinesisRecord)} method.
3637
*/
38+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
3739
class ShardRecordsIterator {
3840

3941
private static final Logger LOG = LoggerFactory.getLogger(ShardRecordsIterator.class);

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/s3/S3ReadableSeekableByteChannel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
2222
import static software.amazon.awssdk.utils.IoUtils.drainInputStream;
2323

24+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2425
import java.io.BufferedInputStream;
2526
import java.io.IOException;
2627
import java.nio.ByteBuffer;
@@ -42,6 +43,7 @@
4243
@SuppressWarnings({
4344
"nullness" // TODO(https://github.com/apache/beam/issues/20497)
4445
})
46+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
4547
class S3ReadableSeekableByteChannel implements SeekableByteChannel {
4648
private static final long ABORT_THRESHOLD = 1024 * 8; // corresponds to default TCP buffer size
4749
private final S3Client s3Client;

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/s3/S3WritableByteChannel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
2121
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
2222

23+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2324
import java.io.ByteArrayInputStream;
2425
import java.io.IOException;
2526
import java.nio.ByteBuffer;
@@ -47,6 +48,7 @@
4748
@SuppressWarnings({
4849
"nullness" // TODO(https://github.com/apache/beam/issues/20497)
4950
})
51+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization is safe.")
5052
class S3WritableByteChannel implements WritableByteChannel {
5153

5254
private final S3Client s3Client;

sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sqs/SqsIO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkState;
2626

2727
import com.google.auto.value.AutoValue;
28+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2829
import java.io.Serializable;
2930
import java.util.ArrayList;
3031
import java.util.Arrays;
@@ -140,6 +141,7 @@
140141
* then opt to retry the current partition in entirety or abort if the max number of retries of the
141142
* runner is reached.
142143
*/
144+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Initialization safe.")
143145
public class SqsIO {
144146

145147
public static Read read() {

0 commit comments

Comments
 (0)