Polish
This commit is contained in:
@@ -292,20 +292,13 @@ abstract class AbstractApplicationContextRunner<SELF extends AbstractApplication
|
||||
consumer.accept(context);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
AnyThrow.throwUnchecked(ex);
|
||||
rethrow(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AnyThrow {
|
||||
|
||||
static void throwUnchecked(Throwable e) {
|
||||
AnyThrow.throwAny(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <E extends Throwable> void throwAny(Throwable e) throws E {
|
||||
throw (E) e;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
private <E extends Throwable> void rethrow(Throwable e) throws E {
|
||||
throw (E) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
|
||||
@@ -130,11 +130,16 @@ public final class TestPropertyValues {
|
||||
return call.call();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
AnyThrow.throwUnchecked(ex);
|
||||
return null; // never reached
|
||||
rethrow(ex);
|
||||
throw new IllegalStateException("Original cause not rethrown", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <E extends Throwable> void rethrow(Throwable e) throws E {
|
||||
throw (E) e;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addToSources(MutablePropertySources sources, Type type, String name) {
|
||||
if (sources.contains(name)) {
|
||||
@@ -310,16 +315,4 @@ public final class TestPropertyValues {
|
||||
|
||||
}
|
||||
|
||||
private static class AnyThrow {
|
||||
|
||||
static void throwUnchecked(Throwable e) {
|
||||
AnyThrow.throwAny(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <E extends Throwable> void throwAny(Throwable e) throws E {
|
||||
throw (E) e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -153,7 +153,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||
new HidePackagesClassLoader(Gson.class.getPackage().getName()))
|
||||
.run((context) -> {
|
||||
try {
|
||||
ClassUtils.forName(Gson.class.getName(), context.getClassLoader());
|
||||
ClassUtils.forName(Gson.class.getName(),
|
||||
context.getClassLoader());
|
||||
fail("Should have thrown a ClassNotFoundException");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
|
||||
Reference in New Issue
Block a user