Skip to content

Commit 92f1c50

Browse files
authored
Merge pull request #61 from maxmind/greg/minor-cleanup
Minor pre-release cleanups
2 parents fc31d9b + 4734671 commit 92f1c50

File tree

10 files changed

+43
-39
lines changed

10 files changed

+43
-39
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ matrix:
1717
- jdk: openjdk8
1818
- jdk: openjdk11
1919
env: RUN_SNYK=true
20+
- jdk: openjdk11
2021
- jdk: openjdk12
22+
- jdk: openjdk13
2123
- jdk: openjdk-ea
2224
- jdk: oraclejdk8
2325
dist: trusty
2426
- jdk: oraclejdk11
27+
- jdk: oraclejdk12
28+
- jdk: oraclejdk13
29+
- jdk: oraclejdk-ea
2530
allow_failures:
2631
- jdk: openjdk-ea
32+
- jdk: oraclejdk-ea
2733
env:
2834
global:
2935
- secure: KXF3RVBZDxeASAnleYlTaqvxRRB9FSzSAdVV9h7Kw81+p4UO64b8CPJR1p4fLIVwAp8C4R8h0xZDN3pAv/iyeA4ndIeh9tQXNZBm737RE5x+6x6nf/shP/Em1w9T1s3KmretXoTFK5NJGv2yTesgaIAV/JV1OFvlG6ArswhrPFc=

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>com.fasterxml.jackson.core</groupId>
4747
<artifactId>jackson-databind</artifactId>
48-
<version>2.10.0</version>
48+
<version>2.10.1</version>
4949
</dependency>
5050
</dependencies>
5151
<build>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class BufferHolder {
1818
BufferHolder(File database, FileMode mode) throws IOException {
1919
try (
2020
final RandomAccessFile file = new RandomAccessFile(database, "r");
21-
final FileChannel channel = file.getChannel();
21+
final FileChannel channel = file.getChannel()
2222
) {
2323
if (mode == FileMode.MEMORY) {
2424
this.buffer = ByteBuffer.wrap(new byte[(int) channel.size()]);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class Decoder {
2828

2929
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
3030

31-
private static final int[] POINTER_VALUE_OFFSETS = { 0, 0, 1 << 11, (1 << 19) + ((1) << 11), 0 };
31+
private static final int[] POINTER_VALUE_OFFSETS = {0, 0, 1 << 11, (1 << 19) + ((1) << 11), 0};
3232

3333
// XXX - This is only for unit testings. We should possibly make a
3434
// constructor to set this
@@ -132,14 +132,14 @@ private JsonNode decode() throws IOException {
132132
int size = ctrlByte & 0x1f;
133133
if (size >= 29) {
134134
switch (size) {
135-
case 29:
136-
size = 29 + buffer.get();
137-
break;
138-
case 30:
139-
size = 285 + decodeInteger(2);
140-
break;
141-
default:
142-
size = 65821 + decodeInteger(3);
135+
case 29:
136+
size = 29 + buffer.get();
137+
break;
138+
case 30:
139+
size = 285 + decodeInteger(2);
140+
break;
141+
default:
142+
size = 65821 + decodeInteger(3);
143143
}
144144
}
145145

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public final class Network {
1414
/**
1515
* Construct a <code>Network</code>
1616
*
17-
* @param ipAddress An IP address in the network. This does not have to be
18-
* the first address in the network.
17+
* @param ipAddress An IP address in the network. This does not have to be
18+
* the first address in the network.
1919
* @param prefixLength The prefix length for the network.
2020
*/
2121
public Network(InetAddress ipAddress, int prefixLength) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.maxmind.db;
22

3+
import com.fasterxml.jackson.databind.JsonNode;
4+
35
import java.io.Closeable;
46
import java.io.File;
57
import java.io.IOException;
@@ -8,8 +10,6 @@
810
import java.nio.ByteBuffer;
911
import java.util.concurrent.atomic.AtomicReference;
1012

11-
import com.fasterxml.jackson.databind.JsonNode;
12-
1313
/**
1414
* Instances of this class provide a reader for the MaxMind DB format. IP
1515
* addresses can be looked up using the <code>get</code> method.
@@ -59,7 +59,7 @@ public Reader(File database) throws IOException {
5959
* GeoIP2 database file.
6060
*
6161
* @param database the MaxMind DB file to use.
62-
* @param cache backing cache instance
62+
* @param cache backing cache instance
6363
* @throws IOException if there is an error opening or reading from the file.
6464
*/
6565
public Reader(File database, NodeCache cache) throws IOException {
@@ -82,7 +82,7 @@ public Reader(InputStream source) throws IOException {
8282
* {@link FileMode#MEMORY}, without using a <code>File</code> instance.
8383
*
8484
* @param source the InputStream that contains the MaxMind DB file.
85-
* @param cache backing cache instance
85+
* @param cache backing cache instance
8686
* @throws IOException if there is an error reading from the Stream.
8787
*/
8888
public Reader(InputStream source, NodeCache cache) throws IOException {
@@ -109,7 +109,7 @@ public Reader(File database, FileMode fileMode) throws IOException {
109109
*
110110
* @param database the MaxMind DB file to use.
111111
* @param fileMode the mode to open the file with.
112-
* @param cache backing cache instance
112+
* @param cache backing cache instance
113113
* @throws IOException if there is an error opening or reading from the file.
114114
*/
115115
public Reader(File database, FileMode fileMode, NodeCache cache) throws IOException {
@@ -144,6 +144,7 @@ private Reader(BufferHolder bufferHolder, String name, NodeCache cache) throws I
144144
public JsonNode get(InetAddress ipAddress) throws IOException {
145145
return getRecord(ipAddress).getData();
146146
}
147+
147148
/**
148149
* Looks up <code>ipAddress</code> in the MaxMind DB.
149150
*
@@ -291,7 +292,6 @@ public Metadata getMetadata() {
291292
}
292293

293294
/**
294-
/**
295295
* <p>
296296
* Closes the database.
297297
* </p>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public final class Record {
1414
/**
1515
* Create a new record.
1616
*
17-
* @param data the data for the record in the database.
18-
* @param ipAddress the IP address used in the lookup.
17+
* @param data the data for the record in the database.
18+
* @param ipAddress the IP address used in the lookup.
1919
* @param prefixLength the network prefix length associated with the record in the database.
2020
*/
21-
public Record( JsonNode data, InetAddress ipAddress, int prefixLength) {
21+
public Record(JsonNode data, InetAddress ipAddress, int prefixLength) {
2222
this.data = data;
2323
this.network = new Network(ipAddress, prefixLength);
2424
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
22
* @author greg
3-
*
43
*/
54
package com.maxmind.db;

src/test/java/com/maxmind/db/DecoderTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.nio.MappedByteBuffer;
1212
import java.nio.channels.FileChannel;
1313
import java.nio.channels.FileChannel.MapMode;
14-
import java.nio.charset.Charset;
1514
import java.nio.charset.StandardCharsets;
1615
import java.util.HashMap;
1716
import java.util.Map;
@@ -274,19 +273,19 @@ private static Map<ObjectNode, byte[]> maps() {
274273
ObjectNode one = om.createObjectNode();
275274
one.put("en", "Foo");
276275
maps.put(one, new byte[]{(byte) 0xe1, /* en */0x42, 0x65, 0x6e,
277-
/* Foo */0x43, 0x46, 0x6f, 0x6f});
276+
/* Foo */0x43, 0x46, 0x6f, 0x6f});
278277

279278
ObjectNode two = om.createObjectNode();
280279
two.put("en", "Foo");
281280
two.put("zh", "人");
282281
maps.put(two, new byte[]{(byte) 0xe2,
283-
/* en */
282+
/* en */
284283
0x42, 0x65, 0x6e,
285-
/* Foo */
284+
/* Foo */
286285
0x43, 0x46, 0x6f, 0x6f,
287-
/* zh */
286+
/* zh */
288287
0x42, 0x7a, 0x68,
289-
/* 人 */
288+
/* 人 */
290289
0x43, (byte) 0xe4, (byte) 0xba, (byte) 0xba});
291290

292291
ObjectNode nested = om.createObjectNode();
@@ -295,11 +294,11 @@ private static Map<ObjectNode, byte[]> maps() {
295294
maps.put(nested, new byte[]{(byte) 0xe1, /* name */
296295
0x44, 0x6e, 0x61, 0x6d, 0x65, (byte) 0xe2,/* en */
297296
0x42, 0x65, 0x6e,
298-
/* Foo */
297+
/* Foo */
299298
0x43, 0x46, 0x6f, 0x6f,
300-
/* zh */
299+
/* zh */
301300
0x42, 0x7a, 0x68,
302-
/* 人 */
301+
/* 人 */
303302
0x43, (byte) 0xe4, (byte) 0xba, (byte) 0xba});
304303

305304
ObjectNode guess = om.createObjectNode();
@@ -309,11 +308,11 @@ private static Map<ObjectNode, byte[]> maps() {
309308
guess.set("languages", languages);
310309
maps.put(guess, new byte[]{(byte) 0xe1,/* languages */
311310
0x49, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x73,
312-
/* array */
311+
/* array */
313312
0x2, 0x4,
314-
/* en */
313+
/* en */
315314
0x42, 0x65, 0x6e,
316-
/* zh */
315+
/* zh */
317316
0x42, 0x7a, 0x68});
318317

319318
return maps;
@@ -326,16 +325,16 @@ private static Map<ArrayNode, byte[]> arrays() {
326325
ArrayNode f1 = om.createArrayNode();
327326
f1.add("Foo");
328327
arrays.put(f1, new byte[]{0x1, 0x4,
329-
/* Foo */
328+
/* Foo */
330329
0x43, 0x46, 0x6f, 0x6f});
331330

332331
ArrayNode f2 = om.createArrayNode();
333332
f2.add("Foo");
334333
f2.add("人");
335334
arrays.put(f2, new byte[]{0x2, 0x4,
336-
/* Foo */
335+
/* Foo */
337336
0x43, 0x46, 0x6f, 0x6f,
338-
/* 人 */
337+
/* 人 */
339338
0x43, (byte) 0xe4, (byte) 0xba, (byte) 0xba});
340339

341340
ArrayNode empty = om.createArrayNode();

src/test/java/com/maxmind/db/ReaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void test() throws IOException {
5555
}
5656
}
5757

58-
class GetRecordTest {
58+
static class GetRecordTest {
5959
InetAddress ip;
6060
File db;
6161
String network;

0 commit comments

Comments
 (0)