Merge branch '1.3.x'
This commit is contained in:
commit
e2ceece525
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -244,17 +244,10 @@ public class RandomAccessDataFile implements RandomAccessData {
|
|||
}
|
||||
|
||||
public RandomAccessFile acquire() throws IOException {
|
||||
try {
|
||||
this.available.acquire();
|
||||
this.available.acquireUninterruptibly();
|
||||
RandomAccessFile file = this.files.poll();
|
||||
return (file == null
|
||||
? new RandomAccessFile(RandomAccessDataFile.this.file, "r")
|
||||
: file);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IOException(ex);
|
||||
}
|
||||
? new RandomAccessFile(RandomAccessDataFile.this.file, "r") : file);
|
||||
}
|
||||
|
||||
public void release(RandomAccessFile file) {
|
||||
|
@ -263,8 +256,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
|||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
this.available.acquire(this.size);
|
||||
this.available.acquireUninterruptibly(this.size);
|
||||
try {
|
||||
RandomAccessFile file = this.files.poll();
|
||||
while (file != null) {
|
||||
|
@ -276,11 +268,6 @@ public class RandomAccessDataFile implements RandomAccessData {
|
|||
this.available.release(this.size);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public class LaunchedURLClassLoaderTests {
|
||||
|
@ -85,4 +86,23 @@ public class LaunchedURLClassLoaderTests {
|
|||
assertThat(resource.openConnection().getInputStream().read()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveFromNestedWhileThreadIsInterrupted() throws Exception {
|
||||
File file = this.temporaryFolder.newFile();
|
||||
TestJarCreator.createTestJar(file);
|
||||
JarFile jarFile = new JarFile(file);
|
||||
URL url = jarFile.getUrl();
|
||||
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { url },
|
||||
null);
|
||||
try {
|
||||
Thread.currentThread().interrupt();
|
||||
URL resource = loader.getResource("nested.jar!/3.dat");
|
||||
assertThat(resource.toString(), equalTo(url + "nested.jar!/3.dat"));
|
||||
assertThat(resource.openConnection().getInputStream().read(), equalTo(3));
|
||||
}
|
||||
finally {
|
||||
Thread.interrupted();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue