Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit acf3d58

Browse files
committed
Remove Jackson byte[] workaround
Now that AtlasDB has upgraded to Jackson 2.16.1, remove performance workaround that landed upstream in Jackson 2.16.0. See FasterXML/jackson-core#1081
1 parent b291ed8 commit acf3d58

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

atlasdb-client/src/main/java/com/palantir/atlasdb/persister/JacksonPersister.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020
import com.google.common.base.Throwables;
2121
import com.palantir.atlasdb.persist.api.ReusablePersister;
22-
import java.io.ByteArrayInputStream;
2322
import java.io.IOException;
24-
import java.io.StringReader;
25-
import java.nio.charset.StandardCharsets;
2623

2724
/**
2825
* A {@link ReusablePersister} that uses an {@link ObjectMapper} to serialize and deserialize objects
@@ -41,14 +38,7 @@ public JacksonPersister(Class<T> typeRef, ObjectMapper mapper) {
4138
@Override
4239
public final T hydrateFromBytes(byte[] input) {
4340
try {
44-
if (input.length <= 8192 && mapper.getFactory().canUseCharArrays()) {
45-
// Optimize to avoid allocation of heap ByteBuffer via InputStreamReader.
46-
// Remove after upgrade to Jackson 2.16.
47-
// see: https://github.com/FasterXML/jackson-core/pull/1081
48-
// and https://github.com/FasterXML/jackson-benchmarks/pull/9
49-
return mapper.readValue(new StringReader(new String(input, StandardCharsets.UTF_8)), typeRef);
50-
}
51-
return mapper.readValue(new ByteArrayInputStream(input), typeRef);
41+
return mapper.readValue(input, typeRef);
5242
} catch (IOException e) {
5343
throw Throwables.propagate(e);
5444
}

atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/internalschema/persistence/InternalSchemaMetadataPayloadCodec.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
import com.palantir.conjure.java.serialization.ObjectMappers;
2626
import com.palantir.logsafe.SafeArg;
2727
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
28-
import java.io.ByteArrayInputStream;
2928
import java.io.IOException;
30-
import java.io.StringReader;
31-
import java.nio.charset.StandardCharsets;
3229
import java.util.Optional;
3330
import java.util.function.Function;
3431

@@ -101,15 +98,7 @@ static VersionedInternalSchemaMetadata encode(InternalSchemaMetadata internalSch
10198

10299
private static InternalSchemaMetadata decodeViaJson(byte[] byteArray) {
103100
try {
104-
if (byteArray.length <= 8192) {
105-
// Optimize to avoid allocation of heap ByteBuffer via InputStreamReader.
106-
// Remove after upgrade to Jackson 2.16.
107-
// see: https://github.com/FasterXML/jackson-core/pull/1081
108-
// and https://github.com/FasterXML/jackson-benchmarks/pull/9
109-
return SCHEMA_METADATA_READER.readValue(
110-
new StringReader(new String(byteArray, StandardCharsets.UTF_8)));
111-
}
112-
return SCHEMA_METADATA_READER.readValue(new ByteArrayInputStream(byteArray));
101+
return SCHEMA_METADATA_READER.readValue(byteArray);
113102
} catch (IOException e) {
114103
throw new RuntimeException(e);
115104
}

0 commit comments

Comments
 (0)