[Bug# 228886] NullPointerException at org.netbeans.modules.glassfish.common.GlassfishInstance.getServerDisplayName

Tomas Kraus <[email protected]> Wed, 22 May 2013 15:17:37 +0200
Newsgroups gmane.comp.java.netbeans.reviewers
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------080806010505020809040502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

*Bug 229886* <https://netbeans.org/bugzilla/show_bug.cgi?id=229886> 
-NullPointerException at 
org.netbeans.modules.glassfish.common.GlassfishInstance.getServerDisplayName

I have no idea what users did to poor NetBeans to trigger this NPE.

     public String getServerDisplayName() {
         return NbBundle.getMessage(GlassfishInstanceProvider.class,
                 "STR_SERVER_NAME", new Object[] {version.toString()});
     }

The only possible source of NPE is version.toString(). So I replaced it 
with version != null ? version.toString() : "" which shall not throw 
NPE. It's being used in description message where missing version for 
some broken/unknown GF is not a serious problem.

version is being initialized in GlassfishInstance.create (the only way 
to get object instance) and it can be null when plugin was unable to 
detect GF version.

There is no reproduction scenario in the bug. Current wizard will not 
allow to register GlassFish with failed version check so it must be 
coming from some existing record.

changeset:   253251:7f592ce9336a
summary:Bug 229886  <https://netbeans.org/bugzilla/show_bug.cgi?id=229886>  - NPE at GlassfishInstance.getServerDisplayName

Asked Peter Benedikovic to review it and he's ok with this fix,




--------------080806010505020809040502
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <a href="https://netbeans.org/bugzilla/show_bug.cgi?id=229886"><b>Bug&nbsp;229886</b></a>
    -<span id="summary_alias_container"> <span
        id="short_desc_nonedit_display">NullPointerException at
org.netbeans.modules.glassfish.common.GlassfishInstance.getServerDisplayName<br>
        <br>
        I have no idea what users did to poor NetBeans to trigger this
        NPE.<br>
        <br>
        &nbsp;&nbsp;&nbsp; public String getServerDisplayName() {<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
        NbBundle.getMessage(GlassfishInstanceProvider.class,<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "STR_SERVER_NAME", new Object[]
        {version.toString()});<br>
        &nbsp;&nbsp;&nbsp; }<br>
        <br>
        The only possible source of NPE is </span></span><span
      id="summary_alias_container"><span id="short_desc_nonedit_display">version.toString().
        So I replaced it with version != null ? version.toString() : ""
        which shall not throw NPE. It's being used in description
        message where missing version for some broken/unknown GF is not
        a serious problem.<br>
      </span></span><span id="summary_alias_container"><span
        id="short_desc_nonedit_display"><br>
        version</span></span> is being initialized in <span
      id="summary_alias_container"><span id="short_desc_nonedit_display">GlassfishInstance.create
        (the only way to </span></span>get object instance) and it can
    be null when plugin was unable to detect GF version.<br>
    <br>
    There is no reproduction scenario in the bug. Current wizard will
    not allow to register GlassFish with failed version check so it must
    be coming from some existing record.<br>
    <pre class="bz_comment_text">changeset:   253251:7f592ce9336a
summary:     <a href="https://netbeans.org/bugzilla/show_bug.cgi?id=229886" title="NEW - NullPointerException at org.netbeans.modules.glassfish.common.GlassfishInstance.getServerDisplayName">Bug 229886</a> - NPE at GlassfishInstance.getServerDisplayName
</pre>
    Asked Peter Benedikovic to review it and he's ok with this fix,<br>
    <br>
    <br>
    <span id="summary_alias_container"><span
        id="short_desc_nonedit_display"><br>
      </span></span>
  </body>
</html>

--------------080806010505020809040502--