Skip to content

Commit

Permalink
use requireNonNull
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmarsuhail committed Jun 9, 2022
1 parent 0807cbd commit ebb1b1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import org.apache.hadoop.fs.statistics.IOStatistics;
import org.apache.hadoop.fs.statistics.IOStatisticsSource;

import static java.util.Objects.requireNonNull;

/**
* Provides an {@link InputStream} that allows reading from an S3 file.
*/
Expand Down Expand Up @@ -108,15 +110,10 @@ public S3InputStream(
S3AInputStream.InputStreamCallbacks client,
S3AInputStreamStatistics streamStatistics) {

Validate.checkNotNull(context, "context");
Validate.checkNotNull(s3Attributes, "s3Attributes");
Validate.checkNotNull(client, "client");
Validate.checkNotNull(streamStatistics, "streamStatistics");

this.context = context;
this.s3Attributes = s3Attributes;
this.client = client;
this.streamStatistics = streamStatistics;
this.context = requireNonNull(context);
this.s3Attributes = requireNonNull(s3Attributes);
this.client = requireNonNull(client);
this.streamStatistics = requireNonNull(streamStatistics);
this.ioStatistics = streamStatistics.getIOStatistics();
this.name = S3File.getPath(s3Attributes);
this.changeTracker = new ChangeTracker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,19 @@ public void testArgChecks() throws Exception {
new S3CachingInputStream(readContext, attrs, client, stats);

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

ExceptionAsserts.assertThrows(
IllegalArgumentException.class,
"'s3Attributes' must not be null",
NullPointerException.class,
() -> new S3CachingInputStream(readContext, null, client, stats));

ExceptionAsserts.assertThrows(
IllegalArgumentException.class,
"'client' must not be null",
NullPointerException.class,
() -> new S3CachingInputStream(readContext, attrs, null, stats));

ExceptionAsserts.assertThrows(
IllegalArgumentException.class,
"'streamStatistics' must not be null",
NullPointerException.class,
() -> new S3CachingInputStream(readContext, attrs, client, null));
}

Expand Down

0 comments on commit ebb1b1d

Please sign in to comment.