From 00b45dbafbfb813542aacf1c220cfb2f9a35f3dc Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 21 Sep 2016 11:56:31 -0700 Subject: [PATCH] Fix bug in validator that stack overflows on final/static fields --- .../src/main/java/com/microsoft/rest/Validator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client-runtime/src/main/java/com/microsoft/rest/Validator.java b/client-runtime/src/main/java/com/microsoft/rest/Validator.java index 51c24722404af..64e3436b0b633 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/Validator.java +++ b/client-runtime/src/main/java/com/microsoft/rest/Validator.java @@ -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; @@ -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 {