PMD消息"避免使用java.lang.ThreadGroup;它不是线程安全的"

Lor*_*ano 8 java pmd

题:

为什么maven PMD插件给出了以下代码行的以下警告:警告:

避免使用java.lang.ThreadGroup; 它不是线程安全的

代码(第二行):

Calendar cal = Calendar.getInstance();
java.sql.Date endDate = new java.sql.Date(cal.getTime().getTime());
Run Code Online (Sandbox Code Playgroud)

语境:

我有这个confit java.sql.Date实例:

public class XYZServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    this.doPost(req, resp);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse resp)
        throws ServletException, IOException {


    Connection conn = null;
    CallableStatement stmt = null;
    try {
        conn = ...
        ...

        Calendar cal = Calendar.getInstance();
        java.sql.Date endDate = new java.sql.Date(cal.getTime().getTime());

        ...
    } catch ...
    }finally {
        try {
            stmt.close();
            conn.close();
        } catch(Exception e) {}
    }
}
Run Code Online (Sandbox Code Playgroud)

}

PMD报告的线路是

java.sql.Date endDate = new java.sql.Date(cal.getTime().getTime());
Run Code Online (Sandbox Code Playgroud)

信息是:

Avoid using java.lang.ThreadGroup; it is not thread safe
Run Code Online (Sandbox Code Playgroud)

oer*_*ers 7

这似乎是PMD 4.2.6中的一个错误.

SourceForge-Link:http:
//sourceforge.net/projects/pmd/forums/forum/188192/topic/4781145