Skip to content

Commit

Permalink
Add Objects.requireNonNull(this) in newStream
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Apr 2, 2024
1 parent 8c753a4 commit 0b21605
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions api/src/main/java/jakarta/mail/util/SharedFileInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,19 @@ public long getPosition() {
*/
@Override
public synchronized InputStream newStream(long start, long end) {
if (in == null)
throw new RuntimeException("Stream closed");
if (start < 0)
throw new IllegalArgumentException("start < 0");
if (end == -1)
end = datalen;

return new SharedFileInputStream(sf,
this.start + start, end - start, bufsize);
try {
if (in == null)
throw new RuntimeException("Stream closed");
if (start < 0)
throw new IllegalArgumentException("start < 0");
if (end == -1)
end = datalen;

return new SharedFileInputStream(sf,
this.start + start, end - start, bufsize);
} finally {
Objects.requireNonNull(this); //TODO: replace with Reference.reachabilityFence
}
}

// for testing...
Expand Down

0 comments on commit 0b21605

Please sign in to comment.