Skip to content

Commit 19a7f34

Browse files
committed
Tidied code
1 parent cfd7cc5 commit 19a7f34

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ final class BufferHolder {
3232
// Also closes the underlying channel.
3333
file.close();
3434
} catch (final IOException e) {
35-
// If an exception was underway when we entered the finally block,
36-
// don't stomp over it due to an error closing the file and channel.
35+
// If an exception was underway when we entered the finally
36+
// block, don't stomp over it due to an error closing the file
37+
// and channel.
3738
if (!threw) {
3839
throw e;
3940
}

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public Reader(File database, FileMode fileMode) throws IOException {
8282
}
8383

8484
private Reader(BufferHolder bufferHolder, String name) throws IOException {
85-
this.bufferHolderReference = new AtomicReference<BufferHolder>(bufferHolder);
85+
this.bufferHolderReference = new AtomicReference<BufferHolder>(
86+
bufferHolder);
8687

8788
ByteBuffer buffer = bufferHolder.get();
8889
int start = this.findMetadataStart(buffer, name);
@@ -144,7 +145,8 @@ record = this.readNode(buffer, record, bit);
144145
throw new InvalidDatabaseException("Something bad happened");
145146
}
146147

147-
private int startNode(ByteBuffer buffer, int bitLength) throws InvalidDatabaseException {
148+
private int startNode(ByteBuffer buffer, int bitLength)
149+
throws InvalidDatabaseException {
148150
// Check if we are looking up an IPv4 address in an IPv6 tree. If this
149151
// is the case, we can skip over the first 96 nodes.
150152
if (this.metadata.ipVersion == 6 && bitLength == 32) {
@@ -155,7 +157,8 @@ private int startNode(ByteBuffer buffer, int bitLength) throws InvalidDatabaseEx
155157
return 0;
156158
}
157159

158-
private int findIpV4StartNode(ByteBuffer buffer) throws InvalidDatabaseException {
160+
private int findIpV4StartNode(ByteBuffer buffer)
161+
throws InvalidDatabaseException {
159162
if (this.metadata.ipVersion == 4) {
160163
return 0;
161164
}
@@ -194,7 +197,8 @@ private int readNode(ByteBuffer buffer, int nodeNumber, int index)
194197
}
195198
}
196199

197-
private JsonNode resolveDataPointer(ByteBuffer buffer, int pointer) throws IOException {
200+
private JsonNode resolveDataPointer(ByteBuffer buffer, int pointer)
201+
throws IOException {
198202
int resolved = (pointer - this.metadata.nodeCount)
199203
+ this.metadata.searchTreeSize;
200204

@@ -206,8 +210,8 @@ private JsonNode resolveDataPointer(ByteBuffer buffer, int pointer) throws IOExc
206210

207211
// We only want the data from the decoder, not the offset where it was
208212
// found.
209-
Decoder decoder = new Decoder(buffer,
210-
this.metadata.searchTreeSize + DATA_SECTION_SEPARATOR_SIZE);
213+
Decoder decoder = new Decoder(buffer, this.metadata.searchTreeSize
214+
+ DATA_SECTION_SEPARATOR_SIZE);
211215
return decoder.decode(resolved).getNode();
212216
}
213217

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public void mmapThreadTest() throws IOException, InterruptedException,
6969
}
7070
}
7171

72-
private static void threadTest(final Reader reader) throws InterruptedException,
73-
ExecutionException {
72+
private static void threadTest(final Reader reader)
73+
throws InterruptedException, ExecutionException {
7474
Callable<JsonNode> task = new Callable<JsonNode>() {
7575
@Override
7676
public JsonNode call() throws UnknownHostException, IOException {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ private void testBrokenDataPointer(Reader reader) throws IOException,
306306
}
307307

308308
@Test
309-
public void testClosedReaderThrowsException() throws IOException, URISyntaxException {
309+
public void testClosedReaderThrowsException() throws IOException,
310+
URISyntaxException {
310311
URI file = ReaderTest.class.getResource(
311312
"/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb").toURI();
312313
Reader reader = new Reader(new File(file));

0 commit comments

Comments
 (0)