浏览代码

fix #I2AQ2M

Looly 5 年之前
父节点
当前提交
e02abaf128

+ 2 - 1
CHANGELOG.md

@@ -3,7 +3,7 @@
 
 -------------------------------------------------------------------------------------------------------------
 
-# 5.5.5 (2020-12-24)
+# 5.5.5 (2020-12-27)
 
 ### 新特性
 * 【core   】     URLUtil.normalize新增重载(pr#233@Gitee)
@@ -19,6 +19,7 @@
 * 【core   】     TreeUtil增加空判定(issue#I2ACCW@Gitee)
 * 【db     】     解决Hive获取表名失败问题(issue#I2AGLU@Gitee)
 * 【core   】     修复DateUtil.parse未使用严格模式导致结果不正常的问题(issue#1332@Github)
+* 【core   】     修复RuntimeUtil.getUsableMemory非static问题(issue#I2AQ2M@Gitee)
 
 -------------------------------------------------------------------------------------------------------------
 # 5.5.4 (2020-12-16)

+ 1 - 1
hutool-core/src/main/java/cn/hutool/core/util/RuntimeUtil.java

@@ -298,7 +298,7 @@ public class RuntimeUtil {
 	 *
 	 * @return 最大可用内存
 	 */
-	public final long getUsableMemory() {
+	public static long getUsableMemory() {
 		return getMaxMemory() - getTotalMemory() + getFreeMemory();
 	}
 }

+ 7 - 3
hutool-core/src/test/java/cn/hutool/core/util/RuntimeUtilTest.java

@@ -1,11 +1,10 @@
 package cn.hutool.core.util;
 
+import cn.hutool.core.lang.Console;
+import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import cn.hutool.core.lang.Console;
-import cn.hutool.core.util.RuntimeUtil;
-
 /**
  * 命令行单元测试
  * @author looly
@@ -26,4 +25,9 @@ public class RuntimeUtilTest {
 		String str = RuntimeUtil.execForStr("cmd /c dir");
 		Console.log(str);
 	}
+
+	@Test
+	public void getUsableMemoryTest(){
+		Assert.assertTrue(RuntimeUtil.getUsableMemory() > 0);
+	}
 }