Skip to content

Commit 0db5efd

Browse files
authored
Merge pull request #593 from maxmind/greg/eng-2665
Require Java 17+
2 parents 3f0d865 + 924879a commit 0db5efd

21 files changed

+76
-404
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
matrix:
1010
distribution: ['zulu']
1111
os: [ubuntu-latest, windows-latest, macos-latest]
12-
version: [ 11, 17, 21, 22 ]
12+
version: [ 17, 21, 24 ]
1313
steps:
1414
- uses: actions/checkout@v5
1515
with:

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
CHANGELOG
22
=========
33

4+
5.0.0
5+
------------------
6+
7+
* The deprecation notices for IP Risk database support have been removed.
8+
IP Risk database support will continue to be maintained.
9+
* **BREAKING:** The deprecated `WebServiceClient.Builder` methods
10+
`connectTimeout(int)`, `readTimeout(int)`, and `proxy(Proxy)` have been
11+
removed. Use `connectTimeout(Duration)`, `requestTimeout(Duration)`, and
12+
`proxy(ProxySelector)` respectively.
13+
* **BREAKING:** The deprecated `WebServiceClient.close()` method has been
14+
removed along with the `Closeable` interface implementation.
15+
* **BREAKING:** The deprecated `getUrl()` methods in `HttpException` and
16+
`InvalidRequestException` have been removed. Use `getUri()` instead.
17+
* **BREAKING:** The deprecated `Traits` constructors and methods
18+
`isAnonymousProxy()` and `isSatelliteProvider()` have been removed. Use the
19+
GeoIP2 Anonymous IP database for anonymous proxy detection instead.
20+
* **BREAKING:** The deprecated `Location.getMetroCode()` method has been
21+
removed. Metro code values are no longer maintained.
22+
* **BREAKING:** Java 11 support has been dropped. Java 17 or later is now required.
23+
* **BREAKING:** Removed explicit `serialVersionUID` from all exception classes.
24+
Java will auto-generate serialVersionUID when needed, following modern practices.
25+
426
4.4.0 (2025-08-28)
527
------------------
628

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
https://maxmind.github.io/MaxMind-DB-Reader-java/doc/latest/
149149
</link>
150150
</links>
151-
<source>11</source>
151+
<source>17</source>
152152
<doclint>-missing</doclint>
153153
</configuration>
154154
<executions>
@@ -198,8 +198,8 @@
198198
<artifactId>maven-compiler-plugin</artifactId>
199199
<version>3.14.0</version>
200200
<configuration>
201-
<release>11</release>
202-
<source>11</source>
201+
<release>17</release>
202+
<source>17</source>
203203
<target>11</target>
204204
</configuration>
205205
</plugin>

src/main/java/com/maxmind/geoip2/DatabaseProvider.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ Optional<AnonymousPlusResponse> tryAnonymousPlus(InetAddress ipAddress) throws I
8989
* @return an IpRiskResponse for the requested IP address.
9090
* @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP
9191
* @throws java.io.IOException if there is an IO error
92-
* @deprecated This database has been discontinued.
9392
*/
94-
@Deprecated
9593
IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException,
9694
GeoIp2Exception;
9795

@@ -102,9 +100,7 @@ IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException,
102100
* @return an IPRiskResponse for the requested IP address or empty if it is not in the DB.
103101
* @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP
104102
* @throws java.io.IOException if there is an IO error
105-
* @deprecated This database has been discontinued.
106103
*/
107-
@Deprecated
108104
Optional<IpRiskResponse> tryIpRisk(InetAddress ipAddress) throws IOException,
109105
GeoIp2Exception;
110106

src/main/java/com/maxmind/geoip2/DatabaseReader.java

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.io.IOException;
2525
import java.io.InputStream;
2626
import java.net.InetAddress;
27-
import java.util.Collections;
2827
import java.util.List;
2928
import java.util.Optional;
3029

