{"record":{"id":"dfb89d25b9036d01","repo":"apache/druid","slug":"unable-to-create-cleaner","errorCode":null,"errorMessage":"Unable to create cleaner","messagePattern":"Unable to create cleaner","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"warning","filePath":"processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java","lineNumber":83,"sourceCode":"    catch (ReflectiveOperationException | RuntimeException e) {\n      throw new UnsupportedOperationException(\"Cleaning is not support on this platform, because internal \" +\n                                              \"Java APIs are not compatible with this Druid version\", e);\n    }\n  }\n\n  private static Cleaner lookupCleaner(MethodHandles.Lookup lookup) throws ReflectiveOperationException\n  {\n    Class<?> cleaner = Class.forName(\"java.lang.ref.Cleaner\");\n    Class<?> cleanable = Class.forName(\"java.lang.ref.Cleaner$Cleanable\");\n\n    MethodHandle create = lookup.findStatic(cleaner, \"create\", MethodType.methodType(cleaner));\n\n    Object theCleaner;\n    try {\n      theCleaner = create.invoke();\n    }\n    catch (Throwable t) {\n      throw new RuntimeException(\"Unable to create cleaner\", t);\n    }\n\n    MethodHandle register = lookup.findVirtual(\n        cleaner,\n        \"register\",\n        MethodType.methodType(cleanable, Object.class, Runnable.class)\n    ).bindTo(theCleaner);\n\n    MethodHandle clean = lookup.findVirtual(cleanable, \"clean\", MethodType.methodType(void.class));\n\n    return new CleanerImpl(register, clean);\n  }\n\n  public static Cleanable register(Object object, Runnable runnable)\n  {\n    if (CLEANER == null) {\n      throw new UnsupportedOperationException(CLEANER_NOT_SUPPORTED_EXCEPTION);\n    }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java#L65-L101","documentation":"Within Cleaners.lookupCleaner, after reflectively finding the cleaner factory MethodHandle, invoking it to instantiate the cleaner object failed. This RuntimeException wraps that Throwable and indicates the JDK's cleaner internals exist but cannot be instantiated via reflection in this runtime.","triggerScenarios":"lookupCleaner resolving the cleaner creation MethodHandle (e.g. Cleaner.create or CleanerFactory.cleaner) but create.invoke() throwing at runtime due to incompatible internal API signatures, access restrictions, or initialization failure on the JVM.","commonSituations":"Unusual JDK builds whose internal Cleaner API differs from what the reflective lookup expects; security managers or instrumentation agents rewriting internals; partial JDK upgrades where the class exists but construction fails.","solutions":["Switch to a mainstream OpenJDK build whose internal Cleaner API matches Druid's expectations.","Upgrade Druid to a version whose Cleaners implementation supports your JDK.","Handle this RuntimeException upstream and fall back to GC-based resource cleanup."],"exampleFix":"// before\nCleanable c = Cleaners.register(obj, action); // may throw RuntimeException\n// after\ntry {\n  Cleanable c = Cleaners.register(obj, action);\n} catch (RuntimeException | UnsupportedOperationException e) {\n  // fallback: rely on finalizer/GC\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Cleaners.register(obj, action);\n} catch (RuntimeException e) {\n  LOG.warn(e, \"cleaner init/registration failed\");\n}","preventionTips":["Test extensions on the target JVM before rollout","Keep Druid and JDK versions aligned with the compatibility matrix","Provide explicit close() fallbacks for resources"],"tags":["jvm","reflection","memory-cleanup","platform"],"backgroundTag":"module-init-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}