mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extension loading: more cancellability, remove log.warn producing too much noise and unrealistic to fix
This commit is contained in:
+3
@@ -63,6 +63,9 @@ public class ExtensionComponentAdapter implements LoadingOrder.Orderable, Assign
|
||||
if (instance == null) {
|
||||
try {
|
||||
Class impl = loadImplementationClass();
|
||||
|
||||
ExtensionPointImpl.CHECK_CANCELED.run();
|
||||
|
||||
instance = new CachingConstructorInjectionComponentAdapter(getComponentKey(), impl, null, true).getComponentInstance(container);
|
||||
|
||||
if (myExtensionElement != null) {
|
||||
|
||||
+8
-19
@@ -552,27 +552,16 @@ public final class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
|
||||
private static Runnable CHECK_CANCELED = EmptyRunnable.getInstance();
|
||||
static Runnable CHECK_CANCELED = EmptyRunnable.getInstance();
|
||||
|
||||
public static void setCheckCanceledAction(Runnable checkCanceled) {
|
||||
CHECK_CANCELED = new Runnable() {
|
||||
final Set<Throwable> reported = ContainerUtil.newConcurrentSet();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
checkCanceled.run();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
if (!isInsideClassInitializer(e.getStackTrace())) { // otherwise ExceptionInInitializerError happens and the class is screwed forever
|
||||
throw e;
|
||||
}
|
||||
else {
|
||||
Throwable throwable = new Throwable();
|
||||
if (reported.add(throwable)) {
|
||||
LOG.warn("Don't instantiate extensions from class initializer", throwable);
|
||||
}
|
||||
}
|
||||
CHECK_CANCELED = () -> {
|
||||
try {
|
||||
checkCanceled.run();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
if (!isInsideClassInitializer(e.getStackTrace())) { // otherwise ExceptionInInitializerError happens and the class is screwed forever
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user