diff --git a/src/main/java/com/maxmind/db/Reader.java b/src/main/java/com/maxmind/db/Reader.java index c346054d..7525b46e 100644 --- a/src/main/java/com/maxmind/db/Reader.java +++ b/src/main/java/com/maxmind/db/Reader.java @@ -237,9 +237,9 @@ public Networks networks(boolean skipAliasedNetworks) throws Network ipAllV6 = new Network(ipv6, 0); // Mask 128. if (this.getMetadata().getIpVersion() == 6) { - return this.networksWithIn(ipAllV6, skipAliasedNetworks); + return this.networksWithin(ipAllV6, skipAliasedNetworks); } - return this.networksWithIn(ipAllV4, skipAliasedNetworks); + return this.networksWithin(ipAllV4, skipAliasedNetworks); } catch (UnknownHostException e) { /* This is returned by getByAddress. This should never happen as the ipv4 and ipv6 are constants set by us. */ @@ -293,7 +293,7 @@ private int findIpV4StartNode(ByteBuffer buffer) * @throws ClosedDatabaseException Exception for a closed databased. * @throws InvalidDatabaseException Exception for an invalid database. */ - public Networks networksWithIn(Network network, boolean skipAliasedNetworks) + public Networks networksWithin(Network network, boolean skipAliasedNetworks) throws InvalidNetworkException, ClosedDatabaseException, InvalidDatabaseException { InetAddress networkAddress = network.getNetworkAddress(); if (this.metadata.getIpVersion() == 4 && networkAddress instanceof Inet6Address) { @@ -304,10 +304,10 @@ public Networks networksWithIn(Network network, boolean skipAliasedNetwor int prefixLength = network.getPrefixLength(); if (this.metadata.getIpVersion() == 6 && ipBytes.length == IPV4_LEN) { - if (skipAliasedNetworks) { - ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ipBytes[0], ipBytes[1], ipBytes[2], ipBytes[3] }; - } else { +if (skipAliasedNetworks) { + ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ipBytes[0], ipBytes[1], ipBytes[2], ipBytes[3] }; +} else { // Convert it to the IP address (in 16-byte from) of the IPv4 address. ipBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, // -1 is for 0xff. @@ -333,7 +333,7 @@ public Networks networksWithIn(Network network, boolean skipAliasedNetwor * @param bitCount The prefix. * @return int[] */ - public int[] traverseTree(byte[] ip, int node, int bitCount) + private int[] traverseTree(byte[] ip, int node, int bitCount) throws ClosedDatabaseException, InvalidDatabaseException { int nodeCount = this.metadata.getNodeCount(); int i = 0; diff --git a/src/test/java/com/maxmind/db/ReaderTest.java b/src/test/java/com/maxmind/db/ReaderTest.java index 313a3e3d..34cc93cb 100644 --- a/src/test/java/com/maxmind/db/ReaderTest.java +++ b/src/test/java/com/maxmind/db/ReaderTest.java @@ -338,7 +338,7 @@ public void testNetworksWithin() throws IOException, InvalidNetworkException{ InetAddress address = InetAddress.getByName(test.network); Network network = new Network(address, test.prefix); - Networks networks = reader.networksWithIn(network, test.skipAliasedNetworks); + Networks networks = reader.networksWithin(network, test.skipAliasedNetworks); networks.setDataClass(Map.class); ArrayList innerIPs = new ArrayList(); @@ -376,7 +376,7 @@ public void testGeoIPNetworksWithin() throws IOException, InvalidNetworkExceptio InetAddress address = InetAddress.getByName(test.network); Network network = new Network(address, test.prefix); - Networks networks = reader.networksWithIn(network, test.skipAliasedNetworks); + Networks networks = reader.networksWithin(network, test.skipAliasedNetworks); networks.setDataClass(Map.class); ArrayList innerIPs = new ArrayList();