Details
-
- Environment:
- All
Activity
| Field | Original Value | New Value |
|---|---|---|
| Priority | Blocker [ 1 ] | |
| Description |
In the current code, the value of 'result' can be overwritten by subsequent non-local addresses. Some 'true' result can be lost.
I suggest the following patch: Index: src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java =================================================================== --- src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java (revision 16340) +++ src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java (working copy) @@ -129,22 +129,23 @@ * @return */ public static boolean isLocalAddress(InetAddress address) { - boolean result = false; if (address != null) { try { Enumeration<NetworkInterface> itfs = NetworkInterface.getNetworkInterfaces(); while (itfs.hasMoreElements()) { NetworkInterface itf = itfs.nextElement(); Enumeration<InetAddress> iaenum = itf.getInetAddresses(); - while (iaenum.hasMoreElements() && !result) { + while (iaenum.hasMoreElements()) { InetAddress ia = iaenum.nextElement(); - result = ia.equals(address); + if (ia.equals(address)) { + return true; + } } } } catch (SocketException e) { } } - return result; + return false; } /** By the way, the management of SocketException is still problematic, because it can occur before every network interface has been scanned and make isLocalAddress() return false while it should have returned true. |
In the current code, the value of 'result' can be overwritten by subsequent non-local addresses. Some 'true' result can be lost.
I suggest the following patch: {code} Index: src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java =================================================================== --- src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java (revision 16340) +++ src/main/java/org/ow2/petals/binding/soap/util/NetworkUtil.java (working copy) @@ -129,22 +129,23 @@ * @return */ public static boolean isLocalAddress(InetAddress address) { - boolean result = false; if (address != null) { try { Enumeration<NetworkInterface> itfs = NetworkInterface.getNetworkInterfaces(); while (itfs.hasMoreElements()) { NetworkInterface itf = itfs.nextElement(); Enumeration<InetAddress> iaenum = itf.getInetAddresses(); - while (iaenum.hasMoreElements() && !result) { + while (iaenum.hasMoreElements()) { InetAddress ia = iaenum.nextElement(); - result = ia.equals(address); + if (ia.equals(address)) { + return true; + } } } } catch (SocketException e) { } } - return result; + return false; } /** {code} By the way, the management of SocketException is still problematic, because it can occur before every network interface has been scanned and make isLocalAddress() return false while it should have returned true. |
| Link | This issue blocks SPVEOLIAE-92 [ SPVEOLIAE-92 ] |
| Fix Version/s | 4.1_4.0 [ 10269 ] | |
| Fix Version/s | 4.1 [ 10186 ] | |
| Affects Version/s | 4.1 [ 10186 ] |
| Fix Version/s | 4.1 [ 10186 ] | |
| Fix Version/s | 4.1_4.0 [ 10269 ] |
| Transition | Status Change Time | Execution Times | Last Executer | Last Execution Date | |||||||||
|
|
|
|
|
|||||||||
|
|
|
|
|
|||||||||
|
|
|
|
|

Sorry for the + and - from the diff output that have been transformed into bullets