You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2017/02/28 22:10:22 UTC

svn commit: r1784825 - /jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java

Author: sebb
Date: Tue Feb 28 22:10:21 2017
New Revision: 1784825

URL: http://svn.apache.org/viewvc?rev=1784825&view=rev
Log:
Add docn on why there is an unnecessary null check

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java?rev=1784825&r1=1784824&r2=1784825&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/NamePanel.java Tue Feb 28 22:10:21 2017
@@ -74,7 +74,16 @@ public class NamePanel extends JPanel im
      */
     @Override
     public String getName() {
-        if (nameField != null) { // NOSONAR this field seems to be null in the constructor
+        /*
+         * Null check is needed because some implementations of JPanel end up calling
+         * getName(). This is a bug, which has been reported as:
+         * http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8175888
+         * 
+         * See also
+         * https://www.securecoding.cert.org/confluence/display/java/MET05-J.+Ensure+that+constructors+do+not+call+overridable+methods
+         * https://dev.eclipse.org/sonar/coding_rules#rule_key=squid%3AS1699
+         */
+        if (nameField != null) { // NOSONAR suppress warning as the null check is needed as per above 
             return nameField.getText();
         }
         return ""; // $NON-NLS-1$