julianhyde commented on code in PR #183: URL: https://github.com/apache/calcite-avatica/pull/183#discussion_r1002770793
########## core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java: ########## @@ -222,15 +223,22 @@ public static <T> T instantiatePlugin(Class<T> pluginClass, final Class<T> clazz = (Class) Class.forName(left); final Field field; field = clazz.getField(right); - return pluginClass.cast(field.get(null)); + final Object fieldValue = field.get(null); + if (fieldValue instanceof ThreadLocal) { + value = ((ThreadLocal<?>) fieldValue).get(); + } else { + value = fieldValue; + } + return pluginClass.cast(value); } //noinspection unchecked final Class<T> clazz = (Class) Class.forName(className); try { // We assume that if there is an INSTANCE field it is static and // has the right type. final Field field = clazz.getField("INSTANCE"); - return pluginClass.cast(field.get(null)); + value = field.get(null); + return pluginClass.cast(value); Review Comment: No. If a class `Foo` has a field called `INSTANCE`, it should be of type `Foo`. It would be confusing for a field called `INSTANCE` to be of any other type. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org