{"record":{"id":"be778f86a07edd63","repo":"apache/druid","slug":"unable-to-register-cleaning-action","errorCode":null,"errorMessage":"Unable to register cleaning action","messagePattern":"Unable to register cleaning action","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java","lineNumber":125,"sourceCode":"  {\n    private final MethodHandle register;\n    private final MethodHandle clean;\n\n    private CleanerImpl(MethodHandle register, MethodHandle clean)\n    {\n      this.register = register;\n      this.clean = clean;\n    }\n\n    @Override\n    public Cleanable register(Object object, Runnable runnable)\n    {\n      try {\n        Object cleanable = (Object) register.invoke(object, runnable);\n        return createCleanable(clean, cleanable);\n      }\n      catch (Throwable t) {\n        throw new RuntimeException(\"Unable to register cleaning action\", t);\n      }\n    }\n\n    private static Cleanable createCleanable(MethodHandle clean, Object cleanable)\n    {\n      return () -> {\n        try {\n          clean.invoke(cleanable);\n        }\n        catch (Throwable t) {\n          throw new RuntimeException(\"Unable to run cleaning action\", t);\n        }\n      };\n    }\n  }\n}\n","sourceCodeStart":107,"sourceCodeEnd":142,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java#L107-L142","documentation":"CleanerImpl.register invokes the reflectively-obtained cleaner register MethodHandle to attach a cleanup action to an object. If that invocation throws for any reason, this RuntimeException wraps it. The cleaner existed but the registration call itself failed on this runtime.","triggerScenarios":"Calling Cleaners.register on a platform where the cleaner object's register method handle was resolved but invocation fails (signature mismatch, access restriction, cleaner already shut down).","commonSituations":"Exotic JDK builds, cleaner instance shutdown during JVM exit, instrumentation/security tooling interfering with reflection into internals.","solutions":["Catch this RuntimeException at the registration site and fall back to explicit close-based cleanup.","Run on a standard supported OpenJDK build.","Upgrade Druid so its reflective cleaner wiring matches your JDK."],"exampleFix":"// before\nCleaners.register(obj, action); // throws RuntimeException on failure\n// after\ntry {\n  Cleaners.register(obj, action);\n} catch (RuntimeException e) {\n  LOG.warn(e, \"cleaner registration failed; relying on explicit close\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Cleaners.register(obj, action);\n} catch (RuntimeException e) {\n  // registration failed; ensure action also runs via close()\n}","preventionTips":["Always have a non-cleaner cleanup path","Don't register cleaners during JVM shutdown","Run on mainstream OpenJDK builds"],"tags":["jvm","reflection","memory-cleanup"],"backgroundTag":"unsupported-platform","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"}