Skip to content

Commit 0991705

Browse files
committed
Rename BadVersionException to InvalidNetworkException
1 parent fb269dd commit 0991705

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/java/com/maxmind/db/BadVersionException.java renamed to src/main/java/com/maxmind/db/InvalidNetworkException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.net.InetAddress;
44

5-
public class BadVersionException extends Exception {
6-
public BadVersionException(InetAddress ip) {
5+
public class InvalidNetworkException extends Exception {
6+
public InvalidNetworkException(InetAddress ip) {
77
super("you attempted to use an IPv6 network in an IPv4-only database: " + ip.toString());
88
}
99
}

src/main/java/com/maxmind/db/Reader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ record = this.readNode(buffer, record, bit);
206206
* SkipAliasedNetworks option.
207207
*
208208
* @return Networks The Networks iterator.
209-
* @throws BadVersionException Exception for using an IPv6 network in ipv4-only database.
209+
* @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
210210
* @throws ClosedDatabaseException Exception for a closed databased.
211211
* @throws InvalidDatabaseException Exception for an invalid database.
212212
*/
213213
public Networks networks() throws
214-
BadVersionException, ClosedDatabaseException, InvalidDatabaseException {
214+
InvalidNetworkException, ClosedDatabaseException, InvalidDatabaseException {
215215
return this.networks(true);
216216
}
217217

@@ -224,12 +224,12 @@ public Networks networks() throws
224224
*
225225
* @param skipAliasedNetworks Enable skipping aliased networks.
226226
* @return Networks The Networks iterator.
227-
* @throws BadVersionException Exception for using an IPv6 network in ipv4-only database.
227+
* @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
228228
* @throws ClosedDatabaseException Exception for a closed databased.
229229
* @throws InvalidDatabaseException Exception for an invalid database.
230230
*/
231231
public Networks networks(boolean skipAliasedNetworks) throws
232-
BadVersionException, ClosedDatabaseException, InvalidDatabaseException {
232+
InvalidNetworkException, ClosedDatabaseException, InvalidDatabaseException {
233233
try {
234234
InetAddress ipv4 = InetAddress.getByAddress(new byte[4]);
235235
InetAddress ipv6 = InetAddress.getByAddress(new byte[16]);
@@ -289,15 +289,15 @@ private int findIpV4StartNode(ByteBuffer buffer)
289289
* @param network Specifies the network to be iterated.
290290
* @param skipAliasedNetworks Boolean for skipping aliased networks.
291291
* @return Networks
292-
* @throws BadVersionException Exception for using an IPv6 network in ipv4-only database.
292+
* @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
293293
* @throws ClosedDatabaseException Exception for a closed databased.
294294
* @throws InvalidDatabaseException Exception for an invalid database.
295295
*/
296296
public <T> Networks<T> networksWithIn(Network network, boolean skipAliasedNetworks)
297-
throws BadVersionException, ClosedDatabaseException, InvalidDatabaseException {
297+
throws InvalidNetworkException, ClosedDatabaseException, InvalidDatabaseException {
298298
InetAddress networkAddress = network.getNetworkAddress();
299299
if (this.metadata.getIpVersion() == 4 && networkAddress instanceof Inet6Address) {
300-
throw new BadVersionException(networkAddress);
300+
throw new InvalidNetworkException(networkAddress);
301301
}
302302

303303
byte[] ipBytes = networkAddress.getAddress();

src/test/java/com/maxmind/db/ReaderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static class GetRecordTest {
7979
}
8080

8181
@Test
82-
public void testNetworks() throws IOException, InvalidDatabaseException, BadVersionException {
82+
public void testNetworks() throws IOException, InvalidDatabaseException, InvalidNetworkException {
8383
for (long recordSize : new long[] {24, 28, 32}) {
8484
for (int ipVersion : new int[] {4, 6}) {
8585
File file = getFile("MaxMind-DB-test-ipv" + ipVersion + "-" + recordSize + ".mmdb");
@@ -107,7 +107,7 @@ public void testNetworks() throws IOException, InvalidDatabaseException, BadVers
107107
}
108108

109109
@Test
110-
public void testNetworksWithInvalidSearchTree() throws IOException, BadVersionException{
110+
public void testNetworksWithInvalidSearchTree() throws IOException, InvalidNetworkException{
111111
File file = getFile("MaxMind-DB-test-broken-search-tree-24.mmdb");
112112
Reader reader = new Reader(file);
113113

@@ -328,7 +328,7 @@ public networkTest(String network, int prefix,String database, String[] expecte
328328
};
329329

330330
@Test
331-
public void testNetworksWithin() throws IOException, BadVersionException{
331+
public void testNetworksWithin() throws IOException, InvalidNetworkException{
332332
for(networkTest test : tests){
333333
for(int recordSize : new int[]{24, 28, 32}){
334334
File file = getFile("MaxMind-DB-test-"+test.database+"-"+recordSize+".mmdb");
@@ -368,7 +368,7 @@ public void testNetworksWithin() throws IOException, BadVersionException{
368368
};
369369

370370
@Test
371-
public void testGeoIPNetworksWithin() throws IOException, BadVersionException{
371+
public void testGeoIPNetworksWithin() throws IOException, InvalidNetworkException{
372372
for (networkTest test : geoipTests){
373373
File file = getFile(test.database);
374374
Reader reader = new Reader(file);

0 commit comments

Comments
 (0)