Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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-EX1EX0: Short-running tasks that execute without blocking are exempt from this rule.

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

TPS02-J

low

probable

medium

P4

L3

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Bibliography

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="eb9969f0d3989e04-03252213-4e484a5b-84729cd8-806b31680752386af95d9193"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

interface ExecutorService

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a3ba705d75a85448-8a28ac94-41004cfb-8bca8d04-26ce3217bd5530204f2579d9"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

Chapter 7: Cancellation and shutdown

]]></ac:plain-text-body></ac:structured-macro>

...