mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
QueueProcessor: survive on LOG.error in tests (more correct)
This commit is contained in:
@@ -77,18 +77,13 @@ public class QueueProcessor<T> {
|
||||
private static <T> PairConsumer<T, Runnable> wrappingProcessor(final Consumer<T> processor) {
|
||||
return new PairConsumer<T, Runnable>() {
|
||||
@Override
|
||||
public void consume(T item, Runnable runnable) {
|
||||
try {
|
||||
processor.consume(item);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
try {
|
||||
LOG.error(e);
|
||||
public void consume(final T item, Runnable runnable) {
|
||||
runSafely(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processor.consume(item);
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
// should survive assertions
|
||||
}
|
||||
}
|
||||
});
|
||||
runnable.run();
|
||||
}
|
||||
};
|
||||
@@ -202,17 +197,12 @@ public class QueueProcessor<T> {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myDeathCondition.value(null)) return;
|
||||
try {
|
||||
myProcessor.consume(item, myContinuationContext);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
try {
|
||||
LOG.error(t);
|
||||
runSafely(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myProcessor.consume(item, myContinuationContext);
|
||||
}
|
||||
catch (Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
@@ -231,6 +221,20 @@ public class QueueProcessor<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void runSafely(Runnable run) {
|
||||
try {
|
||||
run.run();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
try {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
synchronized (myQueue) {
|
||||
return myQueue.isEmpty() && (!isProcessing);
|
||||
|
||||
Reference in New Issue
Block a user