mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (making Task.WithResult less confusing to read and more universal - IDEA-CR-67803)
GitOrigin-RevId: 253aa5e4720c34e6409c5b0d1c29f1d91432a572
This commit is contained in:
committed by
intellij-monorepo-bot
parent
30d076622d
commit
63ab83fd5f
@@ -295,7 +295,8 @@ public abstract class Task implements TaskInfo, Progressive {
|
||||
}
|
||||
|
||||
public abstract static class WithResult<T, E extends Exception> extends Task.Modal {
|
||||
private volatile Object myResult;
|
||||
private volatile T myResult;
|
||||
private volatile Throwable myError;
|
||||
|
||||
public WithResult(@Nullable Project project, @NlsContexts.DialogTitle @NotNull String title, boolean canBeCancelled) {
|
||||
super(project, title, canBeCancelled);
|
||||
@@ -307,7 +308,7 @@ public abstract class Task implements TaskInfo, Progressive {
|
||||
myResult = compute(indicator);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
myResult = t;
|
||||
myError = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,13 +316,13 @@ public abstract class Task implements TaskInfo, Progressive {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getResult() throws E {
|
||||
Object result = myResult;
|
||||
if (result instanceof Throwable) {
|
||||
ExceptionUtil.rethrowUnchecked((Throwable)result);
|
||||
throw (E)result;
|
||||
Throwable t = myError;
|
||||
if (t != null) {
|
||||
ExceptionUtil.rethrowUnchecked(t);
|
||||
throw (E)t;
|
||||
}
|
||||
else {
|
||||
return (T)result;
|
||||
return myResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user