diff --git a/codestyle/druid-forbidden-apis.txt b/codestyle/druid-forbidden-apis.txt index c53007f76e37..893b10fd348f 100644 --- a/codestyle/druid-forbidden-apis.txt +++ b/codestyle/druid-forbidden-apis.txt @@ -2,6 +2,7 @@ com.fasterxml.jackson.databind.ObjectMapper#reader(com.fasterxml.jackson.core.ty com.fasterxml.jackson.databind.ObjectMapper#reader(com.fasterxml.jackson.databind.JavaType) @ Use ObjectMapper#readerFor instead com.fasterxml.jackson.databind.ObjectMapper#reader(java.lang.Class) @ Use ObjectMapper#readerFor instead com.fasterxml.jackson.databind.ObjectMapper#writeValue(com.fasterxml.jackson.core.JsonGenerator, java.lang.Object) @ Use JacksonUtils#writeObjectUsingSerializerProvider to allow SerializerProvider reuse +com.fasterxml.jackson.databind.ObjectMapper#writerWithType(com.fasterxml.jackson.core.type.TypeReference) @ Use ObjectMapper#writeFor instead com.fasterxml.jackson.core.JsonGenerator#writeObject(java.lang.Object) @ Use JacksonUtils#writeObjectUsingSerializerProvider to allow SerializerProvider reuse com.google.common.base.Charsets @ Use java.nio.charset.StandardCharsets instead com.google.common.collect.Iterators#emptyIterator() @ Use java.util.Collections#emptyIterator() diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/DetermineHashedPartitionsJob.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/DetermineHashedPartitionsJob.java index 2328552efb7b..5febd1cf01c4 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/DetermineHashedPartitionsJob.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/DetermineHashedPartitionsJob.java @@ -412,7 +412,7 @@ protected void reduce( try { HadoopDruidIndexerConfig.JSON_MAPPER - .writerWithType(Long.class) + .writerFor(Long.class) .writeValue(out, aggregate.estimateCardinalityRound()); } finally { @@ -430,7 +430,7 @@ public void run(Context context) final OutputStream out = Utils.makePathAndOutputStream(context, outPath, config.isOverwriteFiles()); try { - HadoopDruidIndexerConfig.JSON_MAPPER.writerWithType( + HadoopDruidIndexerConfig.JSON_MAPPER.writerFor( new TypeReference>() { } diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/DeterminePartitionsJob.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/DeterminePartitionsJob.java index 3efb6c5bec7e..ca5f49937abb 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/DeterminePartitionsJob.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/DeterminePartitionsJob.java @@ -920,7 +920,7 @@ protected void innerReduce(Context context, SortableBytes keyBytes, Iterable>() { } diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/worker/http/TaskManagementResource.java b/indexing-service/src/main/java/org/apache/druid/indexing/worker/http/TaskManagementResource.java index 4c2e9237a81b..dd9316a7a7d2 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/worker/http/TaskManagementResource.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/worker/http/TaskManagementResource.java @@ -167,7 +167,7 @@ public void onSuccess(ChangeRequestsSnapshot result) try { HttpServletResponse response = (HttpServletResponse) asyncContext.getResponse(); response.setStatus(HttpServletResponse.SC_OK); - context.inputMapper.writerWithType(WorkerHolder.WORKER_SYNC_RESP_TYPE_REF) + context.inputMapper.writerFor(WorkerHolder.WORKER_SYNC_RESP_TYPE_REF) .writeValue(asyncContext.getResponse().getOutputStream(), result); asyncContext.complete(); } diff --git a/server/src/main/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeon.java b/server/src/main/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeon.java index 2a6e03c8d1db..cf1a239b59d7 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeon.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeon.java @@ -132,7 +132,7 @@ public HttpLoadQueuePeon( ) { this.jsonMapper = jsonMapper; - this.requestBodyWriter = jsonMapper.writerWithType(REQUEST_ENTITY_TYPE_REF); + this.requestBodyWriter = jsonMapper.writerFor(REQUEST_ENTITY_TYPE_REF); this.httpClient = httpClient; this.config = config; this.processingExecutor = processingExecutor; diff --git a/server/src/main/java/org/apache/druid/server/http/SegmentListerResource.java b/server/src/main/java/org/apache/druid/server/http/SegmentListerResource.java index 38911950f024..7c4392daf4e2 100644 --- a/server/src/main/java/org/apache/druid/server/http/SegmentListerResource.java +++ b/server/src/main/java/org/apache/druid/server/http/SegmentListerResource.java @@ -182,7 +182,7 @@ public void onSuccess(ChangeRequestsSnapshot result) try { HttpServletResponse response = (HttpServletResponse) asyncContext.getResponse(); response.setStatus(HttpServletResponse.SC_OK); - context.inputMapper.writerWithType(HttpServerInventoryView.SEGMENT_LIST_RESP_TYPE_REF) + context.inputMapper.writerFor(HttpServerInventoryView.SEGMENT_LIST_RESP_TYPE_REF) .writeValue(asyncContext.getResponse().getOutputStream(), result); asyncContext.complete(); } @@ -295,7 +295,7 @@ public void onSuccess(List result) try { HttpServletResponse response = (HttpServletResponse) asyncContext.getResponse(); response.setStatus(HttpServletResponse.SC_OK); - context.inputMapper.writerWithType(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF) + context.inputMapper.writerFor(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF) .writeValue(asyncContext.getResponse().getOutputStream(), result); asyncContext.complete(); } diff --git a/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java b/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java index b96e51f0c91f..26dd20a70fc7 100644 --- a/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java +++ b/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java @@ -60,7 +60,7 @@ public void testSimple() throws Exception ImmutableList.of( Futures.immediateFuture( new ByteArrayInputStream( - jsonMapper.writerWithType(typeRef).writeValueAsBytes( + jsonMapper.writerFor(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, null, @@ -72,7 +72,7 @@ public void testSimple() throws Exception ), Futures.immediateFuture( new ByteArrayInputStream( - jsonMapper.writerWithType(typeRef).writeValueAsBytes( + jsonMapper.writerFor(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, null, @@ -84,7 +84,7 @@ public void testSimple() throws Exception ), Futures.immediateFuture( new ByteArrayInputStream( - jsonMapper.writerWithType(typeRef).writeValueAsBytes( + jsonMapper.writerFor(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( true, "reset the counter", @@ -96,7 +96,7 @@ public void testSimple() throws Exception ), Futures.immediateFuture( new ByteArrayInputStream( - jsonMapper.writerWithType(typeRef).writeValueAsBytes( + jsonMapper.writerFor(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, null, @@ -108,7 +108,7 @@ public void testSimple() throws Exception ), Futures.immediateFuture( new ByteArrayInputStream( - jsonMapper.writerWithType(typeRef).writeValueAsBytes( + jsonMapper.writerFor(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, null, diff --git a/server/src/test/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeonTest.java b/server/src/test/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeonTest.java index fa4ce7cc45bf..1dcf384d2e0d 100644 --- a/server/src/test/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeonTest.java +++ b/server/src/test/java/org/apache/druid/server/coordinator/loading/HttpLoadQueuePeonTest.java @@ -363,7 +363,7 @@ public ListenableFuture go( return (ListenableFuture) Futures.immediateFuture( new ByteArrayInputStream( MAPPER - .writerWithType(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF) + .writerFor(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF) .writeValueAsBytes(statuses) ) );