浏览代码

移除对sun.misc的依赖

hujie 1 年之前
父节点
当前提交
0ae612f1bb
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      cn.com.taiji.system/src/main/java/cn/com/taiji/util/bigfile/FileMD5Util.java

+ 5 - 3
cn.com.taiji.system/src/main/java/cn/com/taiji/util/bigfile/FileMD5Util.java

@@ -74,9 +74,11 @@ public class FileMD5Util {
                     try {
                     try {
                         Method getCleanerMethod = mappedByteBuffer.getClass().getMethod("cleaner", new Class[0]);
                         Method getCleanerMethod = mappedByteBuffer.getClass().getMethod("cleaner", new Class[0]);
                         getCleanerMethod.setAccessible(true);
                         getCleanerMethod.setAccessible(true);
-                        sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(mappedByteBuffer,
-                                new Object[0]);
-                        cleaner.clean();
+                        Object cleaner = getCleanerMethod.invoke(mappedByteBuffer);
+                        if (cleaner != null) {
+                            Method cleanMethod = cleaner.getClass().getMethod("clean");
+                            cleanMethod.invoke(cleaner);
+                        }
                     } catch (Exception e) {
                     } catch (Exception e) {
                         logger.error("clean MappedByteBuffer error!!!", e);
                         logger.error("clean MappedByteBuffer error!!!", e);
                     }
                     }