Skip to content

Commit

Permalink
Merge pull request Azure#1093 from jianghaolu/validatorfix
Browse files Browse the repository at this point in the history
Fix bug in validator that stack overflows on final/static fields
  • Loading branch information
anuchandy authored Sep 21, 2016
2 parents 245aba2 + 00b45db commit d67ca69
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.joda.time.Period;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -63,6 +64,11 @@ public static void validate(Object parameter) throws IllegalArgumentException {
}
for (Field field : c.getDeclaredFields()) {
field.setAccessible(true);
int mod = field.getModifiers();
// Skip static fields since we don't have any, skip final fields since users can't modify them
if (Modifier.isFinal(mod) || Modifier.isStatic(mod)) {
return;
}
JsonProperty annotation = field.getAnnotation(JsonProperty.class);
Object property;
try {
Expand Down

0 comments on commit d67ca69

Please sign in to comment.