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

Commit

Permalink
Remove Jackson byte[] workaround (#7168)
Browse files Browse the repository at this point in the history
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

Removes changes from #6750
  • Loading branch information
schlosna authored Jul 1, 2024
1 parent 8a2de90 commit d51513d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Throwables;
import com.palantir.atlasdb.persist.api.ReusablePersister;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;

/**
* A {@link ReusablePersister} that uses an {@link ObjectMapper} to serialize and deserialize objects
Expand All @@ -41,14 +38,7 @@ public JacksonPersister(Class<T> typeRef, ObjectMapper mapper) {
@Override
public final T hydrateFromBytes(byte[] input) {
try {
if (input.length <= 8192 && mapper.getFactory().canUseCharArrays()) {
// Optimize to avoid allocation of heap ByteBuffer via InputStreamReader.
// Remove after upgrade to Jackson 2.16.
// see: https://github.com/FasterXML/jackson-core/pull/1081
// and https://github.com/FasterXML/jackson-benchmarks/pull/9
return mapper.readValue(new StringReader(new String(input, StandardCharsets.UTF_8)), typeRef);
}
return mapper.readValue(new ByteArrayInputStream(input), typeRef);
return mapper.readValue(input, typeRef);
} catch (IOException e) {
throw Throwables.propagate(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import com.palantir.conjure.java.serialization.ObjectMappers;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import java.util.function.Function;

Expand Down Expand Up @@ -101,15 +98,7 @@ static VersionedInternalSchemaMetadata encode(InternalSchemaMetadata internalSch

private static InternalSchemaMetadata decodeViaJson(byte[] byteArray) {
try {
if (byteArray.length <= 8192) {
// Optimize to avoid allocation of heap ByteBuffer via InputStreamReader.
// Remove after upgrade to Jackson 2.16.
// see: https://github.com/FasterXML/jackson-core/pull/1081
// and https://github.com/FasterXML/jackson-benchmarks/pull/9
return SCHEMA_METADATA_READER.readValue(
new StringReader(new String(byteArray, StandardCharsets.UTF_8)));
}
return SCHEMA_METADATA_READER.readValue(new ByteArrayInputStream(byteArray));
return SCHEMA_METADATA_READER.readValue(byteArray);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
8 changes: 8 additions & 0 deletions changelog/@unreleased/pr-7168.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: improvement
improvement:
description: |-
Now that AtlasDB has upgraded to Jackson 2.16.1, remove performance workaround that landed upstream in Jackson 2.16.0. See https://github.com/FasterXML/jackson-core/pull/1081
Removes changes from https://github.com/palantir/atlasdb/pull/6750
links:
- https://github.com/palantir/atlasdb/pull/7168

0 comments on commit d51513d

Please sign in to comment.