Skip to content

Commit dbaa873

Browse files
authored
Merge pull request #118 from maxmind/greg/module
Require Java 11, use modules, and prepare for release
2 parents 9bfb629 + 958e2a4 commit dbaa873

24 files changed

+960
-509
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
matrix:
99
distribution: ['zulu']
1010
os: [ubuntu-latest, windows-latest, macos-latest]
11-
version: [ 8, 9, 10, 11, 12, 13, 14, 15 ]
11+
version: [ 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
1212
steps:
1313
- uses: actions/checkout@v3
1414
with:

CHANGELOG.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
------------------
6+
7+
* Java 11 or greater is now required.
8+
* This library is now a Java module.
9+
410
2.1.0 (2022-10-31)
511
------------------
612

713
* Messages for `DeserializationException` have been improved, and the cause
8-
is included, if any. Moreover, the message provides detail about the involved
9-
types, if the exception is caused by an `IllegalArgumentException`.
14+
is included, if any. Moreover, the message provides detail about the involved
15+
types, if the exception is caused by an `IllegalArgumentException`.
1016

1117
2.0.0 (2020-10-13)
1218
------------------
@@ -101,7 +107,6 @@ CHANGELOG
101107
* Several optimizations have been made to reduce allocations when decoding a
102108
record. Pull requests by Viktor Szathmáry. GitHub #16 & #17.
103109

104-
105110
1.0.0 (2014-09-29)
106111
------------------
107112

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ specific to this reader, please [contact MaxMind support](https://www.maxmind.co
185185

186186
## Requirements ##
187187

188-
This API requires Java 8 or greater.
188+
This API requires Java 11 or greater.
189189

190190
## Contributing ##
191191

@@ -198,6 +198,6 @@ The MaxMind DB Reader API uses [Semantic Versioning](https://semver.org/).
198198

199199
## Copyright and License ##
200200

201-
This software is Copyright (c) 2014-2020 by MaxMind, Inc.
201+
This software is Copyright (c) 2014-2022 by MaxMind, Inc.
202202

203203
This is free software, licensed under the Apache License, Version 2.0.

checkstyle-suppressions.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
5+
"https://checkstyle.org/dtds/suppressions_1_0.dtd">
6+
7+
<suppressions>
8+
<suppress checks="AbbreviationAsWordInName" files="CHMCache.java" lines="11"/>
9+
</suppressions>

checkstyle.xml

+382
Large diffs are not rendered by default.

pom.xml

+33-5
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
<groupId>com.maxmind.db</groupId>
56
<artifactId>maxmind-db</artifactId>
@@ -45,6 +46,33 @@
4546
</dependencies>
4647
<build>
4748
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-checkstyle-plugin</artifactId>
52+
<version>3.2.0</version>
53+
<configuration>
54+
<consoleOutput>true</consoleOutput>
55+
<configLocation>checkstyle.xml</configLocation>
56+
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
57+
<violationSeverity>warning</violationSeverity>
58+
</configuration>
59+
<dependencies>
60+
<dependency>
61+
<groupId>com.puppycrawl.tools</groupId>
62+
<artifactId>checkstyle</artifactId>
63+
<version>10.3</version>
64+
</dependency>
65+
</dependencies>
66+
<executions>
67+
<execution>
68+
<id>test</id>
69+
<phase>test</phase>
70+
<goals>
71+
<goal>check</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
4876
<plugin>
4977
<groupId>org.apache.maven.plugins</groupId>
5078
<artifactId>maven-gpg-plugin</artifactId>
@@ -78,8 +106,8 @@
78106
<artifactId>maven-compiler-plugin</artifactId>
79107
<version>3.10.1</version>
80108
<configuration>
81-
<source>8</source>
82-
<target>8</target>
109+
<source>11</source>
110+
<target>11</target>
83111
</configuration>
84112
</plugin>
85113
<plugin>
@@ -97,7 +125,7 @@
97125
<configuration>
98126
<format>xml</format>
99127
<maxmem>256m</maxmem>
100-
<check />
128+
<check/>
101129
</configuration>
102130
</plugin>
103131
<plugin>
@@ -141,7 +169,7 @@
141169
<plugin>
142170
<artifactId>maven-compiler-plugin</artifactId>
143171
<configuration>
144-
<release>8</release>
172+
<release>11</release>
145173
</configuration>
146174
</plugin>
147175
</plugins>

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

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.maxmind.db;
22

3+
import com.maxmind.db.Reader.FileMode;
34
import java.io.ByteArrayOutputStream;
45
import java.io.File;
56
import java.io.IOException;
@@ -9,23 +10,21 @@
910
import java.nio.channels.FileChannel;
1011
import java.nio.channels.FileChannel.MapMode;
1112

12-
import com.maxmind.db.Reader.FileMode;
13-
1413
final class BufferHolder {
1514
// DO NOT PASS OUTSIDE THIS CLASS. Doing so will remove thread safety.
1615
private final ByteBuffer buffer;
1716

1817
BufferHolder(File database, FileMode mode) throws IOException {
1918
try (
20-
final RandomAccessFile file = new RandomAccessFile(database, "r");
21-
final FileChannel channel = file.getChannel()
19+
final RandomAccessFile file = new RandomAccessFile(database, "r");
20+
final FileChannel channel = file.getChannel()
2221
) {
2322
if (mode == FileMode.MEMORY) {
2423
final ByteBuffer buf = ByteBuffer.wrap(new byte[(int) channel.size()]);
2524
if (channel.read(buf) != buf.capacity()) {
2625
throw new IOException("Unable to read "
27-
+ database.getName()
28-
+ " into memory. Unexpected end of stream.");
26+
+ database.getName()
27+
+ " into memory. Unexpected end of stream.");
2928
}
3029
this.buffer = buf.asReadOnlyBuffer();
3130
} else {
@@ -61,19 +60,21 @@ final class BufferHolder {
6160
ByteBuffer get() {
6261
// The Java API docs for buffer state:
6362
//
64-
// Buffers are not safe for use by multiple concurrent threads. If a buffer is to be used by more than
65-
// one thread then access to the buffer should be controlled by appropriate synchronization.
63+
// Buffers are not safe for use by multiple concurrent threads. If a buffer is to be
64+
// used by more than one thread then access to the buffer should be controlled by
65+
// appropriate synchronization.
6666
//
67-
// As such, you may think that this should be synchronized. This used to be the case, but we had several
68-
// complaints about the synchronization causing contention, e.g.:
67+
// As such, you may think that this should be synchronized. This used to be the case, but
68+
// we had several complaints about the synchronization causing contention, e.g.:
6969
//
7070
// * https://github.com/maxmind/MaxMind-DB-Reader-java/issues/65
7171
// * https://github.com/maxmind/MaxMind-DB-Reader-java/pull/69
7272
//
73-
// Given that we are not modifying the original ByteBuffer in any way and all currently known and most
74-
// reasonably imaginable implementations of duplicate() only do read operations on the original buffer object,
75-
// the risk of not synchronizing this call seems relatively low and worth taking for the performance benefit
76-
// when lookups are being done from many threads.
73+
// Given that we are not modifying the original ByteBuffer in any way and all currently
74+
// known and most reasonably imaginable implementations of duplicate() only do read
75+
// operations on the original buffer object, the risk of not synchronizing this call seems
76+
// relatively low and worth taking for the performance benefit when lookups are being done
77+
// from many threads.
7778
return this.buffer.duplicate();
7879
}
7980
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ final class CachedConstructor<T> {
1010
private final Map<String, Integer> parameterIndexes;
1111

1212
CachedConstructor(
13-
Constructor<T> constructor,
14-
Class<?>[] parameterTypes,
15-
java.lang.reflect.Type[] parameterGenericTypes,
16-
Map<String, Integer> parameterIndexes
13+
Constructor<T> constructor,
14+
Class<?>[] parameterTypes,
15+
java.lang.reflect.Type[] parameterGenericTypes,
16+
Map<String, Integer> parameterIndexes
1717
) {
1818
this.constructor = constructor;
1919
this.parameterTypes = parameterTypes;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.maxmind.db;
22

33
public final class DecodedValue {
4-
final Object value;
4+
final Object value;
55

66
DecodedValue(Object value) {
77
this.value = value;

0 commit comments

Comments
 (0)