Skip to content

Commit e9ea56c

Browse files
committed
minor perf improvement to accessing enum annotation, avoid constructing, catching an npe
1 parent c73b072 commit e9ea56c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ public String findEnumValue(Enum<?> value)
7373
Field f = value.getClass().getField(value.name());
7474
if (f != null) {
7575
JsonProperty prop = f.getAnnotation(JsonProperty.class);
76-
String n = prop.value();
77-
if (n != null && !n.isEmpty()) {
78-
return n;
76+
if (prop != null) {
77+
String n = prop.value();
78+
if (n != null && !n.isEmpty()) {
79+
return n;
80+
}
7981
}
8082
}
81-
} catch (Exception e) {
82-
// no such field, or access; neither which we can do much about
83+
} catch (SecurityException e) {
84+
// 17-Sep-2015, tatu: Anything we could/should do here?
85+
} catch (NoSuchFieldException e) {
86+
// 17-Sep-2015, tatu: should not really happen. But... can we do anything?
8387
}
8488
return value.name();
8589
}

0 commit comments

Comments
 (0)