lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [lucene-solr] branch master updated: SOLR-13841: Added 'JsonProperty' to forbidden APIs
Date Wed, 13 Nov 2019 04:52:12 GMT
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 11fd8d6  SOLR-13841: Added 'JsonProperty' to forbidden APIs
11fd8d6 is described below

commit 11fd8d630a5e92ab286b378e69e85fa23fddafb1
Author: noble <noble@apache.org>
AuthorDate: Wed Nov 13 15:51:49 2019 +1100

    SOLR-13841: Added 'JsonProperty' to forbidden APIs
---
 lucene/tools/forbiddenApis/solr.txt                                 | 4 ++++
 solr/core/src/java/org/apache/solr/api/AnnotatedApi.java            | 3 +--
 .../java/org/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 303f0a8..bb177be 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 ac9fdd0..6cd65cd 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 727ffcb..1b59dce 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;
+  }
 }


Mime
View raw message