{"record":{"id":"5aef57619b2b753e","repo":"apache/druid","slug":"cleaner-not-supported-exception","errorCode":"CLEANER_NOT_SUPPORTED_EXCEPTION","errorMessage":"Cleaning is not support on this platform, because internal Java APIs are not compatible with this Druid version","messagePattern":"Cleaning is not support on this platform, because internal Java APIs are not compatible with this Druid version","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java","lineNumber":100,"sourceCode":"    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    }\n\n    return CLEANER.register(object, runnable);\n  }\n\n  private static class CleanerImpl implements Cleaner\n  {\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)","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java#L82-L118","documentation":"Cleaners.register throws this UnsupportedOperationException when the CLEANER static handle is null, i.e. the platform never successfully initialized a cleaner. The constant CLEANER_NOT_SUPPORTED_EXCEPTION carries the same 'internal Java APIs are not compatible' message, telling callers that explicit cleanup action registration is unavailable.","triggerScenarios":"Any call to Cleaners.register(object, runnable) after Cleaners failed to initialize (takeMeToTheCleaners threw, leaving CLEANER null), which happens on JVMs with incompatible internal cleaning APIs.","commonSituations":"Running on non-standard JVMs or locked-down JDKs (see related init failures); using Cleaners-based resource management in extensions deployed to such runtimes.","solutions":["Check Cleaners.isAssigned() (or equivalent) before registering cleaning actions and skip registration when unsupported.","Ensure your cleanup logic also runs via explicit close paths, not only via cleaners.","Run on a supported JDK so the cleaner initializes."],"exampleFix":"// before\nCleaners.register(obj, cleanup);\n// after\nif (Cleaners.isAssigned()) {\n  Cleaners.register(obj, cleanup);\n} else {\n  // cleanup handled by close()/GC\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean canRegisterCleaner() { return Cleaners.isAssigned(); }","tryCatchPattern":"try {\n  Cleaners.register(obj, action);\n} catch (UnsupportedOperationException e) {\n  // CLEANER not initialized; fall back\n}","preventionTips":["Check cleaner availability before depending on it","Pair cleaner-based cleanup with explicit close() lifecycle","Avoid non-standard JVMs"],"tags":["jvm","memory-cleanup","platform","reflection"],"backgroundTag":"operation-not-supported","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"}