Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use deprecated Jackson API ObjectMapper.writerWithType() #17606

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected void reduce(

try {
HadoopDruidIndexerConfig.JSON_MAPPER
.writerWithType(Long.class)
.writerFor(Long.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets put this in the forbidden api's ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have added the check which would give the following error when the deprecated method is used:

[ERROR] Forbidden method invocation: com.fasterxml.jackson.databind.ObjectMapper#writerWithType(com.fasterxml.jackson.core.type.TypeReference) [Use ObjectMapper#writeFor instead]
[ERROR]   in org.apache.druid.server.coordinator.loading.HttpLoadQueuePeon (HttpLoadQueuePeon.java:135)

.writeValue(out, aggregate.estimateCardinalityRound());
}
finally {
Expand All @@ -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<List<Interval>>()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ protected void innerReduce(Context context, SortableBytes keyBytes, Iterable<Dim

try {
HadoopDruidIndexerConfig.JSON_MAPPER
.writerWithType(
.writerFor(
new TypeReference<List<ShardSpec>>()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void onSuccess(ChangeRequestsSnapshot<DataSegmentChangeRequest> 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();
}
Expand Down Expand Up @@ -295,7 +295,7 @@ public void onSuccess(List<DataSegmentChangeResponse> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public <Intermediate, Final> ListenableFuture<Final> go(
return (ListenableFuture<Final>) Futures.immediateFuture(
new ByteArrayInputStream(
MAPPER
.writerWithType(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF)
.writerFor(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF)
.writeValueAsBytes(statuses)
)
);
Expand Down
Loading