correctly.
+ // Jackson library removed the method on the abstract class but the methods are still there in the implementations of AnnotatedMember. The method signatures are implementation specific and we are calling those methods to get the generic type.
+
+ if (m instanceof AnnotatedField) {
+ genericType = ((AnnotatedField) m).getAnnotated().getGenericType();
+ } else if (m instanceof AnnotatedMethod) {
+ genericType = ((AnnotatedMethod) m).getAnnotated().getGenericReturnType();
+ } else if (m instanceof AnnotatedParameter) {
+ genericType = ((AnnotatedParameter) m).getOwner().getGenericParameterType(((AnnotatedParameter) m).getIndex());
+ }
+
+ if (genericType == null) {
+ // Fall back to type-erased raw type in case we missed an implementation. We are unlikely to ever get here though
+ genericType = m.getRawType();
+ }
if (guiceAnnotation == null) {
if (m instanceof AnnotatedMethod) {
throw new IAE("Annotated methods don't work very well yet...");
}
- return Key.get(m.getGenericType());
+ return Key.get(genericType);
}
- return Key.get(m.getGenericType(), guiceAnnotation);
+ return Key.get(genericType, guiceAnnotation);
}
- /**
- * This method is used to find what property to ignore in deserialization. Jackson calls this method
- * per every class and every constructor parameter.
- *
- * This implementation returns a {@link JsonIgnoreProperties.Value#empty()} that allows empty names if
- * the parameters has the {@link JsonProperty} annotation. Otherwise, it returns
- * {@code JsonIgnoreProperties.Value.forIgnoredProperties("")} that does NOT allow empty names.
- * This behavior is to work around a bug in Jackson deserializer (see the below comment for details) and
- * can be removed in the future after the bug is fixed.
- * For example, suppose a constructor like below:
- *
- * {@code
- * @JsonCreator
- * public ClassWithJacksonInject(
- * @JsonProperty("val") String val,
- * @JacksonInject InjectedParameter injected
- * )
- * }
- *
- * During deserializing a JSON string into this class, this method will be called at least twice,
- * one for {@code val} and another for {@code injected}. It will return {@code Value.empty()} for {@code val},
- * while {Value.forIgnoredProperties("")} for {@code injected} because the later does not have {@code JsonProperty}.
- * As a result, {@code injected} will be ignored during deserialization since it has no name.
- */
+ /**
+ * This method is used to find what property to ignore in deserialization. Jackson calls this method
+ * per every class and every constructor parameter.
+ *
+ * This implementation returns a {@link JsonIgnoreProperties.Value#empty()} that allows empty names if
+ * the parameters has the {@link JsonProperty} annotation. Otherwise, it returns
+ * {@code JsonIgnoreProperties.Value.forIgnoredProperties("")} that does NOT allow empty names.
+ * This behavior is to work around a bug in Jackson deserializer (see the below comment for details) and
+ * can be removed in the future after the bug is fixed.
+ * For example, suppose a constructor like below:
+ *
+ * {@code
+ * @JsonCreator
+ * public ClassWithJacksonInject(
+ * @JsonProperty("val") String val,
+ * @JacksonInject InjectedParameter injected
+ * )
+ * }
+ *
+ * During deserializing a JSON string into this class, this method will be called at least twice,
+ * one for {@code val} and another for {@code injected}. It will return {@code Value.empty()} for {@code val},
+ * while {Value.forIgnoredProperties("")} for {@code injected} because the later does not have {@code JsonProperty}.
+ * As a result, {@code injected} will be ignored during deserialization since it has no name.
+ */
@Override
public JsonIgnoreProperties.Value findPropertyIgnorals(Annotated ac)
{
diff --git a/processing/src/test/java/org/apache/druid/segment/TestHelper.java b/processing/src/test/java/org/apache/druid/segment/TestHelper.java
index 5916fe8860b5..c167f6fe9524 100644
--- a/processing/src/test/java/org/apache/druid/segment/TestHelper.java
+++ b/processing/src/test/java/org/apache/druid/segment/TestHelper.java
@@ -19,6 +19,7 @@
package org.apache.druid.segment;
+import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -85,7 +86,7 @@ public static AnnotationIntrospector makeAnnotationIntrospector()
return new GuiceAnnotationIntrospector()
{
@Override
- public Object findInjectableValueId(AnnotatedMember m)
+ public JacksonInject.Value findInjectableValue(AnnotatedMember m)
{
return null;
}
diff --git a/server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java b/server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java
index 3a0a184f1a4a..f0f18667d69d 100644
--- a/server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java
+++ b/server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java
@@ -130,22 +130,22 @@ public void testValidationInsaneError()
throw new IllegalStateException("Should have already failed");
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testTRUE()
{
properties.put(PROPERTY_PREFIX + ".populateCache", "TRUE");
configProvider.inject(properties, configurator);
CacheConfig config = configProvider.get();
- throw new IllegalStateException("Should have already failed");
+ Assert.assertTrue(config.isPopulateCache());
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testFALSE()
{
properties.put(PROPERTY_PREFIX + ".populateCache", "FALSE");
configProvider.inject(properties, configurator);
CacheConfig config = configProvider.get();
- throw new IllegalStateException("Should have already failed");
+ Assert.assertFalse(config.isPopulateCache());
}