commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1580123 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/util/SubnetUtils.java test/java/org/apache/commons/net/SubnetUtilsTest.java
Date Sat, 22 Mar 2014 02:09:14 GMT
Author: sebb
Date: Sat Mar 22 02:09:14 2014
New Revision: 1580123

URL: http://svn.apache.org/r1580123
Log:
NET-529 SubnetUtils throws exception on valid input

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/SubnetUtilsTest.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1580123&r1=1580122&r2=1580123&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Sat Mar 22 02:09:14 2014
@@ -65,6 +65,9 @@ The <action> type attribute can be add,u
         <release version="3.4" date="2014-01-??" description="
 This is mainly a bug-fix release. See further details below.
         ">
+            <action issue="NET-529" type="fix" dev="sebb" due-to="Putinas Piliponis">
+            SubnetUtils throws exception on valid input
+            </action>
             <action issue="NET-527" type="add" dev="sebb" due-to="jason mathews">
             Add SimpleNTPServer as example and for testing
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java?rev=1580123&r1=1580122&r2=1580123&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java Sat
Mar 22 02:09:14 2014
@@ -255,9 +255,6 @@ public class SubnetUtils {
 
             /* Create a binary netmask from the number of bits specification /x */
             int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
-            if (cidrPart == 0 && address != 0) {
-                throw new IllegalArgumentException("Cannot have /0 cidr with non-zero address");
-            }
             for (int j = 0; j < cidrPart; ++j) {
                 netmask |= (1 << 31 - j);
             }

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/SubnetUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/SubnetUtilsTest.java?rev=1580123&r1=1580122&r2=1580123&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/SubnetUtilsTest.java (original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/SubnetUtilsTest.java Sat
Mar 22 02:09:14 2014
@@ -201,16 +201,6 @@ public class SubnetUtilsTest extends Tes
             fail("Should have thrown IllegalArgumentException");
         } catch (IllegalArgumentException expected) {
         }
-        try {
-            new SubnetUtils("192.168.0.1/0");
-            fail("Should have thrown IllegalArgumentException");
-        } catch (IllegalArgumentException expected) {
-        }
-        try {
-            new SubnetUtils("192.168.0.1", "0.0.0.0");
-            fail("Should have thrown IllegalArgumentException");
-        } catch (IllegalArgumentException expected) {
-        }
     }
 
     public void testNET428_31() throws Exception {
@@ -305,14 +295,6 @@ public class SubnetUtilsTest extends Tes
         new SubnetUtils("0.0.0.0/0");
     }
 
-    public void testZeroNetmaskBits() {
-        try {
-            new SubnetUtils("192.168.0.1/0");
-            fail("Mask /0 should have generated an IllegalArgumentException");
-        } catch (IllegalArgumentException expected) {
-        }
-    }
-
     public void testNET521() {
         SubnetUtils utils;
         SubnetInfo info;



Mime
View raw message