Skip to content

Commit 937f857

Browse files
hengyunabcwilkinsona
authored andcommitted
Ensure that LaunchedURLClassLoader works when thread is interrupted
See gh-6683
1 parent ffc0dc4 commit 937f857

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -244,17 +244,10 @@ private class FilePool {
244244
}
245245

246246
public RandomAccessFile acquire() throws IOException {
247-
try {
248-
this.available.acquire();
249-
RandomAccessFile file = this.files.poll();
250-
return (file == null
251-
? new RandomAccessFile(RandomAccessDataFile.this.file, "r")
252-
: file);
253-
}
254-
catch (InterruptedException ex) {
255-
Thread.currentThread().interrupt();
256-
throw new IOException(ex);
257-
}
247+
this.available.acquireUninterruptibly();
248+
RandomAccessFile file = this.files.poll();
249+
return (file == null
250+
? new RandomAccessFile(RandomAccessDataFile.this.file, "r") : file);
258251
}
259252

260253
public void release(RandomAccessFile file) {
@@ -263,22 +256,16 @@ public void release(RandomAccessFile file) {
263256
}
264257

265258
public void close() throws IOException {
259+
this.available.acquireUninterruptibly(this.size);
266260
try {
267-
this.available.acquire(this.size);
268-
try {
269-
RandomAccessFile file = this.files.poll();
270-
while (file != null) {
271-
file.close();
272-
file = this.files.poll();
273-
}
274-
}
275-
finally {
276-
this.available.release(this.size);
261+
RandomAccessFile file = this.files.poll();
262+
while (file != null) {
263+
file.close();
264+
file = this.files.poll();
277265
}
278266
}
279-
catch (InterruptedException ex) {
280-
Thread.currentThread().interrupt();
281-
throw new IOException(ex);
267+
finally {
268+
this.available.release(this.size);
282269
}
283270
}
284271

0 commit comments

Comments
 (0)