Skip to content

Commit

Permalink
remove handling for defunct InterruptedIOException
Browse files Browse the repository at this point in the history
  • Loading branch information
bchristi-git committed Aug 27, 2024
1 parent 0c744ea commit 5eefe66
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions src/java.base/share/classes/jdk/internal/loader/Resource.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,7 +28,6 @@
import java.io.EOFException;
import java.net.URL;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.InputStream;
import java.security.CodeSigner;
import java.util.jar.Manifest;
Expand Down Expand Up @@ -87,24 +86,7 @@ public byte[] getBytes() throws IOException {
// Get stream before content length so that a FileNotFoundException
// can propagate upwards without being caught too early
InputStream in = cachedInputStream();

// This code has been uglified to protect against interrupts.
// Even if a thread has been interrupted when loading resources,
// the IO should not abort, so must carefully retry, failing only
// if the retry leads to some other IO exception.

boolean isInterrupted = Thread.interrupted();
int len;
for (;;) {
try {
len = getContentLength();
break;
} catch (InterruptedIOException iioe) {
Thread.interrupted();
isInterrupted = true;
}
}

int len = getContentLength();
try {
b = new byte[0];
if (len == -1) len = Integer.MAX_VALUE;
Expand All @@ -121,13 +103,7 @@ public byte[] getBytes() throws IOException {
} else {
bytesToRead = b.length - pos;
}
int cc = 0;
try {
cc = in.read(b, pos, bytesToRead);
} catch (InterruptedIOException iioe) {
Thread.interrupted();
isInterrupted = true;
}
int cc = in.read(b, pos, bytesToRead);
if (cc < 0) {
if (len != Integer.MAX_VALUE) {
throw new EOFException("Detect premature EOF");
Expand All @@ -143,13 +119,7 @@ public byte[] getBytes() throws IOException {
} finally {
try {
in.close();
} catch (InterruptedIOException iioe) {
isInterrupted = true;
} catch (IOException ignore) {}

if (isInterrupted) {
Thread.currentThread().interrupt();
}
}
return b;
}
Expand Down

0 comments on commit 5eefe66

Please sign in to comment.