...
Code Block | ||
---|---|---|
| ||
class CustomThreadPoolExecutor extends ThreadPoolExecutor { public CustomThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); } @Override public void beforeExecute(Thread t, Runnable r) { if (t == null || r == null) { throw new NullPointerException(); } Diary.setDay(Day.MONDAY); super.beforeExecute(t, r); } } public final class DiaryPool { // ... DiaryPool() { exec = new CustomThreadPoolExecutor(NoOfThreads, NoOfThreads, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); diary = new Diary(); } // ... } |
Exceptions
TPS04-EX1EX0: It is unnecessary to reinitialize a ThreadLocal
object that does not change state after initialization. For example, there may be only one type of database connection represented by the initial value of the ThreadLocal
object.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
TPS04-J | medium | probable | high | 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="3c69efe3b4920ac6-2d2124d6-477446b7-b909972c-f0802ee4205ffe170ae1a9d8"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | class | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8a8a3f60ea2376fd-a1685eb2-430b4e99-9302a8bd-febca4f101b1bb712235c11e"><ac:plain-text-body><![CDATA[ | [[JPL 2006 | AA. Bibliography#JPL 06]] | 14.13. ThreadLocal Variables | ]]></ac:plain-text-body></ac:structured-macro> |
...