Skip to content

Commit ebb1b1d

Browse files
committed
use requireNonNull
1 parent 0807cbd commit ebb1b1d

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/read/S3InputStream.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import org.apache.hadoop.fs.statistics.IOStatistics;
4545
import org.apache.hadoop.fs.statistics.IOStatisticsSource;
4646

47+
import static java.util.Objects.requireNonNull;
48+
4749
/**
4850
* Provides an {@link InputStream} that allows reading from an S3 file.
4951
*/
@@ -108,15 +110,10 @@ public S3InputStream(
108110
S3AInputStream.InputStreamCallbacks client,
109111
S3AInputStreamStatistics streamStatistics) {
110112

111-
Validate.checkNotNull(context, "context");
112-
Validate.checkNotNull(s3Attributes, "s3Attributes");
113-
Validate.checkNotNull(client, "client");
114-
Validate.checkNotNull(streamStatistics, "streamStatistics");
115-
116-
this.context = context;
117-
this.s3Attributes = s3Attributes;
118-
this.client = client;
119-
this.streamStatistics = streamStatistics;
113+
this.context = requireNonNull(context);
114+
this.s3Attributes = requireNonNull(s3Attributes);
115+
this.client = requireNonNull(client);
116+
this.streamStatistics = requireNonNull(streamStatistics);
120117
this.ioStatistics = streamStatistics.getIOStatistics();
121118
this.name = S3File.getPath(s3Attributes);
122119
this.changeTracker = new ChangeTracker(

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/read/TestS3InputStream.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,19 @@ public void testArgChecks() throws Exception {
5959
new S3CachingInputStream(readContext, attrs, client, stats);
6060

6161
ExceptionAsserts.assertThrows(
62-
IllegalArgumentException.class,
63-
"'context' must not be null",
62+
NullPointerException.class,
6463
() -> new S3CachingInputStream(null, attrs, client, stats));
6564

6665
ExceptionAsserts.assertThrows(
67-
IllegalArgumentException.class,
68-
"'s3Attributes' must not be null",
66+
NullPointerException.class,
6967
() -> new S3CachingInputStream(readContext, null, client, stats));
7068

7169
ExceptionAsserts.assertThrows(
72-
IllegalArgumentException.class,
73-
"'client' must not be null",
70+
NullPointerException.class,
7471
() -> new S3CachingInputStream(readContext, attrs, null, stats));
7572

7673
ExceptionAsserts.assertThrows(
77-
IllegalArgumentException.class,
78-
"'streamStatistics' must not be null",
74+
NullPointerException.class,
7975
() -> new S3CachingInputStream(readContext, attrs, client, null));
8076
}
8177

0 commit comments

Comments
 (0)