Skip to content

Commit

Permalink
Merge pull request #371 from mattrjacobs/evaluate-pr-264
Browse files Browse the repository at this point in the history
Manual merge of #264
  • Loading branch information
mattrjacobs committed Dec 18, 2014
2 parents c602a01 + 71598ec commit 72300c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ public void setExceptionIfResponseNotReceived(Exception e) {
}
}

/**
* Set an ISE if a response is not yet received otherwise skip it
*
* @param e A pre-generated exception. If this is null an ISE will be created and returned
* @param exceptionMessage The message for the ISE
*/
public Exception setExceptionIfResponseNotReceived(Exception e, String exceptionMessage) {
Exception exception = e;
CollapsedRequestObservableFunction.ResponseHolder<T> r = rh.get();
// only proceed if neither response is set
if (!r.isResponseSet() && r.getException() == null) {
if(e == null) {
exception = new IllegalStateException(exceptionMessage);
}
setExceptionIfResponseNotReceived(exception);
}
// return any exception that was generated
return exception;
}

/**
* When set any client thread blocking on get() will immediately be unblocked and receive the exception.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ public void call(Throwable e) {
@Override
public void call() {
// check that all requests had setResponse or setException invoked in case 'mapResponseToRequests' was implemented poorly
IllegalStateException ie = new IllegalStateException("No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation.");
Exception e = null;
for (CollapsedRequest<ResponseType, RequestArgumentType> request : shardRequests) {
try {
((CollapsedRequestObservableFunction<ResponseType, RequestArgumentType>) request).setExceptionIfResponseNotReceived(ie);
e = ((CollapsedRequestObservableFunction<ResponseType, RequestArgumentType>) request).setExceptionIfResponseNotReceived(e,"No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation.");
} catch (IllegalStateException e2) {
logger.debug("Partial success of 'mapResponseToRequests' resulted in IllegalStateException while setting 'No response set' Exception. Continuing ... ", e2);
}
Expand Down

0 comments on commit 72300c5

Please sign in to comment.