Skip to content

Commit

Permalink
#10226 - fix dumpHeap() compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Aug 23, 2023
1 parent 4d0435d commit 93fb4b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.eclipse.jetty.fcgi.server;

import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -22,7 +21,6 @@
import java.util.stream.Stream;
import javax.management.MBeanServer;

import com.sun.management.HotSpotDiagnosticMXBean;
import org.awaitility.Awaitility;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
Expand Down Expand Up @@ -117,7 +115,7 @@ public void dispose(TestInfo testInfo) throws Exception
}
}

private static void dumpHeap(String testMethodName) throws IOException
private static void dumpHeap(String testMethodName) throws Exception
{
Path targetDir = Path.of("target/leaks");
if (Files.exists(targetDir))
Expand All @@ -133,8 +131,9 @@ private static void dumpHeap(String testMethodName) throws IOException
String dumpName = targetDir.resolve(testMethodName + ".hprof").toString();

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean mxBean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
mxBean.dumpHeap(dumpName, true);
Class<?> mxBeanClass = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
Object mxBean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", mxBeanClass);
mxBeanClass.getMethod("dumpHeap", String.class, boolean.class).invoke(mxBean, dumpName, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.eclipse.jetty.test.client.transport;

import java.io.IOException;
import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.net.URI;
Expand All @@ -28,7 +27,6 @@
import java.util.stream.Stream;
import javax.management.MBeanServer;

import com.sun.management.HotSpotDiagnosticMXBean;
import org.awaitility.Awaitility;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.client.HttpClient;
Expand Down Expand Up @@ -158,7 +156,7 @@ public void dispose(TestInfo testInfo) throws Exception
}
}

private static void dumpHeap(String testMethodName) throws IOException
private static void dumpHeap(String testMethodName) throws Exception
{
Path targetDir = Path.of("target/leaks");
if (Files.exists(targetDir))
Expand All @@ -174,9 +172,10 @@ private static void dumpHeap(String testMethodName) throws IOException
String dumpName = targetDir.resolve(testMethodName + ".hprof").toString();

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean mxBean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
mxBean.dumpHeap(dumpName, true);
Class<?> mxBeanClass = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
Object mxBean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", mxBeanClass);
mxBeanClass.getMethod("dumpHeap", String.class, boolean.class).invoke(mxBean, dumpName, true);
}

protected void start(Transport transport, Handler handler) throws Exception
Expand Down

0 comments on commit 93fb4b3

Please sign in to comment.