Github user jasobrown commented on a diff in the pull request: https://github.com/apache/cassandra/pull/236#discussion_r204370957 --- Diff: src/java/org/apache/cassandra/io/util/FileUtils.java --- @@ -350,13 +396,38 @@ public static String getRelativePath(String basePath, String path) public static void clean(ByteBuffer buffer) { - if (buffer == null) + if (buffer == null || !buffer.isDirect()) return; - if (isCleanerAvailable && buffer.isDirect()) + + // TODO Once we can get rid of Java 8, it's simpler to call sun.misc.Unsafe.invokeCleaner(ByteBuffer), + // but need to take care of the attachment handling (i.e. whether 'buf' is a duplicate or slice) - that + // is different in sun.misc.Unsafe.invokeCleaner and this implementation. + + try { - DirectBuffer db = (DirectBuffer) buffer; - if (db.cleaner() != null) - db.cleaner().clean(); + if (buffer.isDirect()) + { + Object cleaner = mhDirectBufferCleaner.bindTo(buffer).invoke(); --- End diff -- Can you add some comments here? It's not clear what's going on, but more importantly, why there's two code paths.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org