Skip to content

Commit

Permalink
Use regular ThreadLocal instead of the netty one (apache#3170)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrypeng authored Dec 12, 2018
1 parent 7bda5b6 commit e10e096
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.pulsar.client.impl.schema;

import io.netty.util.concurrent.FastThreadLocal;
import lombok.extern.slf4j.Slf4j;
import org.apache.avro.io.BinaryDecoder;
import org.apache.avro.io.BinaryEncoder;
Expand Down Expand Up @@ -47,8 +46,8 @@ public class AvroSchema<T> implements Schema<T> {
private BinaryEncoder encoder;
private ByteArrayOutputStream byteArrayOutputStream;

private static final FastThreadLocal<BinaryDecoder> decoders =
new FastThreadLocal<>();
private static final ThreadLocal<BinaryDecoder> decoders =
new ThreadLocal<>();

private AvroSchema(org.apache.avro.Schema schema,
Map<String, String> properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;
import io.netty.util.concurrent.FastThreadLocal;
import lombok.extern.slf4j.Slf4j;
import org.apache.avro.reflect.ReflectData;
import org.apache.pulsar.client.api.Schema;
Expand All @@ -46,15 +45,12 @@ public class JSONSchema<T> implements Schema<T>{

// Cannot use org.apache.pulsar.common.util.ObjectMapperFactory.getThreadLocal() because it does not
// return shaded version of object mapper
private static final FastThreadLocal<ObjectMapper> JSON_MAPPER = new FastThreadLocal<ObjectMapper>() {
@Override
protected ObjectMapper initialValue() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
}
};
private static final ThreadLocal<ObjectMapper> JSON_MAPPER = ThreadLocal.withInitial(() -> {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
});

private final ObjectMapper objectMapper;

Expand Down

0 comments on commit e10e096

Please sign in to comment.