apache/druid · error · java.lang.RuntimeException

Unable to register cleaning action

Error message

Unable to register cleaning action

What it means

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.

Solutions

  1. Catch this RuntimeException at the registration site and fall back to explicit close-based cleanup.
  2. Run on a standard supported OpenJDK build.
  3. Upgrade Druid so its reflective cleaner wiring matches your JDK.

Example fix

// before
Cleaners.register(obj, action); // throws RuntimeException on failure
// after
try {
  Cleaners.register(obj, action);
} catch (RuntimeException e) {
  LOG.warn(e, "cleaner registration failed; relying on explicit close");
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  Cleaners.register(obj, action);
} catch (RuntimeException e) {
  // registration failed; ensure action also runs via close()
}

Prevention

When it happens

Trigger: 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).

Common situations: Exotic JDK builds, cleaner instance shutdown during JVM exit, instrumentation/security tooling interfering with reflection into internals.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/be778f86a07edd63. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/java/util/common/Cleaners.java:125

  {
    private final MethodHandle register;
    private final MethodHandle clean;

    private CleanerImpl(MethodHandle register, MethodHandle clean)
    {
      this.register = register;
      this.clean = clean;
    }

    @Override
    public Cleanable register(Object object, Runnable runnable)
    {
      try {
        Object cleanable = (Object) register.invoke(object, runnable);
        return createCleanable(clean, cleanable);
      }
      catch (Throwable t) {
        throw new RuntimeException("Unable to register cleaning action", t);
      }
    }

    private static Cleanable createCleanable(MethodHandle clean, Object cleanable)
    {
      return () -> {
        try {
          clean.invoke(cleanable);
        }
        catch (Throwable t) {
          throw new RuntimeException("Unable to run cleaning action", t);
        }
      };
    }
  }
}

View on GitHub (pinned to 9b90983fd2)