From 94af2404a8b905f104f8d4853b13ee6b7f6960f4 Mon Sep 17 00:00:00 2001 From: Anton Parkhomenko Date: Thu, 21 Nov 2019 20:11:55 +0300 Subject: [PATCH 1/2] Default isInEuropeanUnion to false in case of NoSuchMethodError (close #123) --- .../model.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com.snowplowanalytics.maxmind.iplookups/model.scala b/src/main/scala/com.snowplowanalytics.maxmind.iplookups/model.scala index c22635f..0e0ee32 100644 --- a/src/main/scala/com.snowplowanalytics.maxmind.iplookups/model.scala +++ b/src/main/scala/com.snowplowanalytics.maxmind.iplookups/model.scala @@ -54,7 +54,14 @@ object model { * @param cityResponse MaxMind CityResponse object * @return IpLocation */ - def apply(cityResponse: CityResponse): IpLocation = + def apply(cityResponse: CityResponse): IpLocation = { + // Try to bypass bincompat problem with Spark Enrich, + // Delete once Spark Enrich is deprecated + val isInEuropeanUnion = try { + cityResponse.getCountry.isInEuropeanUnion + } catch { + case _: NoSuchMethodError => false + } IpLocation( countryCode = cityResponse.getCountry.getIsoCode, countryName = cityResponse.getCountry.getName, @@ -66,10 +73,11 @@ object model { postalCode = Option(cityResponse.getPostal.getCode), metroCode = Option(cityResponse.getLocation.getMetroCode).map(_.toInt), regionName = Option(cityResponse.getMostSpecificSubdivision.getName), - isInEuropeanUnion = cityResponse.getCountry.isInEuropeanUnion, + isInEuropeanUnion = isInEuropeanUnion, continent = cityResponse.getContinent.getName, accuracyRadius = cityResponse.getLocation.getAccuracyRadius ) + } } /** Result of MaxMind lookups */ From 5fa42d02311510cc31061ae46d62c6c78d9537ec Mon Sep 17 00:00:00 2001 From: Anton Parkhomenko Date: Sat, 23 Nov 2019 15:10:29 +0300 Subject: [PATCH 2/2] Prepare for release --- CHANGELOG | 4 ++++ README.md | 4 ++-- build.sbt | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 419bcd0..174b785 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 0.6.1 (2019-11-25) +-------------------------- +Default isInEuropeanUnion to false in case of NoSuchMethodError (#123) + Version 0.6.0 (2019-11-21) -------------------------- Add support for isInEuropeanUnion flag (#87) diff --git a/README.md b/README.md index 140df93..2fa1cd2 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,12 @@ can also configure an LRU (Least Recently Used) cache of variable size ## Installation -The latest version of scala-maxmind-iplookups is **0.6.0** and is compatible with Scala 2.12. +The latest version of scala-maxmind-iplookups is **0.6.1** and is compatible with Scala 2.12. Add this to your SBT config: ```scala -val maxmindIpLookups = "com.snowplowanalytics" %% "scala-maxmind-iplookups" % "0.6.0" +val maxmindIpLookups = "com.snowplowanalytics" %% "scala-maxmind-iplookups" % "0.6.1" ``` Retrieve the `GeoLite2-City.mmdb` file from the [MaxMind downloads page][maxmind-downloads] diff --git a/build.sbt b/build.sbt index b1ea156..e921761 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,7 @@ lazy val root = project .settings( organization := "com.snowplowanalytics", name := "scala-maxmind-iplookups", - version := "0.6.0", + version := "0.6.1", description := "Scala wrapper for MaxMind GeoIP2 library", scalaVersion := "2.12.8", javacOptions := BuildSettings.javaCompilerOptions,