Skip to content

private Future<Void> future; is never used #51

Open
@HelgeStenstrom

Description

@HelgeStenstrom

This object is never written, but it's read at a few places.
I think the intention might have been to assign it to the result of

For usages of this future, see

/**
* Await for the termination of StreamPlayerExecutorService Thread
*/
private void awaitTermination() {
if (future != null && !future.isDone()) {
try {
// future.get() [Don't use this cause it may hang forever and ever...]
// Wait ~1 second and then cancel the future
final Thread delay = new Thread(() -> {
try {
for (int i = 0; i < 50; i++) {
if (!future.isDone())
Thread.sleep(20);
else
break;
logger.log(Level.INFO, "StreamPlayer Future is not yet done...");
}
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
logger.log(Level.INFO, ex.getMessage(), ex);
}
});
// Start the delay Thread
delay.start();
// Join until delay Thread is finished
delay.join();
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
logger.log(Level.WARNING, ex.getMessage(), ex);
} finally {
// Harmless if task already completed
future.cancel(true); // interrupt if running
}
}
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions