Code Review 6706251: api/java_net/NetworkInterface/index.html#misc: getDisplayName() returned non null but empty String

Christopher Hegarty - Sun Microsystems Ireland Christopher.Hegarty at Sun.COM
Fri Mar 19 09:06:20 PDT 2010


How about (thanks to Alan for the wording):

       * A display name is a human readable String describing the network
       * device.
       *
-     * @return the display name of this network interface,
-     *         or null if no display name is available.
+     * @return a non-empty string representing the display name of this 
network
+     *         interface, or null if no display name is available.
       */
      public String getDisplayName() {
-        return displayName;
+        /* strict TCK conformance */
+        return "".equals(displayName) ? null : displayName;
      }
       * A display name is a human readable String describing the network
       * device.
       *
-     * @return the display name of this network interface,
-     *         or null if no display name is available.
+     * @return a non-empty string representing the display name of this 
network
+     *         interface, or null if no display name is available.
       */
      public String getDisplayName() {
-        return displayName;
+        /* strict TCK conformance */
+        return "".equals(displayName) ? null : displayName;
      }

Updated Webrev:
   http://cr.openjdk.java.net/~chegar/6706251/webrev.00/webrev/

-Chris.

On 19/03/2010 15:33, Andrew John Hughes wrote:
> On 19 March 2010 15:12, Alan Bateman<Alan.Bateman at sun.com>  wrote:
>> Christopher Hegarty - Sun Microsystems Ireland wrote:
>>>
>>> :
>>> I vaguely remember the history of this issue (Michael will know better),
>>>   but the expectation from the API is that while empty string is not
>>> disallowed if the display name cannot be retrieved then null should be
>>> returned.
>>>
>>> I think such a clarification is unnecessary in the API, it is such a
>>> corner case, and may be confusing.
>>
>> If the empty string is not allowed then changing the @return to make this
>> clear would be good.
>>
>> -Alan.
>>
>
> The @return currently says 'the display name of this network
> interface, or null if no display name is available.'
>
> 'null if the display name is either null or the empty string' may be
> clearer.  It's these kind of corner cases that are a major pain for
> users of the API.



More information about the net-dev mailing list