DATAMONGO-2173 - Polishing.

Set interrupted thread state after catching InterruptedException. Fix potential NPE by checking the cursor. Streamline generics to not hide class-level generic types.

Original pull request: #634.
This commit is contained in:
Mark Paluch
2019-01-09 12:03:56 +01:00
parent 3a7492c68d
commit 267decf189

View File

@@ -91,7 +91,7 @@ abstract class CursorReadingTask<T, R> implements Task {
synchronized (lifecycleMonitor) {
state = State.CANCELLED;
}
Thread.interrupted();
Thread.currentThread().interrupt();
}
}
}
@@ -126,7 +126,7 @@ abstract class CursorReadingTask<T, R> implements Task {
if (valid) {
this.cursor = cursor;
state = State.RUNNING;
} else {
} else if(cursor != null){
cursor.close();
}
}
@@ -141,7 +141,7 @@ abstract class CursorReadingTask<T, R> implements Task {
synchronized (lifecycleMonitor) {
state = State.CANCELLED;
}
Thread.interrupted();
Thread.currentThread().interrupt();
}
}
} while (State.STARTING.equals(getState()));
@@ -258,7 +258,7 @@ abstract class CursorReadingTask<T, R> implements Task {
* @throws RuntimeException The potentially translated exception.
*/
@Nullable
private <T> T execute(Supplier<T> callback) {
private <V> V execute(Supplier<V> callback) {
try {
return callback.get();