@@ -1116,18 +1116,18 @@ protected Type findJsonValueType(final BeanDescription beanDesc) {
1116
1116
1117
1117
// use recursion to check for method findJsonValueAccessor existence (Jackson 2.9+)
1118
1118
// if not found use previous deprecated method which could lead to inaccurate result
1119
- try {
1120
- Method m = BeanDescription .class .getMethod ("findJsonValueAccessor" );
1121
- AnnotatedMember jsonValueMember = (AnnotatedMember )m .invoke (beanDesc );
1122
- if (jsonValueMember != null ) {
1123
- return jsonValueMember .getType ();
1124
- }
1125
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) {
1119
+ AnnotatedMember jsonValueMember = invokeMethod (beanDesc , "findJsonValueAccessor" );
1120
+ if (jsonValueMember != null ) {
1121
+ return jsonValueMember .getType ();
1122
+ } else {
1126
1123
LOGGER .warn ("jackson BeanDescription.findJsonValueAccessor not found, this could lead to inaccurate result, please update jackson to 2.9+" );
1127
- final AnnotatedMethod jsonValueMethod = beanDesc .findJsonValueMethod ();
1128
- if (jsonValueMethod != null ) {
1129
- return jsonValueMethod .getType ();
1130
- }
1124
+ }
1125
+
1126
+ jsonValueMember = invokeMethod (beanDesc , "findJsonValueMethod" );
1127
+ if (jsonValueMember != null ) {
1128
+ return jsonValueMember .getType ();
1129
+ } else {
1130
+ LOGGER .error ("Neither 'findJsonValueMethod' nor 'findJsonValueAccessor' found in jackson BeanDescription. Please verify your Jackson version." );
1131
1131
}
1132
1132
return null ;
1133
1133
}
@@ -3057,6 +3057,15 @@ protected boolean isNumberSchema(Schema schema){
3057
3057
return "number" .equals (schema .getType ()) || (schema .getTypes () != null && schema .getTypes ().contains ("number" )) || "integer" .equals (schema .getType ()) || (schema .getTypes () != null && schema .getTypes ().contains ("integer" ));
3058
3058
}
3059
3059
3060
+ private AnnotatedMember invokeMethod (final BeanDescription beanDesc , String methodName ) {
3061
+ try {
3062
+ Method m = BeanDescription .class .getMethod (methodName );
3063
+ return (AnnotatedMember ) m .invoke (beanDesc );
3064
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) {
3065
+ return null ;
3066
+ }
3067
+ }
3068
+
3060
3069
protected Schema buildRefSchemaIfObject (Schema schema , ModelConverterContext context ) {
3061
3070
if (schema == null ) {
3062
3071
return null ;
0 commit comments