src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerCollectionResource.java
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerCollectionResource.java Tue Jan 02 15:03:52 2018 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerCollectionResource.java Thu Jan 04 14:39:04 2018 +0530
@@ -33,6 +33,8 @@
import javax.management.remote.rest.PlatformRestAdapter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@@ -57,9 +59,16 @@
if (filteredList == null) {
return HttpResponse.OK;
}
-
- final String path = PlatformRestAdapter.getDomain() +
- exchange.getRequestURI().getPath().replaceAll("/$", "");
+ String query = exchange.getRequestURI().getQuery();
+ if (query != null) {
+ return HttpResponse.BAD_REQUEST;
+ }
+ String exchangePath = URLDecoder.decode(exchange.getRequestURI().getPath(), StandardCharsets.UTF_8.displayName())
+ .replaceAll("/$", "");
+ if (!exchangePath.equalsIgnoreCase("/jmx/servers")) {
+ return HttpResponse.REQUEST_NOT_FOUND;
+ }
+ final String path = PlatformRestAdapter.getDomain() + exchangePath;
JSONObject root = new JSONObject();
if (_links != null && !_links.isEmpty()) {