mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
JDK-8176055: Fix heap dumps on Java 8u141+
In Java 8u141 (1.8.0_141-b15) and newer, the com.sun.management.HotSpotDiagnostic::dumpHeap API has changed and now requires all heap dumps to end with the .hprof file extension. Before this change, servers running 8u141 would be unable to perform a heap dump. For more information, please see the official release notes of Java 8 Update 141, linked below. http://www.oracle.com/technetwork/java/javase/8u141-relnotes-3720385.html
This commit is contained in:
parent
4265551308
commit
160d1ee3f1
4 changed files with 16 additions and 10 deletions
|
@ -20,7 +20,7 @@ index 28917f63d..f4b237034 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 6dba269e7..3e5421932 100644
|
||||
index 3d484fbcf..3c6f46057 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
|
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Allow Reloading of Command Aliases
|
|||
Reload the aliases stored in commands.yml
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 5a9555135..6dba269e7 100644
|
||||
index 37dc16186..3d484fbcf 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
|
|
|
@ -6,11 +6,11 @@ Subject: [PATCH] Allow Reloading of Custom Permissions
|
|||
https://github.com/PaperMC/Paper/issues/49
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 815a26284..7a2c19159 100644
|
||||
index 3007a724b..e8b8e86e8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
Bukkit.getLogger().severe("Could not write heap to " + file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+
|
||||
|
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Paper config files
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
new file mode 100644
|
||||
index 000000000..cd67ab2bb
|
||||
index 000000000..5cdf4bbf4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
@ -62,10 +62,13 @@ index 000000000..cd67ab2bb
|
|||
+
|
||||
+ private void dumpHeap(CommandSender sender) {
|
||||
+ File file = new File(new File(new File("."), "dumps"),
|
||||
+ "heap-dump-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + "-server.bin");
|
||||
+ "heap-dump-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + "-server.hprof");
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Writing JVM heap data to " + file);
|
||||
+ CraftServer.dumpHeap(file);
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Heap dump complete");
|
||||
+ if (CraftServer.dumpHeap(file)) {
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Heap dump complete");
|
||||
+ } else {
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed to write heap dump, see sever log for details");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void doReload(CommandSender sender) {
|
||||
|
@ -370,7 +373,7 @@ index f5d387511..fd204ad7a 100644
|
|||
this.world = new CraftWorld((WorldServer) this, gen, env);
|
||||
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e21fb9bd7..d7af2c00f 100644
|
||||
index e21fb9bd7..dd50d5c56 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
|
@ -404,7 +407,7 @@ index e21fb9bd7..d7af2c00f 100644
|
|||
+
|
||||
+ // Paper start
|
||||
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
+ public static void dumpHeap(File file) {
|
||||
+ public static boolean dumpHeap(File file) {
|
||||
+ try {
|
||||
+ if (file.getParentFile() != null) {
|
||||
+ file.getParentFile().mkdirs();
|
||||
|
@ -415,8 +418,11 @@ index e21fb9bd7..d7af2c00f 100644
|
|||
+ Object hotspotMBean = java.lang.management.ManagementFactory.newPlatformMXBeanProxy(server, "com.sun.management:type=HotSpotDiagnostic", clazz);
|
||||
+ java.lang.reflect.Method m = clazz.getMethod("dumpHeap", String.class, boolean.class);
|
||||
+ m.invoke(hotspotMBean, file.getPath(), true);
|
||||
+ return true;
|
||||
+ } catch (Throwable t) {
|
||||
+ Bukkit.getLogger().severe("Could not write heap to " + file);
|
||||
+ t.printStackTrace();
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
|
Loading…
Reference in a new issue