harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r412049 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
Date Tue, 06 Jun 2006 08:51:44 GMT
Author: gharley
Date: Tue Jun  6 01:51:43 2006
New Revision: 412049

URL: http://svn.apache.org/viewvc?rev=412049&view=rev
Log:
Fixing NPE problem introduced in HARMONY-500 when machine has more than one network interface.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java?rev=412049&r1=412048&r2=412049&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
Tue Jun  6 01:51:43 2006
@@ -298,15 +298,19 @@
         }
 
         for (NetworkInterface netif : interfaces) {
-            for (InetAddress addr : netif.addresses) {
-                if (16 == addr.ipaddress.length) {
-                    if (addr.isLinkLocalAddress() || addr.isSiteLocalAddress()) {
-                        ((Inet6Address) addr).scopedIf = netif;
-                        ((Inet6Address) addr).ifname = netif.name;
-                        ((Inet6Address) addr).scope_ifname_set = true;
+            // Ensure that current NetworkInterface is bound to at least 
+            // one InetAddress before processing
+            if (netif.addresses != null) {
+                for (InetAddress addr : netif.addresses) {
+                    if (16 == addr.ipaddress.length) {
+                        if (addr.isLinkLocalAddress() || addr.isSiteLocalAddress()) {
+                            ((Inet6Address) addr).scopedIf = netif;
+                            ((Inet6Address) addr).ifname = netif.name;
+                            ((Inet6Address) addr).scope_ifname_set = true;
+                        }
                     }
                 }
-            }
+            }// end if 
         }
 
         return (new Vector<NetworkInterface>(Arrays.asList(interfaces)))



Mime
View raw message