
...
Code Block | ||
---|---|---|
| ||
public final class SocketReader implements Runnable { private final SocketChannel sc; private final Object lock = new Object(); public SocketReader(String host, int port) throws IOException { sc = SocketChannel.open(new InetSocketAddress(host, port)); } @Override public void run() { ByteBuffer buf = ByteBuffer.allocate(1024); try { synchronized (lock) { while (!Thread.interrupted()) { sc.read(buf); // ... } } } catch (IOException ie) { // Forward to handler } } } public final class PoolService { // ... } |
Exceptions
TPS02-J-EX0: Short-running tasks that execute without blocking are exempt from this rule.
...
Submitting tasks that are uninterruptible may prevent a thread pool from shutting down and consequently may cause DoS.
Rule | Severity | Likelihood | Detectable |
---|
Repairable | Priority | Level |
---|---|---|
TPS02-J | Low | Probable |
No | No |
P2 | L3 |
Bibliography
[API 2014] | |
Chapter 7, "Cancellation and Shutdown" |
...
...