You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Kanatoko <an...@jumperz.net> on 2011/11/01 03:17:58 UTC
NET SubnetUtil exception on /31 and /32
Hello list,
new SubnetUtils( "1.2.3.4/32" ).getInfo().getAllAddresses()
throws Exception blow.
--
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
$SubnetInfo.getAllAddresses(SubnetUtils.java:166)
--
Tested on commons-net-3.0.1.
/31 as well.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: NET SubnetUtil exception on /31 and /32
Posted by sebb <se...@gmail.com>.
On 1 November 2011 08:11, Maurizio Cucchiara <mc...@apache.org> wrote:
> You should include the network and broadcast addresses
> Try this
>
> public void testMail() throws Exception {
> final SubnetUtils subnetUtils = new SubnetUtils("1.2.3.4/32");
> subnetUtils.setInclusiveHostCount(true);
That fixes the error by increasing the available address count, but I
agree with the OP that the current behaviour is unexpected - it would
make more sense to return an empty array rather than throwing
ArrayIndexOutOfBoundsException.
So I created:
https://issues.apache.org/jira/browse/NET-428
> String[] address = subnetUtils.getInfo().getAllAddresses();
> assertNotNull(address);
> assertEquals(1,address.length);
> }
>
>
> Twitter :http://www.twitter.com/m_cucchiara
> G+ :https://plus.google.com/107903711540963855921
> Linkedin :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
>
> 2011/11/1 Kanatoko <an...@jumperz.net>:
>> new SubnetUtils( "1.2.3.4/32" ).getInfo().getAllAddresses()
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: NET SubnetUtil exception on /31 and /32
Posted by Maurizio Cucchiara <mc...@apache.org>.
You should include the network and broadcast addresses
Try this
public void testMail() throws Exception {
final SubnetUtils subnetUtils = new SubnetUtils("1.2.3.4/32");
subnetUtils.setInclusiveHostCount(true);
String[] address = subnetUtils.getInfo().getAllAddresses();
assertNotNull(address);
assertEquals(1,address.length);
}
Twitter :http://www.twitter.com/m_cucchiara
G+ :https://plus.google.com/107903711540963855921
Linkedin :http://www.linkedin.com/in/mauriziocucchiara
Maurizio Cucchiara
2011/11/1 Kanatoko <an...@jumperz.net>:
> new SubnetUtils( "1.2.3.4/32" ).getInfo().getAllAddresses()
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org