Skip to content

Commit

Permalink
fixed thread interrupted bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan committed Mar 14, 2012
1 parent 400036d commit c9f861a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/com/deftlabs/cursor/mongo/TailableCursorImpl.java
Expand Up @@ -151,12 +151,23 @@ private DBCursor createCursor() {
return col.find(_options.getInitialQuery()).sort(new BasicDBObject("$natural", 1)).addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA);
}

/**
* Either log the exception or pass to the handler.
* @param pT The throwable received.
* @return True if the thread should exit. False otherwise :-)
*/
private boolean handleException(final Throwable pT) {

if (pT instanceof InterruptedException) return true;

if (_options.hasErrorListener()) {
try {
// Call the error listener.
_options.getErrorListener().onError(pT);
} catch (final Throwable t) { _logger.log(Level.SEVERE, pT.getMessage(), pT); }
} catch (final Throwable t) {
if (t instanceof InterruptedException) return true;
_logger.log(Level.SEVERE, pT.getMessage(), pT);
}
} else { _logger.log(Level.SEVERE, pT.getMessage(), pT); }

if (_options.getErrorSleepTime() <= 0) return false;
Expand Down

0 comments on commit c9f861a

Please sign in to comment.