Polish
This commit is contained in:
@@ -138,6 +138,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Ignore and continue
|
||||
}
|
||||
|
||||
// 2) Try to find locally
|
||||
@@ -147,6 +148,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||
return cls;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Ignore and continue
|
||||
}
|
||||
|
||||
// 3) Use standard loading
|
||||
|
||||
@@ -27,10 +27,13 @@ import org.springframework.boot.loader.data.RandomAccessData.ResourceAccess;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class Bytes {
|
||||
final class Bytes {
|
||||
|
||||
private static final byte[] EMPTY_BYTES = new byte[] {};
|
||||
|
||||
private Bytes() {
|
||||
}
|
||||
|
||||
public static byte[] get(RandomAccessData data) throws IOException {
|
||||
InputStream inputStream = data.getInputStream(ResourceAccess.ONCE);
|
||||
try {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Handler extends URLStreamHandler {
|
||||
.getDeclaredMethod("openConnection", URL.class);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Swallow and ignore
|
||||
}
|
||||
OPEN_CONNECTION_METHOD = method;
|
||||
}
|
||||
|
||||
@@ -34,16 +34,16 @@ public class ByteArrayStartsWith extends TypeSafeMatcher<byte[]> {
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("a byte array starting with ").appendValue(bytes);
|
||||
description.appendText("a byte array starting with ").appendValue(this.bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(byte[] item) {
|
||||
if (item.length < bytes.length) {
|
||||
if (item.length < this.bytes.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if (item[i] != bytes[i]) {
|
||||
for (int i = 0; i < this.bytes.length; i++) {
|
||||
if (item[i] != this.bytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,17 @@ public class ExecutableArchiveLauncherTests {
|
||||
assertArrayEquals(urls, ((URLClassLoader) classLoader).getURLs());
|
||||
}
|
||||
|
||||
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
action.call();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class UnitTestExecutableArchiveLauncher extends
|
||||
ExecutableArchiveLauncher {
|
||||
|
||||
@@ -103,15 +114,4 @@ public class ExecutableArchiveLauncherTests {
|
||||
}
|
||||
}
|
||||
|
||||
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
action.call();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class JarFileArchiveTests {
|
||||
|
||||
private void setup(boolean unpackNested) throws Exception {
|
||||
this.rootJarFile = this.temporaryFolder.newFile();
|
||||
this.rootJarFileUrl = rootJarFile.toURI().toString();
|
||||
System.out.println(rootJarFileUrl);
|
||||
this.rootJarFileUrl = this.rootJarFile.toURI().toString();
|
||||
System.out.println(this.rootJarFileUrl);
|
||||
TestJarCreator.createTestJar(this.rootJarFile, unpackNested);
|
||||
this.archive = new JarFileArchive(this.rootJarFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user