Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.4</version>
<version>2.7.0</version>
</dependency>
</dependencies>
<properties>
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/maxmind/db/CHMCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.concurrent.ConcurrentHashMap;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ContainerNode;

/**
* A simplistic cache using a {@link ConcurrentHashMap}. There's no eviction
Expand Down Expand Up @@ -42,9 +41,6 @@ public JsonNode get(int key, Loader loader) throws IOException {
}
}
}
if (value instanceof ContainerNode) {
value = value.deepCopy();
}
return value;
}

Expand Down
16 changes: 11 additions & 5 deletions src/main/java/com/maxmind/db/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -257,26 +262,27 @@ private static BooleanNode decodeBoolean(int size)
}

private JsonNode decodeArray(int size) throws IOException {
ArrayNode array = OBJECT_MAPPER.createArrayNode();

List<JsonNode> array = new ArrayList<JsonNode>(size);
for (int i = 0; i < size; i++) {
JsonNode r = this.decode();
array.add(r);
}

return array;
return new ArrayNode(OBJECT_MAPPER.getNodeFactory(), Collections.unmodifiableList(array));
}

private JsonNode decodeMap(int size) throws IOException {
ObjectNode map = OBJECT_MAPPER.createObjectNode();
int capacity = (int) (size / 0.75F + 1.0F);
Map<String, JsonNode> map = new HashMap<String, JsonNode>(capacity);

for (int i = 0; i < size; i++) {
String key = this.decode().asText();
JsonNode value = this.decode();
map.set(key, value);
map.put(key, value);
}

return map;
return new ObjectNode(OBJECT_MAPPER.getNodeFactory(), Collections.unmodifiableMap(map));
}

private byte[] getByteArray(int length) {
Expand Down