Skip to content

Commit 39fa360

Browse files
committed
Make JarCacheSupport be Closeable
1 parent 9dbda48 commit 39fa360

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/hudson/remoting/Channel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,9 @@ public void close(@CheckForNull Throwable diagnosis) throws IOException {
16111611
terminate(e);
16121612
return;
16131613
}
1614+
if (jarCache instanceof Closeable c) {
1615+
c.close();
1616+
}
16141617
outClosed = new IOException(
16151618
diagnosis); // last command sent. no further command allowed. lock guarantees that no command will
16161619
// slip inbetween

src/main/java/hudson/remoting/JarCacheSupport.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import edu.umd.cs.findbugs.annotations.NonNull;
44
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5+
import java.io.Closeable;
56
import java.io.IOException;
67
import java.net.URL;
78
import java.util.concurrent.CompletableFuture;
@@ -21,7 +22,7 @@
2122
* @author Kohsuke Kawaguchi
2223
* @since 2.24
2324
*/
24-
public abstract class JarCacheSupport extends JarCache {
25+
public abstract class JarCacheSupport extends JarCache implements Closeable {
2526
/**
2627
* Remember in-progress jar file resolution to avoid retrieving the same jar file twice.
2728
*/
@@ -75,6 +76,12 @@ private CompletableFuture<URL> submitDownload(Channel channel, long sum1, long s
7576
return promise;
7677
}
7778

79+
@Override
80+
public void close() throws IOException {
81+
// TODO Java 21 maybe just use ExecutorService.close()
82+
downloader.shutdown();
83+
}
84+
7885
private class DownloadRunnable implements Runnable {
7986

8087
final Channel channel;

0 commit comments

Comments
 (0)