Add trySet method to DeferredResult
The method absorbs any potential StaleAsyncWebRequestException and returns false instead. Issue: SPR-8517
This commit is contained in:
@@ -103,6 +103,22 @@ public final class DeferredResult {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of {@link #set(Object)} that absorbs a potential, resulting
|
||||
* {@link StaleAsyncWebRequestException}.
|
||||
* @return {@code false} if the outcome was a {@code StaleAsyncWebRequestException}
|
||||
*/
|
||||
public boolean trySet(Object result) throws StaleAsyncWebRequestException {
|
||||
try {
|
||||
set(result);
|
||||
return true;
|
||||
}
|
||||
catch (StaleAsyncWebRequestException ex) {
|
||||
// absorb
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked to complete async processing when a timeout occurs before
|
||||
* {@link #set(Object)} is called. Or if {@link #set(Object)} is already in
|
||||
|
||||
Reference in New Issue
Block a user