@@ -150,9 +149,8 @@ private int getDatabaseType() {
150149
type |= DatabaseType.ISP.type;
151150
}
152151
if (type == 0) {
153-
// XXX - exception type
154-
throw new UnsupportedOperationException(
155-
"Invalid attempt to open an unknown database type: " + databaseType);
152+
throw new IllegalArgumentException(
153+
"Unsupported database type: " + databaseType);
156154
}
157155
return type;
158156
}
@@ -174,7 +172,7 @@ public static final class Builder {
174172
final File database;
175173
final InputStream stream;
176174

177-
List<String> locales = Collections.singletonList("en");
175+
List<String> locales = List.of("en");
178176
FileMode mode = FileMode.MEMORY_MAPPED;
179177
NodeCache cache = NoCache.getInstance();
180178

@@ -239,28 +237,7 @@ public DatabaseReader build() throws IOException {
239237
}
240238
}
241239

242-
static final class LookupResult<T> {
243-
final T model;
244-
final String ipAddress;
245-
final Network network;
246-
247-
LookupResult(T model, String ipAddress, Network network) {
248-
this.model = model;
249-
this.ipAddress = ipAddress;
250-
this.network = network;
251-
}
252-
253-
T getModel() {
254-
return this.model;
255-
}
256-
257-
String getIpAddress() {
258-
return this.ipAddress;
259-
}
260-
261-
Network getNetwork() {
262-
return this.network;
263-
}
240+
static record LookupResult<T>(T model, String ipAddress, Network network) {
264241
}
265242

266243
/**
@@ -333,15 +310,15 @@ private Optional<CountryResponse> getCountry(
333310
CountryResponse.class,
334311
DatabaseType.COUNTRY
335312
);
336-
CountryResponse response = result.getModel();
313+
CountryResponse response = result.model();
337314
if (response == null) {
338315
return Optional.empty();
339316
}
340317
return Optional.of(
341318
new CountryResponse(
342319
response,
343-
result.getIpAddress(),
344-
result.getNetwork(),
320+
result.ipAddress(),
321+
result.network(),
345322
locales
346323
)
347324
);
@@ -372,15 +349,15 @@ private Optional<CityResponse> getCity(
372349
CityResponse.class,
373350
DatabaseType.CITY
374351
);
375-
CityResponse response = result.getModel();
352+
CityResponse response = result.model();
376353
if (response == null) {
377354
return Optional.empty();
378355
}
379356
return Optional.of(
380357
new CityResponse(
381358
response,
382-
result.getIpAddress(),
383-
result.getNetwork(),
359+
result.ipAddress(),
360+
result.network(),
384361
locales
385362
)
386363
);
@@ -419,15 +396,15 @@ private Optional<AnonymousIpResponse> getAnonymousIp(
419396
AnonymousIpResponse.class,
420397
DatabaseType.ANONYMOUS_IP
421398
);
422-
AnonymousIpResponse response = result.getModel();
399+
AnonymousIpResponse response = result.model();
423400
if (response == null) {
424401
return Optional.empty();
425402
}
426403
return Optional.of(
427404
new AnonymousIpResponse(
428405
response,
429-
result.getIpAddress(),
430-
result.getNetwork()
406+
result.ipAddress(),
407+
result.network()
431408
)
432409
);
433410
}
@@ -466,15 +443,15 @@ private Optional<AnonymousPlusResponse> getAnonymousPlus(
466443
AnonymousPlusResponse.class,
467444
DatabaseType.ANONYMOUS_PLUS
468445
);
469-
AnonymousPlusResponse response = result.getModel();
446+
AnonymousPlusResponse response = result.model();
470447
if (response == null) {
471448
return Optional.empty();
472449
}
473450
return Optional.of(
474451
new AnonymousPlusResponse(
475452
response,
476-
result.getIpAddress(),
477-
result.getNetwork()
453+
result.ipAddress(),
454+
result.network()
478455
)
479456
);
480457
}
@@ -487,9 +464,7 @@ private Optional<AnonymousPlusResponse> getAnonymousPlus(
487464
* @return a IPRiskResponse for the requested IP address.
488465
* @throws GeoIp2Exception if there is an error looking up the IP
489466
* @throws IOException if there is an IO error
490-
* @deprecated This database has been discontinued.
491467
*/
492-
@Deprecated
493468
@Override
494469
public IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException,
495470
GeoIp2Exception {
@@ -501,30 +476,28 @@ public IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException,
501476
return r.get();
502477
}
503478

504-
@Deprecated
505479
@Override
506480
public Optional<IpRiskResponse> tryIpRisk(InetAddress ipAddress) throws IOException,
507481
GeoIp2Exception {
508482
return getIpRisk(ipAddress);
509483
}
510484

511-
@Deprecated
512485
private Optional<IpRiskResponse> getIpRisk(InetAddress ipAddress) throws IOException,
513486
GeoIp2Exception {
514487
LookupResult<IpRiskResponse> result = this.get(
515488
ipAddress,
516489
IpRiskResponse.class,
517490
DatabaseType.IP_RISK
518491
);
519-
IpRiskResponse response = result.getModel();
492+
IpRiskResponse response = result.model();
520493
if (response == null) {
521494
return Optional.empty();
522495
}
523496
return Optional.of(
524497
new IpRiskResponse(
525498
response,
526-
result.getIpAddress(),
527-
result.getNetwork()
499+
result.ipAddress(),
500+
result.network()
528501
)
529502
);
530503
}
@@ -561,15 +534,15 @@ private Optional<AsnResponse> getAsn(InetAddress ipAddress)
561534
AsnResponse.class,
562535
DatabaseType.ASN
563536
);
564-
AsnResponse response = result.getModel();
537+
AsnResponse response = result.model();
565538
if (response == null) {
566539
return Optional.empty();
567540
}
568541
return Optional.of(
569542
new AsnResponse(
570543
response,
571-
result.getIpAddress(),
572-
result.getNetwork()
544+
result.ipAddress(),
545+
result.network()
573546
)
574547
);
575548
}
@@ -607,15 +580,15 @@ private Optional<ConnectionTypeResponse> getConnectionType(
607580
ConnectionTypeResponse.class,
608581
DatabaseType.CONNECTION_TYPE
609582
);
610-
ConnectionTypeResponse response = result.getModel();
583+
ConnectionTypeResponse response = result.model();
611584
if (response == null) {
612585
return Optional.empty();
613586
}
614587
return Optional.of(
615588
new ConnectionTypeResponse(
616589
response,
617-
result.getIpAddress(),
618-
result.getNetwork()
590+
result.ipAddress(),
591+
result.network()
619592
)
620593
);
621594
}
@@ -653,15 +626,15 @@ private Optional<DomainResponse> getDomain(
653626
DomainResponse.class,
654627
DatabaseType.DOMAIN
655628
);
656-
DomainResponse response = result.getModel();
629+
DomainResponse response = result.model();
657630
if (response == null) {
658631
return Optional.empty();
659632
}
660633
return Optional.of(
661634
new DomainResponse(
662635
response,
663-
result.getIpAddress(),
664-
result.getNetwork()
636+
result.ipAddress(),
637+
result.network()
665638
)
666639
);
667640
}
@@ -699,15 +672,15 @@ private Optional<EnterpriseResponse> getEnterprise(
699672
EnterpriseResponse.class,
700673
DatabaseType.ENTERPRISE
701674
);
702-
EnterpriseResponse response = result.getModel();
675+
EnterpriseResponse response = result.model();
703676
if (response == null) {
704677
return Optional.empty();
705678
}
706679
return Optional.of(
707680
new EnterpriseResponse(
708681
response,
709-
result.getIpAddress(),
710-
result.getNetwork(),
682+
result.ipAddress(),
683+
result.network(),
711684
locales
712685
)
713686
);
@@ -746,15 +719,15 @@ private Optional<IspResponse> getIsp(
746719
IspResponse.class,
747720
DatabaseType.ISP
748721
);
749-
IspResponse response = result.getModel();
722+
IspResponse response = result.model();
750723
if (response == null) {
751724
return Optional.empty();
752725
}
753726
return Optional.of(
754727
new IspResponse(
755728
response,
756-
result.getIpAddress(),
757-
result.getNetwork()
729+
result.ipAddress(),
730+
result.network()
758731
)
759732
);
760733
}

0 commit comments

Comments
 (0)