SOLR-13841: Added 'JsonProperty' to forbidden APIs

This commit is contained in:
noble 2019-11-13 15:51:49 +11:00
parent 5df9a51cbf
commit 11fd8d630a
3 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}
}