From 11fd8d630a5e92ab286b378e69e85fa23fddafb1 Mon Sep 17 00:00:00 2001 From: noble Date: Wed, 13 Nov 2019 15:51:49 +1100 Subject: [PATCH] SOLR-13841: Added 'JsonProperty' to forbidden APIs --- lucene/tools/forbiddenApis/solr.txt | 4 ++++ solr/core/src/java/org/apache/solr/api/AnnotatedApi.java | 3 +-- .../apache/solr/util/SolrJacksonAnnotationInspector.java | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lucene/tools/forbiddenApis/solr.txt b/lucene/tools/forbiddenApis/solr.txt index 303f0a8bf47..bb177bec976 100644 --- a/lucene/tools/forbiddenApis/solr.txt +++ b/lucene/tools/forbiddenApis/solr.txt @@ -55,3 +55,7 @@ com.google.common.base.Preconditions#checkNotNull(java.lang.Object,java.lang.Obj @defaultMessage Use methods in java.util.Comparator instead com.google.common.collect.Ordering +@defaultMessage Use org.apache.solr.common.annotation.JsonProperty instead +com.fasterxml.jackson.annotation.JsonProperty + + diff --git a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java index ac9fdd04a56..6cd65cda4de 100644 --- a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java +++ b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java @@ -171,14 +171,13 @@ public class AnnotatedApi extends Api implements PermissionNameProvider { final Command command; final Method method; final Object obj; - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = SolrJacksonAnnotationInspector.createObjectMapper(); int paramsCount; Class c; boolean isWrappedInPayloadObj = false; Cmd(Command command, Object obj, Method method) { - mapper.setAnnotationIntrospector(SolrJacksonAnnotationInspector.INSTANCE); if (Modifier.isPublic(method.getModifiers())) { this.command = command; this.obj = obj; diff --git a/solr/core/src/java/org/apache/solr/util/SolrJacksonAnnotationInspector.java b/solr/core/src/java/org/apache/solr/util/SolrJacksonAnnotationInspector.java index 727ffcbd598..1b59dce304b 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrJacksonAnnotationInspector.java +++ b/solr/core/src/java/org/apache/solr/util/SolrJacksonAnnotationInspector.java @@ -19,6 +19,7 @@ package org.apache.solr.util; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.AnnotationIntrospector; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyName; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.introspect.AnnotatedField; @@ -86,4 +87,9 @@ public class SolrJacksonAnnotationInspector extends AnnotationIntrospector { return findNameForSerialization(a); } + public static ObjectMapper createObjectMapper(){ + ObjectMapper mapper = new ObjectMapper(); + mapper.setAnnotationIntrospector(INSTANCE); + return mapper; + } }