<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Poor Error Handling: Swallowed ThreadDeath

    ABSTRACT

    如果重新拋出了 ThreadDeath 錯誤,則出現問題的線程可能實際上并未終止。

    EXPLANATION

    如果異步終止了應用程序后需要將其清除,則應僅捕獲 ThreadDeath 錯誤。如果捕獲了 ThreadDeath 錯誤,則將其重新拋出非常重要,因為這樣該線程才真正地終止。拋出 ThreadDeath 的目的是終止線程。如果 ThreadDeath 被抑制,則它可以阻止線程停止并導致意外行為,因為代碼最初拋出 ThreadDeath 的目的是希望停止該線程。

    例 1:下列代碼捕獲了 ThreadDeath 但未將其重新拋出。


    try
    {
    //some code
    }
    catch(ThreadDeath td)
    {
    //clean up code
    }

    REFERENCES

    [1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 691

    [2] Sun Microsystems, Inc. Java Sun Tutorial

    [3] Scott Oaks, Henry Wong Java Threads O'Reilly


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.structural.java.poor_error_handling_swallowed_threaddeath

    97av