Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM cost reform

...

Code Block
bgColor#ccccff
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

Remediation Cost

Repairable

Priority

Level

TPS02-J

Low

Probable

Medium

No

No

P4

P2

L3

Bibliography

[API 2014]

Interface ExecutorService

[Goetz 2006a]

Chapter 7, "Cancellation and Shutdown"

...


...