Skip to content

Commit a165a2d

Browse files
authored
Merge pull request #205 from maxmind/greg/httpclient
Switch to HttpClient and prepare for major version bump
2 parents e35bfcf + 4a085b1 commit a165a2d

39 files changed

Lines changed: 409 additions & 642 deletions

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
os: [ubuntu-latest, windows-latest, macos-latest]
10-
version: [ 8, 9, 10, 11, 12, 13, 14, 15 ]
10+
version: [ 11, 12, 13, 14, 15 ]
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
CHANGELOG
22
=========
33

4-
1.19.0
4+
2.0.0
55
-------------------
66

7+
* Java 11 or greater is now required.
8+
* Apache HttpClient has been replaced with `java.net.http.HttpClient`.
9+
* The `close()` method on `WebServiceClient` is now deprecated. It
10+
no longer does anything.
11+
* On `WebServiceClient.Builder`:
12+
* `connectTimeout(int)` has been deprecated in favor of
13+
`connectTimeout(Duration)`.
14+
* `readTimeout(int)` has been deprecated in favor of
15+
`requestTimeout(Duration)`.
16+
* `proxy(Proxy)` has been deprecated in favor of `proxy(ProxySelector)`.
17+
* On `HttpException` and `InvalidRequestException`, `getUrl()` has been
18+
deprecated in favor of `getUri()`. Constructors that took a `URL` have
19+
been replaced with the equivalent taking a `URI`.
20+
* Deprecated constructors on model classes were removed.
21+
* Removed deprecated response methods:
22+
* `Email.getAddressMd5()`
23+
* `Subscores.getEmailTenure()`
24+
* `Subscores.getIpTenure()`
25+
* Removed `GeoIp2Country` and its associated `isHighRisk()` method.
26+
`IpAddress.getCountry()` now returns a `com.maxmind.geoip2.record.Country`.
27+
* Removed deprecated `Payment.Processor.VERAPAY` enum value. Use `VEREPAY`
28+
instead.
29+
* `Email.getDomain()` will now return an empty object rather than null if
30+
there is no domain data. This is match other response model class getters.
731
* Upgraded the `geoip2` dependency to 2.16.1. This adds mobile country code
832
(MCC) and mobile network code (MNC) to minFraud Insights and Factors
933
responses. These are available at

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ If you are having an issue with the minFraud service that is not specific
271271
to the client API, please see
272272
[our support page](https://www.maxmind.com/en/support).
273273

274-
## Requirements ##
274+
## Requirements ##
275275

276-
This code requires Java 8+.
276+
This code requires Java 11+.
277277

278278
## Contributing ##
279279

pom.xml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>com.maxmind.minfraud</groupId>
@@ -64,29 +65,6 @@
6465
<artifactId>geoip2</artifactId>
6566
<version>2.16.1</version>
6667
</dependency>
67-
<dependency>
68-
<groupId>org.apache.httpcomponents</groupId>
69-
<artifactId>httpclient</artifactId>
70-
<version>4.5.13</version>
71-
</dependency>
72-
<dependency>
73-
<!-- httpclient pulls this in. We pull in a newer version
74-
because of a security issue in 1.11 -->
75-
<groupId>commons-codec</groupId>
76-
<artifactId>commons-codec</artifactId>
77-
<version>1.15</version>
78-
</dependency>
79-
<!--
80-
commons-validator 1.6 depends on an older version of
81-
commons-beanutils with a CVE. So add a direct dependency on the
82-
commons-beanutils version that is fixed, while we wait for
83-
commons-validator to be updated.
84-
-->
85-
<dependency>
86-
<groupId>commons-beanutils</groupId>
87-
<artifactId>commons-beanutils</artifactId>
88-
<version>1.9.4</version>
89-
</dependency>
9068
<dependency>
9169
<groupId>commons-validator</groupId>
9270
<artifactId>commons-validator</artifactId>
@@ -110,12 +88,6 @@
11088
<version>1.5.0</version>
11189
<scope>test</scope>
11290
</dependency>
113-
<dependency>
114-
<groupId>org.slf4j</groupId>
115-
<artifactId>slf4j-simple</artifactId>
116-
<version>1.7.32</version>
117-
<scope>test</scope>
118-
</dependency>
11991
<dependency>
12092
<groupId>com.fasterxml.jackson.jr</groupId>
12193
<artifactId>jackson-jr-objects</artifactId>
@@ -160,7 +132,7 @@
160132
<version>3.3.1</version>
161133
<configuration>
162134
<show>public</show>
163-
<source>8</source>
135+
<source>11</source>
164136
</configuration>
165137
</plugin>
166138
<plugin>
@@ -186,8 +158,9 @@
186158
<artifactId>maven-compiler-plugin</artifactId>
187159
<version>3.8.1</version>
188160
<configuration>
189-
<source>1.8</source>
190-
<target>1.8</target>
161+
<release>11</release>
162+
<source>1.11</source>
163+
<target>1.11</target>
191164
</configuration>
192165
</plugin>
193166
<plugin>
@@ -233,7 +206,7 @@
233206
<configuration>
234207
<format>xml</format>
235208
<maxmem>256m</maxmem>
236-
<check />
209+
<check/>
237210
</configuration>
238211
</plugin>
239212
<plugin>

src/main/java/com/maxmind/minfraud/AbstractModel.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
11
package com.maxmind.minfraud;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude;
4-
import com.fasterxml.jackson.databind.MapperFeature;
5-
import com.fasterxml.jackson.databind.ObjectMapper;
6-
import com.fasterxml.jackson.databind.SerializationFeature;
7-
import com.fasterxml.jackson.databind.util.StdDateFormat;
8-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
9-
103
import java.io.IOException;
114

125
public abstract class AbstractModel {
13-
146
/**
157
* @return JSON representation of this object.
168
* @throws IOException if there is an error serializing the object to JSON.
179
*/
1810
public final String toJson() throws IOException {
19-
ObjectMapper mapper = new ObjectMapper();
20-
mapper.registerModule(new JavaTimeModule());
21-
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
22-
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
23-
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
24-
mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
25-
mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
26-
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
27-
28-
return mapper.writeValueAsString(this);
11+
return Mapper.get().writeValueAsString(this);
2912
}
3013

3114
@Override
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.maxmind.minfraud;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.databind.DeserializationFeature;
5+
import com.fasterxml.jackson.databind.MapperFeature;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
7+
import com.fasterxml.jackson.databind.SerializationFeature;
8+
import com.fasterxml.jackson.databind.json.JsonMapper;
9+
import com.fasterxml.jackson.databind.util.StdDateFormat;
10+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
11+
12+
class Mapper {
13+
private final static ObjectMapper mapper = JsonMapper.builder()
14+
.addModule(new JavaTimeModule())
15+
.defaultDateFormat(new StdDateFormat().withColonInTimeZone(true))
16+
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
17+
.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)
18+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
19+
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
20+
.serializationInclusion(JsonInclude.Include.NON_NULL)
21+
.serializationInclusion(JsonInclude.Include.NON_EMPTY)
22+
.build();
23+
24+
public static ObjectMapper get() {
25+
return mapper;
26+
}
27+
}

0 commit comments

Comments
 (0)