{"record":{"id":"aa2e04c6d95921c7","repo":"apache/druid","slug":"unmapping-is-not-supported-on-this-platform-becau","errorCode":null,"errorMessage":"Unmapping is not supported on this platform, because internal Java APIs are not compatible with this Druid version","messagePattern":"Unmapping is not supported 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/ByteBufferUtils.java","lineNumber":97,"sourceCode":"    }\n    catch (Throwable throwable) {\n      throw new RuntimeException(\"Unable to unmap the mapped buffer\", throwable);\n    }\n  }\n\n  private static MethodHandle lookupUnmapMethodHandle()\n  {\n    final MethodHandles.Lookup lookup = MethodHandles.lookup();\n    try {\n      MethodHandle unmapper = lookup.findVirtual(\n          UnsafeUtils.theUnsafeClass(),\n          \"invokeCleaner\",\n          MethodType.methodType(void.class, ByteBuffer.class)\n      );\n      return unmapper.bindTo(UnsafeUtils.theUnsafe());\n    }\n    catch (ReflectiveOperationException | RuntimeException e1) {\n      throw new UnsupportedOperationException(\"Unmapping is not supported on this platform, because internal \" +\n                                              \"Java APIs are not compatible with this Druid version\", e1);\n    }\n  }\n\n  /**\n   * Same as {@link ByteBuffer#allocateDirect(int)}, but returns a closeable {@link ResourceHolder} that\n   * frees the buffer upon close.\n   *\n   * Direct (off-heap) buffers are an alternative to on-heap buffers that allow memory to be managed\n   * outside the purview of the garbage collector. It's most useful when allocating big chunks of memory,\n   * like processing buffers.\n   *\n   * Holders cannot be closed more than once. Attempting to close a holder twice will earn you an\n   * {@link IllegalStateException}.\n   */\n  public static ResourceHolder<ByteBuffer> allocateDirect(final int size)\n  {\n    class DirectByteBufferHolder implements ResourceHolder<ByteBuffer>","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/ByteBufferUtils.java#L79-L115","documentation":"ByteBufferUtils.lookupUnmapMethodHandle resolves sun.misc.Unsafe.invokeCleaner via reflection to unmap direct ByteBuffers. On a JVM whose internal APIs do not provide this method (or block reflective access to it), it wraps the failure in this UnsupportedOperationException. Memory-mapped buffer unmapping is therefore unavailable on the current platform/JDK.","triggerScenarios":"Calling ByteBufferUtils unmap methods (e.g. on mapped MappedByteBuffers) on a JDK lacking Unsafe.invokeCleaner, or a JDK where reflection into sun.misc.Unsafe is denied (module restrictions, non-HotSpot JVMs like J9/openj9 historically, exotic JDK builds).","commonSituations":"Running Druid on a non-standard JVM or a very new/locked-down JDK where sun.misc.Unsafe access is restricted; container images with unusual Java distributions; calling unmapping helpers in custom extensions on such JVMs.","solutions":["Run on a supported OpenJDK/HotSpot build where sun.misc.Unsafe.invokeCleaner exists (JDK 9+ standard builds).","If your code calls unmap, guard with try/catch on UnsupportedOperationException and rely on GC to reclaim buffers.","Check --add-opens java.base/jdk.internal.misc and similar JVM flags if module access is the blocker, or switch JVM vendor."],"exampleFix":"// before\nByteBufferUtils.unmap(mappedBuffer);\n// after\ntry {\n  ByteBufferUtils.unmap(mappedBuffer);\n} catch (UnsupportedOperationException e) {\n  // platform cannot unmap explicitly; buffer reclaimed by GC\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  ByteBufferUtils.unmap(buffer);\n} catch (UnsupportedOperationException e) {\n  // platform cannot unmap; rely on GC\n}","preventionTips":["Use standard HotSpot OpenJDK builds","Avoid stripping or locking down sun.misc.Unsafe access","Make unmap best-effort in your code paths"],"tags":["jvm","reflection","platform","memory"],"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"}