{"record":{"id":"1f0e40a9d76b3835","repo":"Netflix/Hystrix","slug":"classsimplename-implementation-is-not-an-instan","errorCode":null,"errorMessage":"${classSimpleName} implementation is not an instance of ${classSimpleName}: ${implementingClass}","messagePattern":"(.+?) implementation is not an instance of (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/strategy/HystrixPlugins.java","lineNumber":352,"sourceCode":"        T p = getPluginImplementationViaProperties(pluginClass, dynamicProperties);\n        if (p != null) return p;        \n        return findService(pluginClass, classLoader);\n    }\n    \n    @SuppressWarnings(\"unchecked\")\n    private static <T> T getPluginImplementationViaProperties(Class<T> pluginClass, HystrixDynamicProperties dynamicProperties) {\n        String classSimpleName = pluginClass.getSimpleName();\n        // Check Archaius for plugin class.\n        String propertyName = \"hystrix.plugin.\" + classSimpleName + \".implementation\";\n        String implementingClass = dynamicProperties.getString(propertyName, null).get();\n        if (implementingClass != null) {\n            try {\n                Class<?> cls = Class.forName(implementingClass);\n                // narrow the scope (cast) to the type we're expecting\n                cls = cls.asSubclass(pluginClass);\n                return (T) cls.newInstance();\n            } catch (ClassCastException e) {\n                throw new RuntimeException(classSimpleName + \" implementation is not an instance of \" + classSimpleName + \": \" + implementingClass);\n            } catch (ClassNotFoundException e) {\n                throw new RuntimeException(classSimpleName + \" implementation class not found: \" + implementingClass, e);\n            } catch (InstantiationException e) {\n                throw new RuntimeException(classSimpleName + \" implementation not able to be instantiated: \" + implementingClass, e);\n            } catch (IllegalAccessException e) {\n                throw new RuntimeException(classSimpleName + \" implementation not able to be accessed: \" + implementingClass, e);\n            }\n        } else {\n            return null;\n        }\n    }\n    \n    \n\n    private static HystrixDynamicProperties resolveDynamicProperties(ClassLoader classLoader, LoggerSupplier logSupplier) {\n        HystrixDynamicProperties hp = getPluginImplementationViaProperties(HystrixDynamicProperties.class, \n                HystrixDynamicPropertiesSystemProperties.getInstance());\n        if (hp != null) {","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/strategy/HystrixPlugins.java#L334-L370","documentation":"When a plugin implementation is supplied via the property hystrix.plugin.<PluginSimpleName>.implementation, Hystrix loads the class reflectively and calls Class.asSubclass(pluginClass). If the named class does not extend/implement the expected Hystrix strategy type, a ClassCastException is caught and rethrown as this RuntimeException naming the offending class.","triggerScenarios":"Setting e.g. -Dhystrix.plugin.HystrixMetricsPublisher.implementation=com.example.MyNotAPublisher where MyNotAPublisher does not extend HystrixMetricsPublisher (wrong superclass, wrong interface, or a class that only extends another plugin type).","commonSituations":"Copy-pasting an Archaius property from a different plugin; renaming a strategy class so it no longer extends the base; pointing the wrong plugin key at a class written for a different strategy interface.","solutions":["Make the configured class extend the exact strategy interface named in the property key (e.g. class MyPublisher implements HystrixMetricsPublisher).","Verify the class hierarchy with a quick check: MyPublisher.class.asSubclass(HystrixMetricsPublisher.class) should not throw.","Correct the property value/className typo so it names a class of the right type."],"exampleFix":"// before\n-Dhystrix.plugin.HystrixMetricsPublisher.implementation=com.example.SomeRandomClass\n\n// after\npublic class SomeRandomClass implements HystrixMetricsPublisher { ... }\n// or point the property at a class that already implements HystrixMetricsPublisher","handlingStrategy":"type-guard","validationCode":"String fqcn = System.getProperty(\"hystrix.plugin.HystrixMetricsPublisher.implementation\");\nif (fqcn != null) {\n    Class<?> cls = Class.forName(fqcn);\n    if (!HystrixMetricsPublisher.class.isAssignableFrom(cls)) {\n        throw new IllegalStateException(fqcn + \" does not implement HystrixMetricsPublisher\");\n    }\n}","typeGuard":"static boolean isValidPlugin(Class<?> candidate, Class<?> pluginInterface) {\n    return pluginInterface.isAssignableFrom(candidate);\n}","tryCatchPattern":"try {\n    // trigger plugin resolution (first getter call)\n    HystrixPlugins.getInstance().getMetricsPublisher();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is not an instance of\")) {\n        // fix the hystrix.plugin.*.implementation property value\n    }\n}","preventionTips":["Add a startup assertion that each configured plugin class is assignable to its strategy interface.","Generate plugin config from a typed registry rather than free-form property strings."],"tags":["hystrix","configuration","reflection","classcast"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}