[ https://issues.apache.org/jira/browse/NET-641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114426#comment-16114426 ]
pin_ptr commented on NET-641: ----------------------------- import org.apache.commons.net.util.SubnetUtils; public class B { public static void main(String[] args) { SubnetUtils c = new SubnetUtils("192.168.1.0/24"); System.out.println(c.getInfo().isInRange("192.168.1.0")); System.out.println(c.getInfo().isInRange("192.168.1.255")); c.setInclusiveHostCount(true); System.out.println(c.getInfo().isInRange("192.168.1.0")); System.out.println(c.getInfo().isInRange("192.168.1.255")); } } Javadoc says this code output 4x false, but commons-net 3.6's actual output is false, false, true and true. I looked through SVN log and found isInclusiveHostCount was added in r920235 (Mar 2008), and then low(), high() and isInRange() changed their behavior. (because isInRange() uses low() and high()) In other words, isInRange never ignored isInclusiveHostCount for 9 years. I am worried that commons-net changes it's behavior only if isInclusiveHostCount is true and network address is 0.0.0.0. > SubnetUtils.SubnetInfo.isInRange("0.0.0.0") returns true for CIDR/31, 32 > ------------------------------------------------------------------------ > > Key: NET-641 > URL: https://issues.apache.org/jira/browse/NET-641 > Project: Commons Net > Issue Type: Bug > Affects Versions: 3.6 > Environment: Windows; JDK8; common-net 3.6 > Reporter: pin_ptr > Priority: Minor > Fix For: 3.7 > > > Code: > import org.apache.commons.net.util.SubnetUtils; > public class A { > public static void main(String[] args) { > System.out.println(new > SubnetUtils("192.168.1.0/30").getInfo().isInRange("0.0.0.0")); > System.out.println(new > SubnetUtils("192.168.1.0/31").getInfo().isInRange("0.0.0.0")); > System.out.println(new > SubnetUtils("192.168.1.0/32").getInfo().isInRange("0.0.0.0")); > } > } > Result: > false > true > true > Expected: > false > false > false -- This message was sent by Atlassian JIRA (v6.4.14#64029)