{"record":{"id":"e1dc5dcf10c046a0","repo":"apache/druid","slug":"cleaning-is-not-support-on-this-platform-because","errorCode":null,"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":66,"sourceCode":"      exception = e;\n    }\n    if (cleaner != null) {\n      CLEANER = cleaner;\n      CLEANER_NOT_SUPPORTED_EXCEPTION = null;\n    } else {\n      CLEANER = null;\n      CLEANER_NOT_SUPPORTED_EXCEPTION = exception;\n    }\n  }\n\n  private static Cleaner takeMeToTheCleaners()\n  {\n    final MethodHandles.Lookup lookup = MethodHandles.lookup();\n    try {\n      return lookupCleaner(lookup);\n    }\n    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    }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java#L48-L84","documentation":"Cleaners.takeMeToTheCleaners builds a Cleaner abstraction over JDK internals (java.lang.ref.Cleaner on 9+, or a Java 8 fallback). If no compatible cleaning API can be found via reflection, it throws this UnsupportedOperationException. Buffer cleaning (eager deallocation) is unsupported on the current JVM.","triggerScenarios":"Static initialization of Cleaners on a JVM where neither jdk.internal.ref.Cleaner (Java 9+ path) nor the Java 8 sun.misc path can be resolved, e.g. non-HotSpot JVMs, heavily restricted module settings, or stripped JDK images.","commonSituations":"Running Druid on unusual/locked-down Java runtimes; custom minimal JRE images (jlink) missing java.base internals; JVM vendors blocking deep reflection; the first use of Cleaners-dependent code triggering static init.","solutions":["Run on a standard, supported HotSpot OpenJDK (8 or 11+ per Druid's compatibility matrix).","Avoid --illegal-access=deny style flags or remove module restrictions blocking jdk.internal.ref access.","Catch UnsupportedOperationException at call sites (see Cleaners.register) and fall back to GC-based cleanup."],"exampleFix":"// before\nCleaners.register(obj, cleanupRunnable);\n// after\ntry {\n  Cleaners.register(obj, cleanupRunnable);\n} catch (UnsupportedOperationException e) {\n  // cleaner unsupported; cleanup happens at GC\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Cleanable c = Cleaners.register(obj, action);\n} catch (UnsupportedOperationException e) {\n  // cleaner unsupported on this JVM; rely on GC/close\n}","preventionTips":["Pin deployments to supported JDK vendors/versions","Avoid jlink images that drop java.base internals","Never rely solely on cleaners for correctness of cleanup"],"tags":["jvm","reflection","platform","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"}