Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public String[] getConnectionIds() {
* one new connection to this connector server.</p>
*
* <p>A given connector need not support the generation of client
* stubs. However, the connectors specified by the JMX Remote API do
* (JMXMP Connector and RMI Connector).</p>
* stubs. The RMI Connector does so.</p>
*
* <p>The default implementation of this method uses {@link
* #getAddress} and {@link JMXConnectorFactory} to generate the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ public interface JMXConnectorServerMBean {
* one new connection to this connector server.</p>
*
* <p>A given connector need not support the generation of client
* stubs. However, the connectors specified by the JMX Remote API do
* (JMXMP Connector and RMI Connector).</p>
* stubs. The RMI Connector does so.</p>
*
* @param env client connection parameters of the same sort that
* can be provided to {@link JMXConnector#connect(Map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ public JMXServiceURL(String serviceURL) throws MalformedURLException {
* {@link #JMXServiceURL(String, String, int, String)
* JMXServiceURL(protocol, host, port, null)}.</p>
*
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
* @param protocol the protocol part of the URL. Must be specified,
* there is no default.
*
* @param host the host part of the URL. If host is null and if
* local host name can be resolved to an IP, then host defaults
Expand All @@ -255,7 +255,7 @@ public JMXServiceURL(String serviceURL) throws MalformedURLException {
* @exception MalformedURLException if one of the parts is
* syntactically incorrect, or if <code>host</code> is null and it
* is not possible to find the local host name, or if
* <code>port</code> is negative.
* <code>port</code> is negative, or if protocol is null.
*/
public JMXServiceURL(String protocol, String host, int port)
throws MalformedURLException {
Expand All @@ -265,8 +265,8 @@ public JMXServiceURL(String protocol, String host, int port)
/**
* <p>Constructs a <code>JMXServiceURL</code> with the given parts.
*
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
* @param protocol the protocol part of the URL. Must be specified,
* there is no default.
*
* @param host the host part of the URL. If host is null and if
* local host name can be resolved to an IP, then host defaults
Expand All @@ -285,14 +285,14 @@ public JMXServiceURL(String protocol, String host, int port)
* @exception MalformedURLException if one of the parts is
* syntactically incorrect, or if <code>host</code> is null and it
* is not possible to find the local host name, or if
* <code>port</code> is negative.
* <code>port</code> is negative, or if protocol is null.
*/
public JMXServiceURL(String protocol, String host, int port,
String urlPath)
throws MalformedURLException {
if (protocol == null)
protocol = "jmxmp";

if (protocol == null) {
throw new MalformedURLException("Misssing protocol name");
}
if (host == null) {
InetAddress local;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8347114
* @summary Test JMXServiceURL does not accept a null protocol
*
* @run main JMXServiceURLProtocol
*/

import java.net.MalformedURLException;
import javax.management.remote.JMXServiceURL;

public class JMXServiceURLProtocol {

public static void main(String[] args) throws Exception {

try {
JMXServiceURL u = new JMXServiceURL("service:jmx:://");
String proto = u.getProtocol();
System.out.println("JMXServiceURL(String) with null protocol gets: " + u + " protocol: " + proto);
throw new RuntimeException("JMXServiceURL created using null protocol: " + u);
} catch (MalformedURLException e) {
System.out.println("JMXServiceURL with null protocol causes expected: " + e);
}

try {
JMXServiceURL u = new JMXServiceURL(null, "localhost", 1234);
String proto = u.getProtocol();
System.out.println("JMXServiceURL(params) with null protocol gets: " + u + " protocol: " + proto);
throw new RuntimeException("JMXServiceURL created using null protocol: " + u);
} catch (MalformedURLException e) {
System.out.println("JMXServiceURL with null protocol causes expected: " + e);
}

}
}