Skip to content

Commit ea7186a

Browse files
GennadiyKrivosheinDmitry Chuyko
authored andcommitted
8020207: jconsole fails connecting over SSL using service:jmx:rmi://...jndi...
Reviewed-by: kevinw
1 parent a0c4124 commit ea7186a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/jdk.jconsole/share/classes/sun/tools/jconsole/ProxyClient.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
3434
import static java.lang.management.ManagementFactory.*;
3535
import java.lang.ref.WeakReference;
3636
import java.lang.reflect.*;
37+
import java.net.URI;
3738
import java.rmi.*;
3839
import java.rmi.registry.*;
3940
import java.rmi.server.*;
@@ -133,7 +134,24 @@ private ProxyClient(String url,
133134
this.advancedUrl = url;
134135
this.connectionName = getConnectionName(url, userName);
135136
this.displayName = connectionName;
136-
setParameters(new JMXServiceURL(url), userName, password);
137+
JMXServiceURL jmxServiceURL = new JMXServiceURL(url);
138+
setParameters(jmxServiceURL, userName, password);
139+
if ("rmi".equals(jmxServiceURL.getProtocol())) {
140+
String path = jmxServiceURL.getURLPath();
141+
if (path.startsWith("/jndi/")) {
142+
int end = path.indexOf(';');
143+
if (end < 0) end = path.length();
144+
String registryURIStr = path.substring(6, end);
145+
URI registryURI = URI.create(registryURIStr);
146+
if ("rmi".equals(registryURI.getScheme())
147+
&& "/jmxrmi".equals(registryURI.getPath())) {
148+
this.registryHostName = registryURI.getHost();
149+
this.registryPort = registryURI.getPort();
150+
this.vmConnector = true;
151+
checkSslConfig();
152+
}
153+
}
154+
}
137155
}
138156

139157
private ProxyClient(LocalVirtualMachine lvm) throws IOException {

0 commit comments

Comments
 (0)