Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #32 from maxmind/greg/api-clean-up
Browse files Browse the repository at this point in the history
Improve handling of invalid databases
  • Loading branch information
rafl committed Jan 21, 2016
2 parents 4144e33 + 600db7e commit ef5347e
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 371 deletions.
19 changes: 16 additions & 3 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Changes
=======

1.3.0 (2016-01-XX)
------------------

* `LookupService` will now throw an `InvalidDatabaseException` if there is a
problem with the database. This is a unchecked, runtime exception in order
to not introduce an API change. Previously `LookupService` would swallow
exceptions, either returning `null` or an invalid value or throwing an
exception such as `ArrayIndexOutOfBoundsException` cause by the invalid
state.
* When using `GEOIP_MEMORY_CACHE`, the number of allocations has been reduced,
providing a moderate performance increase.
* Minor code clean-up and de-duplication.

1.2.15 (2015-07-17)
-------------------

Expand Down Expand Up @@ -87,7 +100,7 @@ Changes
* Update FIPS codes 20100530 ( Boris Zentner )
* Update FIPS codes 20100510 ( Boris Zentner )
* Add IPv6 support via getCountryV6 ( Boris Zentner )
* Add exmaple for IPv6 lookups: CountryLookupTestV6 ( Boris Zentner )
* Add example for IPv6 lookups: CountryLookupTestV6 ( Boris Zentner )
* Fix DatabaseInfo string ( Boris Zentner )
* Add netmask and last_netmask methods ( Boris Zentner )
* Remove static keyword from objects that are reinitialized in the init()
Expand All @@ -109,7 +122,7 @@ Changes
* Fix rare out of range error, when the last entry of the Org/ISP/Domain
database is copied ( MEMORY_CACHE only ). ( Boris Zentner )
* Update timezones for Australia
* Remore "\n" from RegionLookupTest.java. println add already a newline
* Remove "\n" from RegionLookupTest.java. println add already a newline
( Boris Zentner )
* Change regionName.java and generate_regionName.pl to support FIPS codes
with letters ( Boris Zentner ).
Expand Down Expand Up @@ -195,7 +208,7 @@ Changes
1.1.1 (2002-10-31)
------------------

* Added support for GeoIP Full Edition, remaned CountryLookup class
* Added support for GeoIP Full Edition, renamed CountryLookup class
to Lookup

1.1.0 (2002-10-28)
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/maxmind/geoip/InvalidDatabaseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.maxmind.geoip;

import java.io.IOException;

/**
* Signals that there was an issue reading from the database file due to
* unexpected data formatting. This generally suggests that the database is
* corrupt or otherwise not in a format supported by the reader.
*/
public final class InvalidDatabaseException extends RuntimeException {

/**
* @param message A message describing the reason why the exception was thrown.
*/
public InvalidDatabaseException(String message) {
super(message);
}

/**
* @param message A message describing the reason why the exception was thrown.
* @param cause The cause of the exception.
*/
public InvalidDatabaseException(String message, Throwable cause) {
super(message, cause);
}
}
Loading

0 comments on commit ef5347e

Please sign in to comment.