Lot of bug fixes jmx-rest-api
authorhb
Mon, 01 Jan 2018 23:59:14 +0530
branchjmx-rest-api
changeset 56002 60ab3b595a8e
parent 56001 95c0323f0c1a
child 56003 4f7f76f6be2f
Lot of bug fixes Added test cases
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/HttpUtil.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/RestResource.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/JSONPrimitive.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParser.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserConstants.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserTokenManager.java
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JsonParser.jj
src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/mapper/JSONMappingFactory.java
src/java.management.rest/share/classes/javax/management/remote/rest/PlatformRestAdapter.java
test/jdk/javax/management/remote/rest/DefaultRestAdapter.java
test/jdk/javax/management/remote/rest/JsonParserTest.java
test/jdk/javax/management/remote/rest/PlatformAdapterTest.java
test/jdk/javax/management/remote/rest/PlatformMBeanTest.java
test/jdk/javax/management/remote/rest/RestAdapterConfigTest.java
test/jdk/javax/management/remote/rest/RestAdapterPerfTest.java
test/jdk/javax/management/remote/rest/RestAdapterSSLTest.java
test/jdk/javax/management/remote/rest/RestAdapterTest.java
test/jdk/javax/management/remote/rest/RunRestAdapter.java
test/jdk/javax/management/remote/rest/data/QueueSample.java
test/jdk/javax/management/remote/rest/data/QueueSampler.java
test/jdk/javax/management/remote/rest/data/QueueSamplerBean.java
test/jdk/javax/management/remote/rest/data/QueueSamplerBeanMBean.java
test/jdk/javax/management/remote/rest/data/QueueSamplerMXBean.java
test/jdk/javax/management/remote/rest/json/JSONTest.java
test/jdk/javax/management/remote/rest/json/JsonParserTest.java
test/jdk/javax/management/remote/rest/json/JsonTester.java
test/jdk/javax/management/remote/rest/management.properties
test/jdk/javax/management/remote/rest/management.properties.template
test/jdk/javax/management/remote/rest/management1.properties
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/HttpUtil.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/HttpUtil.java	Mon Jan 01 23:59:14 2018 +0530
@@ -104,7 +104,9 @@
         String[] params = query.trim().split("&");
         for (String param : params) {
             int idx = param.indexOf('=');
-            queryParams.put(param.substring(0, idx), param.substring(idx + 1));
+            if(idx != -1) {
+                queryParams.put(param.substring(0, idx), param.substring(idx + 1));
+            }
         }
         return queryParams;
     }
@@ -224,7 +226,6 @@
             URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
             return uri.toURL().toString();
         } catch (Exception ex) {
-            ex.printStackTrace();
             return null;
         }
     }
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanCollectionResource.java	Mon Jan 01 23:59:14 2018 +0530
@@ -166,6 +166,19 @@
         try {
             List<ObjectName> filteredMBeans = allowedMbeans;
             Map<String, String> queryMap = HttpUtil.getGetRequestQueryMap(exchange);
+            String query = exchange.getRequestURI().getQuery();
+            if(query != null && queryMap.isEmpty()) {
+                return new HttpResponse(HttpResponse.BAD_REQUEST,
+                        "Invalid query params : Allowed query keys [query,page]");
+            }else if(query != null && !queryMap.isEmpty()) {
+                Map<String, String> newMap = new HashMap<>(queryMap);
+                newMap.remove("query");
+                newMap.remove("page");
+                if(!newMap.isEmpty()) { // Invalid query params
+                    return new HttpResponse(HttpResponse.BAD_REQUEST,
+                            "Invalid query params : Allowed query keys [query,page]");
+                }
+            }
             if (queryMap.containsKey("query")) {        // Filter based on ObjectName query
                 Set<ObjectName> queryMBeans = mBeanServer
                         .queryNames(new ObjectName(queryMap.get("query")), null);
@@ -174,10 +187,10 @@
             }
 
             JSONObject _links = HttpUtil.getPaginationLinks(exchange, filteredMBeans, pageSize);
-            filteredMBeans = HttpUtil.filterByPage(exchange, filteredMBeans, pageSize);
+            List<ObjectName> mbeanPage = HttpUtil.filterByPage(exchange, filteredMBeans, pageSize);
 
             List<Map<String, String>> items = new ArrayList<>(filteredMBeans.size());
-            filteredMBeans.forEach(objectName -> {
+            mbeanPage.forEach(objectName -> {
                 Map<String, String> item = new LinkedHashMap<>(2);
                 item.put("name", objectName.toString());
                 String href = path + "/" + objectName.toString();
@@ -188,7 +201,7 @@
 
             Map<String, String> properties = new HashMap<>();
 
-            properties.put("mbeanCount", Integer.toString(allowedMbeans.size()));
+            properties.put("mbeanCount", Integer.toString(filteredMBeans.size()));
 
             JSONMapper typeMapper1 = JSONMappingFactory.INSTANCE.getTypeMapper(items);
             JSONMapper typeMapper2 = JSONMappingFactory.INSTANCE.getTypeMapper(properties);
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/MBeanServerResource.java	Mon Jan 01 23:59:14 2018 +0530
@@ -58,6 +58,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 
 public final class MBeanServerResource implements RestResource, JmxRestAdapter {
@@ -78,12 +79,12 @@
     // Use an expiring map that removes entries after the configured period lapses.
     private final TimedMap<String, MBeanCollectionResource> proxyMBeanServers = new TimedMap<>(5*60);
 
-    private static int count = 0;
+    private static AtomicInteger resourceNumber = new AtomicInteger(1);
     private boolean started = false;
 
     public MBeanServerResource(HttpServer hServer, MBeanServer mbeanServer,
                                String context, Map<String, ?> env) {
-        httpServer = hServer;
+        this.httpServer = hServer;
         this.env = env;
         this.mbeanServer = mbeanServer;
 
@@ -91,7 +92,7 @@
                 MBeanServerDelegate.DELEGATE_NAME, MBeanServerDelegateMBean.class);
 
         if (context == null || context.isEmpty()) {
-            contextStr = "server-" + count++;
+            contextStr = "server-" + resourceNumber.getAndIncrement();
         } else {
             contextStr = context;
         }
@@ -306,6 +307,7 @@
 
         public TimedMap(int seconds) {
             this.timeout = seconds;
+            permanentMap = new ConcurrentHashMap<>();
         }
 
         public boolean containsKey(K key) {
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/RestResource.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/RestResource.java	Mon Jan 01 23:59:14 2018 +0530
@@ -36,7 +36,7 @@
  */
 public interface RestResource extends HttpHandler {
     @Override
-    public default void handle (HttpExchange exchange) throws IOException {
+    public default void handle(HttpExchange exchange) throws IOException {
         HttpResponse httpResponse = HttpResponse.METHOD_NOT_ALLOWED;
         switch (exchange.getRequestMethod()) {
             case "GET":
@@ -90,7 +90,7 @@
         return HttpResponse.METHOD_NOT_ALLOWED;
     }
 
-    public default HttpResponse doConnect (HttpExchange exchange) {
+    public default HttpResponse doConnect(HttpExchange exchange) {
         return HttpResponse.METHOD_NOT_ALLOWED;
     }
 
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/JSONPrimitive.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/JSONPrimitive.java	Mon Jan 01 23:59:14 2018 +0530
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package com.oracle.jmx.remote.rest.json;
 
 /**
@@ -45,80 +44,24 @@
     }
 
     public JSONPrimitive(String s) {
-        value = s != null ? unescape(s) : s;
-    }
-
-    public JSONPrimitive() {
-        value = null;
+        value = s;
     }
 
     public static String escape(String s) {
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < s.length(); i++) {
             char ch = s.charAt(i);
-            switch (ch) {
-                case '\\':
+            if (ch == '\\') {
+                if (i < s.length() - 1 && (s.charAt(i + 1) == '\\' || s.charAt(i + 1) == '"')) {
+                    sb.append(ch).append(s.charAt(i + 1));
+                    i++;
+                } else {
                     sb.append("\\\\");
-                    break;
-                case '\b':
-                    sb.append("\\b");
-                    break;
-                case '\f':
-                    sb.append("\\f");
-                    break;
-                case '\n':
-                    sb.append("\\n");
-                    break;
-                case '\r':
-                    sb.append("\\r");
-                    break;
-                case '\t':
-                    sb.append("\\t");
-                    break;
-                case '"':
-                    sb.append("\\\"");
-                    break;
-                default:
-                    sb.append(s.charAt(i));
-            }
-        }
-        return sb.toString();
-    }
-
-    public static String unescape(String s) {
-        StringBuilder sb = new StringBuilder(s.length());
-        for (int i = 0; i < s.length(); ++i) {
-            if (s.charAt(i) == '\\') {
-                if (i + 1 < s.length() - 1) {
-                    ++i;
-                    switch (s.charAt(i)) {
-                        case '\\':
-                            sb.append('\\');
-                            break;
-                        case '\b':
-                            sb.append('\b');
-                            break;
-                        case '\f':
-                            sb.append('\f');
-                            break;
-                        case '\n':
-                            sb.append('\n');
-                            break;
-                        case '\r':
-                            sb.append('\r');
-                            break;
-                        case '\t':
-                            sb.append('\t');
-                            break;
-                        case '\"':
-                            sb.append('\"');
-                            break;
-                        default:
-                            sb.append(s.charAt(i));
-                    }
                 }
+            } else if (ch == '"') {
+                sb.append("\\\"");
             } else {
-                sb.append(s.charAt(i));
+                sb.append(ch);
             }
         }
         return sb.toString();
@@ -135,4 +78,43 @@
         }
         return value != null ? value.toString() : null;
     }
+
+    @Override
+    public int hashCode() {
+        if (value instanceof String) {
+            return ((String) value).hashCode();
+        } else if (value instanceof Long) {
+            return ((Long) value).hashCode();
+        } else if (value instanceof Double) {
+            return ((Double) value).hashCode();
+        } else if (value instanceof Boolean) {
+            return ((Boolean) value).hashCode();
+        } else {
+            return super.hashCode();
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+
+        if (!(obj instanceof JSONPrimitive)) {
+            return false;
+        }
+
+        JSONPrimitive o = (JSONPrimitive) obj;
+
+        if (value == null && o.getValue() == null) {
+            return true;
+        }
+
+        if (value != null && o.getValue() != null) {
+            if (value.getClass().equals(o.getValue().getClass())) {
+                return value.equals(o.getValue());
+            }
+        }
+        return false;
+    }
 }
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParser.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParser.java	Mon Jan 01 23:59:14 2018 +0530
@@ -16,11 +16,11 @@
 
   final public JSONElement jsonValue() throws ParseException {
         JSONElement x;
-    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-    case 17:
+    switch (jj_nt.kind) {
+    case 16:
       x = object();
       break;
-    case 21:
+    case 20:
       x = list();
       break;
     case QUOTED_STRING:
@@ -49,50 +49,28 @@
         final JSONObject jobject = new JSONObject();
         JSONPrimitive key;
         JSONElement value;
+    jj_consume_token(16);
+    key = string();
     jj_consume_token(17);
-    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-    case QUOTED_STRING:
-      key = string();
-      break;
-    case IDENTIFIER:
-      key = identifier();
-      break;
-    default:
-      jj_la1[1] = jj_gen;
-      jj_consume_token(-1);
-      throw new ParseException();
-    }
-    jj_consume_token(18);
     value = jsonValue();
           jobject.put((String)key.getValue(), value);
     label_1:
     while (true) {
-      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-      case 19:
+      switch (jj_nt.kind) {
+      case 18:
         ;
         break;
       default:
-        jj_la1[2] = jj_gen;
+        jj_la1[1] = jj_gen;
         break label_1;
       }
-      jj_consume_token(19);
-      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-      case QUOTED_STRING:
-        key = string();
-        break;
-      case IDENTIFIER:
-        key = identifier();
-        break;
-      default:
-        jj_la1[3] = jj_gen;
-        jj_consume_token(-1);
-        throw new ParseException();
-      }
       jj_consume_token(18);
+      key = string();
+      jj_consume_token(17);
       value = jsonValue();
                   jobject.put((String)key.getValue(), value);
     }
-    jj_consume_token(20);
+    jj_consume_token(19);
       {if (true) return jobject;}
     throw new Error("Missing return statement in function");
   }
@@ -100,24 +78,24 @@
   final public JSONArray list() throws ParseException {
     final JSONArray jarray = new JSONArray();
     JSONElement value;
-    jj_consume_token(21);
+    jj_consume_token(20);
     value = jsonValue();
           jarray.add(value);
     label_2:
     while (true) {
-      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-      case 19:
+      switch (jj_nt.kind) {
+      case 18:
         ;
         break;
       default:
-        jj_la1[4] = jj_gen;
+        jj_la1[2] = jj_gen;
         break label_2;
       }
-      jj_consume_token(19);
+      jj_consume_token(18);
       value = jsonValue();
               jarray.add(value);
     }
-    jj_consume_token(22);
+    jj_consume_token(21);
       {if (true) return jarray;}
     throw new Error("Missing return statement in function");
   }
@@ -136,7 +114,7 @@
 
   final public JSONPrimitive number() throws ParseException {
     Token t;
-    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+    switch (jj_nt.kind) {
     case INTEGER_LITERAL:
       t = jj_consume_token(INTEGER_LITERAL);
                              {if (true) return new JSONPrimitive(Long.parseLong(t.image));}
@@ -146,7 +124,7 @@
                                       {if (true) return new JSONPrimitive(Double.parseDouble(t.image));}
       break;
     default:
-      jj_la1[5] = jj_gen;
+      jj_la1[3] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
@@ -160,12 +138,6 @@
     throw new Error("Missing return statement in function");
   }
 
-  final public JSONPrimitive identifier() throws ParseException {
-    jj_consume_token(IDENTIFIER);
-      {if (true) return new JSONPrimitive(token.image);}
-    throw new Error("Missing return statement in function");
-  }
-
   /** Generated Token Manager. */
   public JSONParserTokenManager token_source;
   JavaCharStream jj_input_stream;
@@ -173,15 +145,14 @@
   public Token token;
   /** Next token. */
   public Token jj_nt;
-  private int jj_ntk;
   private int jj_gen;
-  final private int[] jj_la1 = new int[6];
+  final private int[] jj_la1 = new int[4];
   static private int[] jj_la1_0;
   static {
       jj_la1_init_0();
    }
    private static void jj_la1_init_0() {
-      jj_la1_0 = new int[] {0x22e180,0x12000,0x80000,0x12000,0x80000,0x180,};
+      jj_la1_0 = new int[] {0x11e180,0x40000,0x40000,0x180,};
    }
 
   /** Constructor with InputStream. */
@@ -193,9 +164,9 @@
     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
     token_source = new JSONParserTokenManager(jj_input_stream);
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   /** Reinitialise. */
@@ -207,9 +178,9 @@
     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
     token_source.ReInit(jj_input_stream);
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   /** Constructor. */
@@ -217,9 +188,9 @@
     jj_input_stream = new JavaCharStream(stream, 1, 1);
     token_source = new JSONParserTokenManager(jj_input_stream);
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   /** Reinitialise. */
@@ -227,38 +198,38 @@
     jj_input_stream.ReInit(stream, 1, 1);
     token_source.ReInit(jj_input_stream);
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   /** Constructor with generated Token Manager. */
   public JSONParser(JSONParserTokenManager tm) {
     token_source = tm;
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   /** Reinitialise. */
   public void ReInit(JSONParserTokenManager tm) {
     token_source = tm;
     token = new Token();
-    jj_ntk = -1;
+    token.next = jj_nt = token_source.getNextToken();
     jj_gen = 0;
-    for (int i = 0; i < 6; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 4; i++) jj_la1[i] = -1;
   }
 
   private Token jj_consume_token(int kind) throws ParseException {
-    Token oldToken;
-    if ((oldToken = token).next != null) token = token.next;
-    else token = token.next = token_source.getNextToken();
-    jj_ntk = -1;
+    Token oldToken = token;
+    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
+    else jj_nt = jj_nt.next = token_source.getNextToken();
     if (token.kind == kind) {
       jj_gen++;
       return token;
     }
+    jj_nt = token;
     token = oldToken;
     jj_kind = kind;
     throw generateParseException();
@@ -267,9 +238,8 @@
 
 /** Get the next Token. */
   final public Token getNextToken() {
-    if (token.next != null) token = token.next;
-    else token = token.next = token_source.getNextToken();
-    jj_ntk = -1;
+    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
+    else jj_nt = jj_nt.next = token_source.getNextToken();
     jj_gen++;
     return token;
   }
@@ -284,13 +254,6 @@
     return t;
   }
 
-  private int jj_ntk() {
-    if ((jj_nt=token.next) == null)
-      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
-    else
-      return (jj_ntk = jj_nt.kind);
-  }
-
   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
   private int[] jj_expentry;
   private int jj_kind = -1;
@@ -298,12 +261,12 @@
   /** Generate ParseException. */
   public ParseException generateParseException() {
     jj_expentries.clear();
-    boolean[] la1tokens = new boolean[23];
+    boolean[] la1tokens = new boolean[22];
     if (jj_kind >= 0) {
       la1tokens[jj_kind] = true;
       jj_kind = -1;
     }
-    for (int i = 0; i < 6; i++) {
+    for (int i = 0; i < 4; i++) {
       if (jj_la1[i] == jj_gen) {
         for (int j = 0; j < 32; j++) {
           if ((jj_la1_0[i] & (1<<j)) != 0) {
@@ -312,7 +275,7 @@
         }
       }
     }
-    for (int i = 0; i < 23; i++) {
+    for (int i = 0; i < 22; i++) {
       if (la1tokens[i]) {
         jj_expentry = new int[1];
         jj_expentry[0] = i;
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserConstants.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserConstants.java	Mon Jan 01 23:59:14 2018 +0530
@@ -28,8 +28,6 @@
   int BOOL_LITERAL = 14;
   /** RegularExpression Id. */
   int NULL = 15;
-  /** RegularExpression Id. */
-  int IDENTIFIER = 16;
 
   /** Lexical state. */
   int DEFAULT = 0;
@@ -52,7 +50,6 @@
     "<QUOTED_STRING>",
     "<BOOL_LITERAL>",
     "\"null\"",
-    "<IDENTIFIER>",
     "\"{\"",
     "\":\"",
     "\",\"",
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserTokenManager.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JSONParserTokenManager.java	Mon Jan 01 23:59:14 2018 +0530
@@ -15,29 +15,6 @@
 {
    switch (pos)
    {
-      case 0:
-         if ((active0 & 0x8000L) != 0L)
-         {
-            jjmatchedKind = 16;
-            return 14;
-         }
-         return -1;
-      case 1:
-         if ((active0 & 0x8000L) != 0L)
-         {
-            jjmatchedKind = 16;
-            jjmatchedPos = 1;
-            return 14;
-         }
-         return -1;
-      case 2:
-         if ((active0 & 0x8000L) != 0L)
-         {
-            jjmatchedKind = 16;
-            jjmatchedPos = 2;
-            return 14;
-         }
-         return -1;
       default :
          return -1;
    }
@@ -57,19 +34,20 @@
    switch(curChar)
    {
       case 44:
-         return jjStopAtPos(0, 19);
+         return jjStopAtPos(0, 18);
       case 58:
-         return jjStopAtPos(0, 18);
+         return jjStopAtPos(0, 17);
       case 91:
-         return jjStopAtPos(0, 21);
+         return jjStopAtPos(0, 20);
       case 93:
-         return jjStopAtPos(0, 22);
+         return jjStopAtPos(0, 21);
+      case 78:
       case 110:
          return jjMoveStringLiteralDfa1_0(0x8000L);
       case 123:
-         return jjStopAtPos(0, 17);
+         return jjStopAtPos(0, 16);
       case 125:
-         return jjStopAtPos(0, 20);
+         return jjStopAtPos(0, 19);
       default :
          return jjMoveNfa_0(0, 0);
    }
@@ -83,6 +61,7 @@
    }
    switch(curChar)
    {
+      case 85:
       case 117:
          return jjMoveStringLiteralDfa2_0(active0, 0x8000L);
       default :
@@ -101,6 +80,7 @@
    }
    switch(curChar)
    {
+      case 76:
       case 108:
          return jjMoveStringLiteralDfa3_0(active0, 0x8000L);
       default :
@@ -119,23 +99,16 @@
    }
    switch(curChar)
    {
+      case 76:
       case 108:
          if ((active0 & 0x8000L) != 0L)
-            return jjStartNfaWithStates_0(3, 15, 14);
+            return jjStopAtPos(3, 15);
          break;
       default :
          break;
    }
    return jjStartNfa_0(2, active0);
 }
-private int jjStartNfaWithStates_0(int pos, int kind, int state)
-{
-   jjmatchedKind = kind;
-   jjmatchedPos = pos;
-   try { curChar = input_stream.readChar(); }
-   catch(java.io.IOException e) { return pos + 1; }
-   return jjMoveNfa_0(state, pos + 1);
-}
 static final long[] jjbitVec0 = {
    0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
 };
@@ -145,7 +118,7 @@
 private int jjMoveNfa_0(int startState, int curPos)
 {
    int startsAt = 0;
-   jjnewStateCnt = 31;
+   jjnewStateCnt = 29;
    int i = 1;
    jjstateSet[0] = startState;
    int kind = 0x7fffffff;
@@ -184,78 +157,71 @@
                   if (curChar == 34 && kind > 13)
                      kind = 13;
                   break;
-               case 14:
-                  if ((0x3ff200000000000L & l) == 0L)
-                     break;
-                  if (kind > 16)
-                     kind = 16;
-                  jjstateSet[jjnewStateCnt++] = 14;
-                  break;
-               case 15:
+               case 13:
                   if (curChar == 45)
                      jjCheckNAddStates(7, 10);
                   break;
-               case 16:
+               case 14:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
                   if (kind > 7)
                      kind = 7;
-                  jjCheckNAdd(16);
+                  jjCheckNAdd(14);
+                  break;
+               case 15:
+                  if ((0x3ff000000000000L & l) != 0L)
+                     jjCheckNAddTwoStates(15, 16);
+                  break;
+               case 16:
+                  if (curChar == 46)
+                     jjCheckNAdd(17);
                   break;
                case 17:
-                  if ((0x3ff000000000000L & l) != 0L)
-                     jjCheckNAddTwoStates(17, 18);
-                  break;
-               case 18:
-                  if (curChar == 46)
-                     jjCheckNAdd(19);
-                  break;
-               case 19:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
                   if (kind > 8)
                      kind = 8;
-                  jjCheckNAdd(19);
+                  jjCheckNAdd(17);
+                  break;
+               case 18:
+                  if ((0x3ff000000000000L & l) != 0L)
+                     jjCheckNAddTwoStates(18, 19);
                   break;
                case 20:
-                  if ((0x3ff000000000000L & l) != 0L)
-                     jjCheckNAddTwoStates(20, 21);
+                  if ((0x280000000000L & l) != 0L)
+                     jjCheckNAdd(21);
                   break;
-               case 22:
-                  if ((0x280000000000L & l) != 0L)
-                     jjCheckNAdd(23);
-                  break;
-               case 23:
+               case 21:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
                   if (kind > 8)
                      kind = 8;
-                  jjCheckNAdd(23);
+                  jjCheckNAdd(21);
+                  break;
+               case 22:
+                  if ((0x3ff000000000000L & l) != 0L)
+                     jjCheckNAddTwoStates(22, 23);
+                  break;
+               case 23:
+                  if (curChar == 46)
+                     jjCheckNAdd(24);
                   break;
                case 24:
                   if ((0x3ff000000000000L & l) != 0L)
                      jjCheckNAddTwoStates(24, 25);
                   break;
-               case 25:
-                  if (curChar == 46)
-                     jjCheckNAdd(26);
+               case 26:
+                  if ((0x280000000000L & l) != 0L)
+                     jjCheckNAdd(27);
                   break;
-               case 26:
-                  if ((0x3ff000000000000L & l) != 0L)
-                     jjCheckNAddTwoStates(26, 27);
-                  break;
-               case 28:
-                  if ((0x280000000000L & l) != 0L)
-                     jjCheckNAdd(29);
-                  break;
-               case 29:
+               case 27:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
                   if (kind > 8)
                      kind = 8;
-                  jjCheckNAdd(29);
+                  jjCheckNAdd(27);
                   break;
-               case 30:
+               case 28:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
                   if (kind > 7)
@@ -274,15 +240,9 @@
             switch(jjstateSet[--i])
             {
                case 0:
-                  if ((0x7fffffe87fffffeL & l) != 0L)
-                  {
-                     if (kind > 16)
-                        kind = 16;
-                     jjCheckNAdd(14);
-                  }
-                  if (curChar == 102)
+                  if ((0x4000000040L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 11;
-                  else if (curChar == 116)
+                  else if ((0x10000000100000L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 7;
                   break;
                case 1:
@@ -294,54 +254,46 @@
                      jjstateSet[jjnewStateCnt++] = 3;
                   break;
                case 3:
-                  if ((0x14404410000000L & l) != 0L)
+                  if ((0x14404410144044L & l) != 0L)
                      jjCheckNAddStates(11, 13);
                   break;
                case 5:
-                  if (curChar == 101 && kind > 14)
+                  if ((0x2000000020L & l) != 0L && kind > 14)
                      kind = 14;
                   break;
                case 6:
-                  if (curChar == 117)
+                  if ((0x20000000200000L & l) != 0L)
                      jjCheckNAdd(5);
                   break;
                case 7:
-                  if (curChar == 114)
+                  if ((0x4000000040000L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 6;
                   break;
                case 8:
-                  if (curChar == 116)
+                  if ((0x10000000100000L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 7;
                   break;
                case 9:
-                  if (curChar == 115)
+                  if ((0x8000000080000L & l) != 0L)
                      jjCheckNAdd(5);
                   break;
                case 10:
-                  if (curChar == 108)
+                  if ((0x100000001000L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 9;
                   break;
                case 11:
-                  if (curChar == 97)
+                  if ((0x200000002L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 10;
                   break;
                case 12:
-                  if (curChar == 102)
+                  if ((0x4000000040L & l) != 0L)
                      jjstateSet[jjnewStateCnt++] = 11;
                   break;
-               case 13:
-               case 14:
-                  if ((0x7fffffe87fffffeL & l) == 0L)
-                     break;
-                  if (kind > 16)
-                     kind = 16;
-                  jjCheckNAdd(14);
-                  break;
-               case 21:
+               case 19:
                   if ((0x2000000020L & l) != 0L)
                      jjAddStates(14, 15);
                   break;
-               case 27:
+               case 25:
                   if ((0x2000000020L & l) != 0L)
                      jjAddStates(16, 17);
                   break;
@@ -375,15 +327,15 @@
          kind = 0x7fffffff;
       }
       ++curPos;
-      if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt)))
+      if ((i = jjnewStateCnt) == (startsAt = 29 - (jjnewStateCnt = startsAt)))
          return curPos;
       try { curChar = input_stream.readChar(); }
       catch(java.io.IOException e) { return curPos; }
    }
 }
 static final int[] jjnextStates = {
-   16, 17, 18, 20, 21, 24, 25, 16, 17, 20, 24, 1, 2, 4, 22, 23, 
-   28, 29, 
+   14, 15, 16, 18, 19, 22, 23, 14, 15, 18, 22, 1, 2, 4, 20, 21, 
+   26, 27, 
 };
 private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
 {
@@ -401,21 +353,21 @@
 /** Token literal values. */
 public static final String[] jjstrLiteralImages = {
 "", null, null, null, null, null, null, null, null, null, null, null, null, 
-null, null, "\156\165\154\154", null, "\173", "\72", "\54", "\175", "\133", "\135", };
+null, null, null, "\173", "\72", "\54", "\175", "\133", "\135", };
 
 /** Lexer state names. */
 public static final String[] lexStateNames = {
    "DEFAULT",
 };
 static final long[] jjtoToken = {
-   0x7fe181L, 
+   0x3fe181L, 
 };
 static final long[] jjtoSkip = {
    0x7eL, 
 };
 protected JavaCharStream input_stream;
-private final int[] jjrounds = new int[31];
-private final int[] jjstateSet = new int[62];
+private final int[] jjrounds = new int[29];
+private final int[] jjstateSet = new int[58];
 protected char curChar;
 /** Constructor. */
 public JSONParserTokenManager(JavaCharStream stream){
@@ -442,7 +394,7 @@
 {
    int i;
    jjround = 0x80000001;
-   for (i = 31; i-- > 0;)
+   for (i = 29; i-- > 0;)
       jjrounds[i] = 0x80000000;
 }
 
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JsonParser.jj	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/json/parser/JsonParser.jj	Mon Jan 01 23:59:14 2018 +0530
@@ -1,9 +1,52 @@
+/*
+ * Copyright (c) 2018, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
 
+ /*
+  * This is the JavaCC grammar file for a JSON parser. The productions are
+  * based on syntax diagrams as specified at json.org
+  * Every type of JSON is represent by a JSONElement. JSON Objects are mapped to
+  * by LinkedHashMap via JSONObject. JSON Arrays are mapped to ArrayList via JSONArray
+  * String, Number, Boolean and null are wrapped into a JSONPrimitive.
+  * Control characters inside a string (JSONPrimitive(String)) are not escaped and are passed through
+  * to ouput JSON string generated by toJsonString method of JSONElement.
+  * Inside a String, only backslash ('\') and double quote ('"') characters
+  * are escaped by a backslash, if they are not already escaped.
+  * Applications consuming json string generated by JSON* objects must take care
+  * to escape control characters within strings by prefixing with a backslash character,
+  * if not already escaped.
+  */
 options {
     STATIC=false;
     ERROR_REPORTING=true;
     JAVA_UNICODE_ESCAPE=true;
     UNICODE_INPUT=true;
+    IGNORE_CASE=true;
+    CACHE_TOKENS=true;
+//    DEBUG_PARSER=true;
+//    DEBUG_LOOKAHEAD=true;
+//    DEBUG_TOKEN_MANAGER=true;
 }
 
 PARSER_BEGIN(JSONParser)
@@ -44,7 +87,6 @@
 |   <QUOTED_STRING: "\"" ((~["\"","\\"]) | ("\\" ( ["n","t","b","r","f","\\","\""])))* "\"">
 |   <BOOL_LITERAL : "true" | "false">   
 |   <NULL: "null">
-|   <IDENTIFIER: ["_","a"-"z", "A"-"Z"] (["a"-"z", "A"-"Z","0"-"9","_","-"])* >
 }
 
 JSONElement jsonValue() : {
@@ -66,13 +108,13 @@
 	JSONElement value;
 }{
     "{"
-        (key = string() | key = identifier())
+        (key = string())
         ":"
         value = jsonValue()
         { jobject.put((String)key.getValue(), value);}
         (
                 ","
-                (key = string() | key = identifier())
+                (key = string())
                 ":"
                 value = jsonValue()
                 { jobject.put((String)key.getValue(), value);}
@@ -122,9 +164,3 @@
     (t = <QUOTED_STRING>)
     { return new JSONPrimitive(t.image.substring(1,t.image.length()-1)); }
 }
-
-JSONPrimitive identifier() : {}
-{
-    <IDENTIFIER>
-    { return new JSONPrimitive(token.image); }
-}
\ No newline at end of file
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/mapper/JSONMappingFactory.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/mapper/JSONMappingFactory.java	Mon Jan 01 23:59:14 2018 +0530
@@ -70,8 +70,8 @@
 
     private JSONMappingFactory() {
 
-        typeMapper.put(void.class, null);
-        typeMapper.put(Void.class, null);
+        typeMapper.put(void.class, new VoidMapper());
+        typeMapper.put(Void.class, new VoidMapper());
 
         typeMapper.put(boolean.class, new BooleanMapper());
         typeMapper.put(Boolean.class, new BooleanMapper());
@@ -155,6 +155,10 @@
     }
 
     public JSONMapper getTypeMapper(Object object) {
+        return getTypeMapper(object, true);
+    }
+
+    private JSONMapper getTypeMapper(Object object, boolean deepTypeCheck) {
         if (object == null) return null;
         Object obj = object;
         Class<?> cls = object.getClass();
@@ -176,21 +180,23 @@
             TabularData cds = (TabularData) object;
             return getTypeMapper(cds.getTabularType());
         } else if (object instanceof Collection<?>) {
-            Collection<?> c = (Collection<?>) object;
-            boolean unknownMapper = c.stream().anyMatch(k -> (k != null) && (getTypeMapper(k) == null));
-            if (unknownMapper)
-                return null;
-            else
-                return new CollectionMapper();
+            if (deepTypeCheck) {
+                Collection<?> c = (Collection<?>) object;
+                boolean unknownMapper = c.stream().anyMatch(k -> (k != null) && (getTypeMapper(k) == null));
+                if (unknownMapper)
+                    return null;
+            }
+            return new CollectionMapper();
         } else if (object instanceof Map<?, ?>) {
-            Map<?, ?> map = (Map<?, ?>) object;
-            boolean unknownMapper = map.keySet().stream().
-                    anyMatch(k -> ((k != null) && (getTypeMapper(k) == null)
-                            || (map.get(k) != null && getTypeMapper(map.get(k)) == null)));
-            if (unknownMapper)
-                return null;
-            else
-                return new MapMapper();
+            if (deepTypeCheck) {
+                Map<?, ?> map = (Map<?, ?>) object;
+                boolean unknownMapper = map.keySet().stream().
+                        anyMatch(k -> ((k != null) && (getTypeMapper(k) == null)
+                                || (map.get(k) != null && getTypeMapper(map.get(k)) == null)));
+                if (unknownMapper)
+                    return null;
+            }
+            return new MapMapper();
         } else {
             return getTypeMapper(cls);
         }
@@ -294,7 +300,7 @@
         @Override
         public JSONElement toJsonValue(Object data) throws JSONMappingException {
             if (data == null) {
-                return new JSONPrimitive();
+                return null;
             }
             if (!data.getClass().equals(type)) {
                 throw new JSONMappingException("Illegal type : " + data.getClass());
@@ -304,7 +310,7 @@
 
         private JSONElement getJasonValue(Object data) throws JSONMappingException {
             if (data == null) {
-                return new JSONPrimitive();
+                return null;
             }
             if (!data.getClass().isArray()) {
                 return mapper.toJsonValue(data);
@@ -354,7 +360,7 @@
         public JSONElement toJsonValue(Object d) throws JSONMappingException {
             CompositeData data = (CompositeData) d;
             if (data == null) {
-                return new JSONPrimitive();
+                return null;
             }
             JSONObject jObject = new JSONObject();
             for (String itemName : type.keySet()) {
@@ -379,59 +385,28 @@
         }
 
         /*
-        Tabular data in JSON can be represented in below format
-        [
-            {
-                "key" : [<list of elements>],
-                "value": { <CompositeData> }
-            },
-            {
-                "key" : [<list of elements>],
-                "value": { <CompositeData> }
-            }
-        ]
+        Tabular data in JSON can follow below schema
+        {
+            "keys" : [<list of elements>],
+            "rows": [{ <CompositeData> }]
+        }
          */
         @Override
         public TabularDataSupport toJavaObject(JSONElement jsonValue) throws JSONDataException {
-//            if(jsonValue instanceof JSONArray) {
-//                JSONArray jarr = (JSONArray) jsonValue;
-//                for(JSONValue jval : jarr) {
-//                    if(jval instanceof JSONObject) {
-//                        JSONObject jObject = (JSONObject) jval;
-//                        JSONValue jval1 = jObject.get("key");
-//                        Object[] key;
-//                        if(jval1 != null && jval1 instanceof JSONArray) {
-//                            JSONArray jarr1 = (JSONArray) jval1;
-//                            key = new Object[jarr1.size()];
-//                            int i=0;
-//                            for(JSONValue jval2: jarr1){
-//                                key[i++] = ((JSONPrimitive)jval2).getValue();
-//                            }
-//                        }
-//                        JSONValue jval2 = jObject.get("value");
-//                        
-//                        if(jval2 instanceof JSONObject) {
-//                            JSONObject jObj1 = (JSONObject) jval2;
-//                            JSONMapper typeMapper = JSONMappingFactory.INSTANCE.getTypeMapper(type.getRowType());
-//                            Object valueObj = typeMapper.toJavaObject(jObj1);
-//                        }
-//                    }
-//                }
-//            }
             throw new UnsupportedOperationException();
         }
 
         @Override
         public JSONElement toJsonValue(Object data) throws JSONMappingException {
             if (data == null) {
-                return new JSONPrimitive();
+                return null;
             }
             TabularDataSupport tds = (TabularDataSupport) data;
             JSONArray jsonArray = new JSONArray();
             for (Map.Entry<Object, Object> a : tds.entrySet()) {
                 CompositeData cds = (CompositeData) a.getValue();
                 JSONMapper cdsMapper = JSONMappingFactory.INSTANCE.getTypeMapper(cds);
-                if(cdsMapper != null) {
+                if (cdsMapper != null) {
                     jsonArray.add(cdsMapper.toJsonValue(cds));
                 }
             }
@@ -440,7 +415,6 @@
     }
 
     private static class VoidMapper implements JSONMapper {
-
         @Override
         public Void toJavaObject(JSONElement jsonValue) throws JSONDataException {
             return null;
@@ -448,7 +422,7 @@
 
         @Override
         public JSONElement toJsonValue(Object data) throws JSONMappingException {
-            return new JSONPrimitive();
+            return null;
         }
     }
 
@@ -460,7 +434,8 @@
                 return (Boolean) ((JSONPrimitive) jsonValue).getValue();
             } else {
                 throw new JSONDataException("Invalid type convertion - cannot convert "
-                        + ((JSONPrimitive) jsonValue).getValue() + "(" + ((JSONPrimitive) jsonValue).getValue().getClass() + ")" + " to boolean");
+                        + ((JSONPrimitive) jsonValue).getValue()
+                        + "(" + ((JSONPrimitive) jsonValue).getValue().getClass() + ")" + " to boolean");
             }
         }
 
@@ -693,7 +668,7 @@
     private static final class MapMapper implements JSONMapper {
 
         @Override
-        public Object toJavaObject(JSONElement jsonValue) throws JSONDataException {
+        public Map<String, Object> toJavaObject(JSONElement jsonValue) throws JSONDataException {
             if (jsonValue instanceof JSONObject) {
                 JSONObject obj = (JSONObject) jsonValue;
                 Map<String, Object> result = new HashMap<>(obj.size());
@@ -728,9 +703,10 @@
                     String key = k.toString();
                     final Object value = input.get(k);
                     if (value == null) {
-                        jobj.put(key, new JSONPrimitive());
+                        jobj.put(key, (JSONElement) null);
                     } else {
-                        JSONMapper mapper = JSONMappingFactory.INSTANCE.getTypeMapper(value);
+                        JSONMapper mapper = JSONMappingFactory.INSTANCE
+                                .getTypeMapper(value,false); // Disable repeated type checking
                         if (mapper == null) {
                             throw new JSONMappingException("Unable to map : " + value);
                         }
@@ -781,11 +757,12 @@
         public JSONElement toJsonValue(Object data) throws JSONMappingException {
             if (data instanceof Collection) {
                 JSONArray jarr = new JSONArray();
-                Collection<Object> c = (Collection<Object>) data;
-                Iterator<Object> itr = c.iterator();
+                Collection<?> c = (Collection<?>) data;
+                Iterator<?> itr = c.iterator();
                 while (itr.hasNext()) {
                     Object next = itr.next();
-                    JSONMapper typeMapper = JSONMappingFactory.INSTANCE.getTypeMapper(next);
+                    JSONMapper typeMapper = JSONMappingFactory.INSTANCE.
+                            getTypeMapper(next,false); // Disable repeated type checking for collection
                     if (typeMapper == null) {
                         throw JSONMappingException.UNABLE_TO_MAP;
                     }
--- a/src/java.management.rest/share/classes/javax/management/remote/rest/PlatformRestAdapter.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/src/java.management.rest/share/classes/javax/management/remote/rest/PlatformRestAdapter.java	Mon Jan 01 23:59:14 2018 +0530
@@ -47,8 +47,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.Executors;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * This is the root class that initializes the HTTPServer and
@@ -67,10 +67,36 @@
     // Save configuration to be used for other MBeanServers
     private static Map<String, Object> env;
     private static List<MBeanServerResource> restAdapters = new CopyOnWriteArrayList<>();
+    private static final int maxThreadCount = 5;
 
     private PlatformRestAdapter() {
     }
 
+    private static class HttpThreadFactory implements ThreadFactory {
+
+        private static final AtomicInteger poolNumber = new AtomicInteger(1);
+        private final ThreadGroup group;
+        private final AtomicInteger threadNumber = new AtomicInteger(1);
+        private final String namePrefix = "http-thread-";
+
+        HttpThreadFactory() {
+            SecurityManager s = System.getSecurityManager();
+            group = (s != null) ? s.getThreadGroup() :
+                    Thread.currentThread().getThreadGroup();
+        }
+
+        public Thread newThread(Runnable r) {
+            Thread t = new Thread(group, r,
+                    namePrefix + threadNumber.getAndIncrement(),
+                    0);
+            if (t.isDaemon())
+                t.setDaemon(false);
+            if (t.getPriority() != Thread.NORM_PRIORITY)
+                t.setPriority(Thread.NORM_PRIORITY);
+            return t;
+        }
+    }
+
     /**
      * Starts the HTTP server with confiuration specified in properties.
      * The configuration properties are Interface name/IP, port and SSL configuration
@@ -92,6 +118,12 @@
      */
     public static synchronized void init(Properties properties) throws IOException {
         if (httpServer == null) {
+            if(properties == null || properties.isEmpty()) {
+                properties = new Properties();
+                properties.setProperty("com.sun.management.jmxremote.ssl", "false");
+                properties.setProperty("com.sun.management.jmxremote.authenticate", "false");
+                properties.setProperty("com.sun.management.jmxremote.rest.port", "0");
+            }
             final int port;
             try {
                 port = Integer.parseInt(properties.getProperty(PropertyNames.PORT, DefaultValues.PORT));
@@ -122,7 +154,7 @@
             }
 
             new MBeanServerCollectionResource(restAdapters, httpServer);
-            httpServer.setExecutor(Executors.newCachedThreadPool());
+            httpServer.setExecutor(Executors.newFixedThreadPool(maxThreadCount, new HttpThreadFactory()));
             httpServer.start();
             startDefaultRestAdapter(properties);
         }
@@ -203,7 +235,14 @@
 
     public synchronized static void stop() {
         restAdapters.forEach(r -> r.stop());
+        restAdapters.clear();
         if (httpServer != null) {
+            ExecutorService executor = (ExecutorService) httpServer.getExecutor();
+            executor.shutdownNow();
+            try {
+                executor.awaitTermination(30, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
             httpServer.stop(0);
             httpServer = null;
         }
--- a/test/jdk/javax/management/remote/rest/DefaultRestAdapter.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-
- /*
- * @test
- * @run main/othervm -Dcom.sun.management.jmxremote.rest.port=8686 -Dcom.sun.management.config.file=/home/harsha/work/jdk10_rest/jdk/test/javax/management/remote/rest/mgmt1.properties DefaultRestAdapter
- */
-import java.io.IOException;
-import java.util.Arrays;
-
-public class DefaultRestAdapter {
-
-    public static void main(String[] args) throws IOException, Exception {
-        Arrays.asList(args).stream().forEach(System.out::println);
-        Thread.sleep(1000000);
-    }
-}
-
-
-
--- a/test/jdk/javax/management/remote/rest/JsonParserTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-
-
-
-import javax.management.remote.rest.json.JSONElement;
-import javax.management.remote.rest.json.parser.JSONParser;
-import javax.management.remote.rest.json.parser.ParseException;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author harsha
- */
-public class JsonParserTest {
-    
-    public JsonParserTest() {
-    }
-
-    // TODO add test methods here.
-    // The methods must be annotated with annotation @Test. For example:
-    //
-    // @Test
-    // public void hello() {}
-
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-    }
-
-    @BeforeMethod
-    public void setUpMethod() throws Exception {
-    }
-
-    @AfterMethod
-    public void tearDownMethod() throws Exception {
-    }
-    
-    @DataProvider
-    public Object[][] getJsonString() {
-        Object[][] data = new Object[2][1];
-        data[0][0] = "{organisms:[\n" +
-"        {\n" +
-"        id:10929,\n" +
-"        name:\"Bovine Rotavirus\"\n" +
-"        },\n" +
-"        {\n" +
-"        id:9606,\n" +
-"        name:\"Homo Sapiens\"\n" +
-"        }\n" +
-"        ],\n" +
-"proteins:[\n" +
-"        {\n" +
-"        label:\"NSP3\",\n" +
-"        description:\"Rotavirus Non Structural Protein 3\",\n" +
-"        organism-id: 10929,\n" +
-"        acc: \"ACB38353\"\n" +
-"        },\n" +
-"        {\n" +
-"        label:\"EIF4G\",\n" +
-"        description:\"eukaryotic translation initiation factor 4 gamma\",\n" +
-"        organism-id: 9606,\n" +
-"        boolflag: true,\n" +
-"        longFloat: 12351123.1235123e-10,\n" +                
-"        singleQuote: \'asd\',\n" +                                
-"        acc:\"AAI40897\"\n" +
-"        }\n" +
-"        ],\n" +
-"interactions:[\n" +
-"        {\n" +
-"        label:\"NSP3 interacts with EIF4G1\",\n" +
-"        pubmed-id:[77120248,38201627],\n" +
-"        proteins:[\"ACB38353\",\"AAI40897\"]\n" +
-"        }\n" +
-"        ]}";
-        
-        data[1][0] = "{\"name\":\"com.example:type=QueueSampler\",\"exec\":\"testMethod1\",\"params\":[[1,2,3],\"abc\",5,[\"asd\",\"3\",\"67\",\"778\"],[{date:\"2016-3-2\",size:3,head:\"head\"}],[{date:\"2016-3-2\",size:3,head:\"head\"}]]}";
-        return data;
-    }
-    
-    @Test (dataProvider = "getJsonString")
-    public void parserTest(String input) throws ParseException {
-        JSONParser jsonParser = new JSONParser(input);
-        JSONElement parse = jsonParser.parse();
-        String output = parse.toJsonString();
-        System.out.println("\t: " + input);
-        System.out.println("\t: " + output);
-//        Assert.assertEquals(input, output);
-    }
-}
--- a/test/jdk/javax/management/remote/rest/PlatformAdapterTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,275 +0,0 @@
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.cert.Certificate;
-import java.util.Base64;
-import java.util.Properties;
-import javax.management.remote.rest.JmxRestAdapter;
-import javax.management.remote.rest.PlatformRestAdapter;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.TrustManagerFactory;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
-
-/**
- * @test 
- * @modules java.management.rest
- * @run testng/othervm PlatformAdapterTest
- */
-@Test
-public class PlatformAdapterTest {
-
-    private static final String MBEANS = "mbeans";
-    private static String sslAgentConfig;
-    private static String sslClientConfig;
-    private static String passwordFile;
-    
-
-    @BeforeClass
-    public void setup() throws IOException {
-        String testSrcRoot = System.getProperty("test.src") + File.separator;
-        sslAgentConfig = testSrcRoot + "sslConfigAgent";
-        sslClientConfig = testSrcRoot + "sslConfigClient";
-        passwordFile = testSrcRoot + "password.properties";
-        createAgentSslConfigFile(sslAgentConfig);
-        createClientSslConfigFile(sslClientConfig);
-    }
-    
-    @Test
-    public void testHttpNoAuth() throws Exception {
-        Properties props = new Properties();
-        props.setProperty("com.sun.management.jmxremote.rest.port", "8686");
-        props.setProperty("com.sun.management.jmxremote.ssl", "false");
-        props.setProperty("com.sun.management.jmxremote.authenticate", "false");
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-
-        JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-        adapter.start();
-        URL url = new URL(adapter.getBaseUrl() + MBEANS);
-        HttpURLConnection con = (HttpURLConnection) url.openConnection();
-        con.setDoOutput(false);
-        print_content(con);
-        PlatformRestAdapter.stop();
-    }
-
-    @Test
-    public void testHttpAuth() throws Exception {
-        Properties props = new Properties();
-        props.setProperty("com.sun.management.jmxremote.rest.port", "8686");
-        props.setProperty("com.sun.management.jmxremote.ssl", "false");
-        props.setProperty("com.sun.management.jmxremote.authenticate", "true");
-        props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-
-        JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-        adapter.start();
-        URL url = new URL(adapter.getBaseUrl() + MBEANS);
-        HttpURLConnection con = (HttpURLConnection) url.openConnection();
-        con.setDoOutput(false);
-
-        String userCredentials = "username1:password1";
-
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        con.setRequestProperty("Authorization", basicAuth);
-        print_content(con);
-
-        PlatformRestAdapter.stop();
-    }
-
-    private void createAgentSslConfigFile(String fileName) throws IOException {
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreAgent");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreAgent");
-        props.setProperty("javax.net.ssl.trustStorePassword","glopglop");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
-        }
-    }
-
-    private void createClientSslConfigFile(String fileName) throws IOException {
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreClient");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreClient");
-        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
-        }
-    }
-
-    @Test
-    public void testHttpsNoAuth() throws Exception {
-        Properties props = new Properties();
-        props.setProperty("com.sun.management.jmxremote.rest.port", "8686");
-        props.setProperty("com.sun.management.jmxremote.ssl", "true");
-        props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
-        props.setProperty("com.sun.management.jmxremote.authenticate", "false");
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-        JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-        adapter.start();
-        SSLContext ctx = getSSlContext(sslClientConfig);
-        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
-        HttpsURLConnection.setDefaultHostnameVerifier(
-                (String hostname, javax.net.ssl.SSLSession sslSession) -> hostname.equals("Harsha-Wardhana-B"));
-
-        URL url = new URL(adapter.getBaseUrl() + MBEANS);
-        HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-        con.setDoOutput(false);
-        print_https_cert(con);
-        print_content(con);
-        PlatformRestAdapter.stop();
-    }
-
-    @Test
-    public void testHttpsAuth() throws Exception {
-        Properties props = new Properties();
-        props.setProperty("com.sun.management.jmxremote.rest.port", "8686");
-        props.setProperty("com.sun.management.jmxremote.ssl", "true");
-        props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
-        props.setProperty("com.sun.management.jmxremote.authenticate", "true");
-        props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-
-        JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-        adapter.start();
-        SSLContext ctx = getSSlContext(sslClientConfig);
-        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
-        HttpsURLConnection.setDefaultHostnameVerifier(
-                (String hostname, javax.net.ssl.SSLSession sslSession) -> hostname.equals("Harsha-Wardhana-B"));
-
-        URL url = new URL(adapter.getBaseUrl() + MBEANS);
-        HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-        con.setDoOutput(false);
-
-        String userCredentials = "username1:password1";
-
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        con.setRequestProperty("Authorization", basicAuth);
-        print_https_cert(con);
-        print_content(con);
-        PlatformRestAdapter.stop();
-    }
-
-    private void print_content(HttpURLConnection con) {
-        if (con != null) {
-            try {
-                System.out.println("****** Content of the URL ********");
-                int status = con.getResponseCode();
-                System.out.println("Status = " + status);
-                BufferedReader br
-                        = new BufferedReader(
-                                new InputStreamReader(con.getInputStream()));
-                String input;
-                while ((input = br.readLine()) != null) {
-                    System.out.println(input);
-                }
-                br.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private void print_https_cert(HttpsURLConnection con) {
-        if (con != null) {
-            try {
-                System.out.println("Response Code : " + con.getResponseCode());
-                System.out.println("Cipher Suite : " + con.getCipherSuite());
-                System.out.println("\n");
-
-                Certificate[] certs = con.getServerCertificates();
-                for (Certificate cert : certs) {
-                    System.out.println("Cert Type : " + cert.getType());
-                    System.out.println("Cert Hash Code : " + cert.hashCode());
-                    System.out.println("Cert Public Key Algorithm : "
-                            + cert.getPublicKey().getAlgorithm());
-                    System.out.println("Cert Public Key Format : "
-                            + cert.getPublicKey().getFormat());
-                    System.out.println("\n");
-                }
-
-            } catch (SSLPeerUnverifiedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private static SSLContext getSSlContext(String sslConfigFileName) {
-        String keyStore, keyStorePassword, trustStore, trustStorePassword;
-        System.out.println("SSL Config file : " + sslConfigFileName);
-
-        try {
-            Properties p = new Properties();
-            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
-            p.load(bin);
-            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
-            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
-            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
-            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
-
-            char[] keyStorePasswd = null;
-            if (keyStorePassword.length() != 0) {
-                keyStorePasswd = keyStorePassword.toCharArray();
-            }
-
-            char[] trustStorePasswd = null;
-            if (trustStorePassword.length() != 0) {
-                trustStorePasswd = trustStorePassword.toCharArray();
-            }
-
-            KeyStore ks = null;
-            if (keyStore != null) {
-                ks = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream ksfis = new FileInputStream(keyStore);
-                ks.load(ksfis, keyStorePasswd);
-
-            }
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
-                    KeyManagerFactory.getDefaultAlgorithm());
-            kmf.init(ks, keyStorePasswd);
-
-            KeyStore ts = null;
-            if (trustStore != null) {
-                ts = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream tsfis = new FileInputStream(trustStore);
-                ts.load(tsfis, trustStorePasswd);
-            }
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
-                    TrustManagerFactory.getDefaultAlgorithm());
-            tmf.init(ts);
-
-            SSLContext ctx = SSLContext.getInstance("SSL");
-            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-            return ctx;
-        } catch (Exception ex) {
-        }
-        return null;
-    }
-}
--- a/test/jdk/javax/management/remote/rest/PlatformMBeanTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package javax.management.remote.rest.test;
-
-import javax.management.remote.rest.JmxRestAdapter;
-import javax.management.remote.rest.PlatformRestAdapter;
-import javax.management.remote.rest.json.JSONArray;
-import javax.management.remote.rest.json.JSONElement;
-import javax.management.remote.rest.json.JSONObject;
-import javax.management.remote.rest.json.JSONPrimitive;
-import javax.management.remote.rest.json.parser.JSONParser;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.security.KeyStore;
-import java.util.Base64;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author harsha
- */
-public class PlatformMBeanTest {
-
-    private static SSLContext getSSlContext(String sslConfigFileName) {
-        final String keyStore, keyStorePassword, trustStore, trustStorePassword;
-
-        try {
-            Properties p = new Properties();
-            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
-            p.load(bin);
-            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
-            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
-            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
-            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
-
-            char[] keyStorePasswd = null;
-            if (keyStorePassword.length() != 0) {
-                keyStorePasswd = keyStorePassword.toCharArray();
-            }
-
-            char[] trustStorePasswd = null;
-            if (trustStorePassword.length() != 0) {
-                trustStorePasswd = trustStorePassword.toCharArray();
-            }
-
-            KeyStore ks = null;
-            if (keyStore != null) {
-                ks = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream ksfis = new FileInputStream(keyStore);
-                ks.load(ksfis, keyStorePasswd);
-
-            }
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
-                    KeyManagerFactory.getDefaultAlgorithm());
-            kmf.init(ks, keyStorePasswd);
-
-            KeyStore ts = null;
-            if (trustStore != null) {
-                ts = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream tsfis = new FileInputStream(trustStore);
-                ts.load(tsfis, trustStorePasswd);
-            }
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
-                    TrustManagerFactory.getDefaultAlgorithm());
-            tmf.init(ts);
-
-            SSLContext ctx = SSLContext.getInstance("SSL");
-            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-            return ctx;
-        } catch (Exception ex) {
-            Logger.getLogger(PlatformRestAdapter.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        return null;
-    }
-
-    private static final String CHARSET = "UTF-8";
-
-    private String getFilePath(String filename) {
-        return System.getProperty("user.dir") + File.separator + filename;
-    }
-
-    @BeforeClass
-    public void setupAdapter() throws Exception {
-        File file = new File(getFilePath("management.properties"));
-        Properties props = new Properties();
-        props.load(new FileInputStream(file));
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-        PlatformRestAdapter.getInstance().start();
-        SSLContext ctx = getSSlContext(getFilePath("sslconfigClient"));
-        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
-        HttpsURLConnection.setDefaultHostnameVerifier(
-                (String hostname, javax.net.ssl.SSLSession sslSession) -> hostname.equals("Harsha-Wardhana-B"));
-    }
-
-    @AfterClass
-    public void tearDown() {
-        PlatformRestAdapter.stop();
-    }
-
-    private String executeHttpGetRequest(String inputUrl) throws MalformedURLException, IOException {
-        if (inputUrl != null && !inputUrl.isEmpty()) {
-            JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-            URL url = new URL(adapter.getBaseUrl() + inputUrl);
-            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-            con.setDoOutput(false);
-            String userCredentials = "username1:password1";
-            String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-            con.setRequestProperty("Authorization", basicAuth);
-            try {
-                int status = con.getResponseCode();
-                if (status == 200) {
-
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getInputStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(URLDecoder.decode(input, CHARSET));
-                        }
-                    }
-                    return sbuf.toString();
-                } else {
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getErrorStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(URLDecoder.decode(input, CHARSET));
-                        }
-                    }
-                    return sbuf.toString();
-                }
-            } catch (IOException e) {
-            }
-        }
-        return null;
-    }
-
-    private String executeHttpPostRequest(String postBody) throws MalformedURLException, IOException {
-        if (postBody != null && !postBody.isEmpty()) {
-            JmxRestAdapter adapter = PlatformRestAdapter.getInstance();
-            URL url = new URL(adapter.getBaseUrl());
-            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
-            connection.setRequestProperty("Content-Type", "application/json; charset=" + CHARSET);
-            connection.setDoOutput(true);
-            connection.setRequestMethod("POST");
-            String userCredentials = "username1:password1";
-            String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-            connection.setRequestProperty("Authorization", basicAuth);
-            try (OutputStreamWriter out = new OutputStreamWriter(
-                    connection.getOutputStream(), CHARSET)) {
-                out.write(URLEncoder.encode(postBody, CHARSET));
-                out.flush();
-            }
-            try {
-                int status = connection.getResponseCode();
-                if (status == 200) {
-
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(connection.getInputStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(URLDecoder.decode(input, CHARSET));
-                        }
-                    }
-                    return sbuf.toString();
-                } else {
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(connection.getErrorStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(URLDecoder.decode(input, CHARSET));
-                        }
-                    }
-                    return sbuf.toString();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void testOperatingSystemMbean() throws Exception {
-        //  Get MBeanInfo
-        String osMbeanInfo = executeHttpGetRequest("java.lang:type=OperatingSystem");
-        System.out.println(osMbeanInfo);
-
-        // Read all attributes
-        JSONParser parser = new JSONParser(osMbeanInfo);
-        JSONObject docRoot = (JSONObject) parser.parse();
-        JSONArray attrJson = (JSONArray) ((JSONObject) docRoot.get("response")).get("attributeInfo");
-        for (JSONElement elem : attrJson) {
-            JSONObject attrElem = (JSONObject) elem;
-            JSONPrimitive a = (JSONPrimitive) attrElem.get("name");
-            JSONPrimitive access = (JSONPrimitive) attrElem.get("access");
-            String attrResponse = executeHttpGetRequest("java.lang:type=OperatingSystem/" + a.getValue());
-            parser = new JSONParser(attrResponse);
-            docRoot = (JSONObject) parser.parse();
-            JSONPrimitive result = (JSONPrimitive) ((JSONObject) docRoot.get("response")).get(a.getValue());
-            System.out.println("Attribute : " + a.getValue() + "(" + access.getValue() + ")" + " - " + result.getValue());
-        }
-    }
-
-    @Test
-    public void testHotSpotDiagMBean() throws Exception {
-        String mbeanName = "com.sun.management:type=HotSpotDiagnostic";
-        String osMbeanInfo = executeHttpGetRequest(mbeanName);
-        System.out.println(osMbeanInfo);
-
-        // Read all attributes
-        JSONParser parser = new JSONParser(osMbeanInfo);
-        JSONObject docRoot = (JSONObject) parser.parse();
-        JSONArray attrJson = (JSONArray) ((JSONObject) docRoot.get("response")).get("attributeInfo");
-        if (attrJson != null) {
-            for (JSONElement elem : attrJson) {
-                JSONObject attrElem = (JSONObject) elem;
-                JSONPrimitive a = (JSONPrimitive) attrElem.get("name");
-                JSONPrimitive access = (JSONPrimitive) attrElem.get("access");
-                String attrResponse = executeHttpGetRequest(mbeanName + "/" + a.getValue());
-                parser = new JSONParser(attrResponse);
-                docRoot = (JSONObject) parser.parse();
-                JSONObject response = (JSONObject) docRoot.get("response");
-                if (response != null) {
-                    JSONElement get = response.get(a.getValue());
-                    System.out.println("Attribute : " + a.getValue() + "(" + access.getValue() + ")" + " - " + get.toJsonString());
-                } else {
-                    System.out.println("Attribute : " + a.getValue() + "(" + access.getValue() + ")" + " - null");
-                }
-            }
-        }
-
-        String dumpHeap = "{\n"
-                + "  \"name\": \"com.sun.management:type=HotSpotDiagnostic\",\n"
-                + "  \"exec\": \"dumpHeap\",\n"
-                + "  \"arguments\": [\n"
-                + "			\"heapdump.hprof\",\n"
-                + "			false\n"
-                + "		]\n"
-                + "}";
-
-        String responseJson = executeHttpPostRequest(dumpHeap);
-        parser = new JSONParser(responseJson);
-        docRoot = (JSONObject) parser.parse();
-        JSONElement response = docRoot.get("response");
-        System.out.println(" DumpHeap op - " + (response != null ? response.toJsonString() : null));
-
-        String getVmOption = "{\n"
-                + "  \"name\": \"com.sun.management:type=HotSpotDiagnostic\",\n"
-                + "  \"exec\": \"getVMOption\",\n"
-                + "  \"arguments\": [\n"
-                + "	\"PrintGCDetails\"\n"
-                + "	]\n"
-                + "}";
-        responseJson = executeHttpPostRequest(getVmOption);
-        parser = new JSONParser(responseJson);
-        docRoot = (JSONObject) parser.parse();
-        response = docRoot.get("response");
-        System.out.println(" DumpHeap op - " + (response != null ? response.toJsonString() : null));
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/management/remote/rest/RestAdapterConfigTest.java	Mon Jan 01 23:59:14 2018 +0530
@@ -0,0 +1,219 @@
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.management.remote.rest.PlatformRestAdapter;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.*;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@Test
+public class RestAdapterConfigTest {
+    private static String sslAgentConfig;
+    private static String sslClientConfig;
+    private static String passwordFile;
+    private static String configFile;
+    private static List<Runnable> tasks = new ArrayList<>();
+    private static RestAdapterTest test = new RestAdapterTest();
+
+    static {
+        tasks.add(test::testAllMBeanServers);
+        tasks.add(test::testAllMBeanInfo);
+        tasks.add(test::testAllMBeans);
+        tasks.add(test::testMBeanFiltering);
+        tasks.add(test::testMBeanGetAttributes);
+        tasks.add(test::testMBeanSetAttributes);
+        tasks.add(test::testMbeanNoArgOperations);
+        tasks.add(test::testAllMBeansBulkRequest);
+        tasks.add(test::testThreadMXBeanBulkRequest);
+        tasks.add(test::testThreadMXBeanThreadInfo);
+    }
+
+    private void createAgentSslConfigFile(String fileName) throws IOException {
+        File f = new File(fileName);
+        if (f.exists()) {
+            f.delete();
+        }
+
+        Properties props = new Properties();
+        String testDir = System.getProperty("test.src");
+        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreAgent");
+        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
+        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreAgent");
+        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
+
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
+            props.store(writer, "");
+        }
+    }
+
+    private void createClientSslConfigFile(String fileName) throws IOException {
+        File f = new File(fileName);
+        if (f.exists()) {
+            f.delete();
+        }
+        Properties props = new Properties();
+        String testDir = System.getProperty("test.src");
+        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreClient");
+        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
+        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreClient");
+        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
+
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
+            props.store(writer, "");
+        }
+    }
+
+    private void setupMgmtConfig(String fileName, boolean isSSL, boolean isAuth) throws IOException {
+        Properties props = new Properties();
+        File f = new File(fileName);
+        if (f.exists()) {
+            f.delete();
+        }
+
+        props.setProperty("com.sun.management.jmxremote.ssl", isSSL ? "true" : "false");
+        if(isSSL) {
+            props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
+        }
+        props.setProperty("com.sun.management.jmxremote.authenticate", isAuth ? "true" : "false");
+        if (isAuth) {
+            props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
+        }
+        props.setProperty("com.sun.management.jmxremote.rest.port", "0");
+
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
+            props.store(writer, "");
+        }
+    }
+
+    @BeforeClass
+    public void init() throws Exception {
+        // TODO : Remove this line for Jtreg testing
+        System.setProperty("test.src", System.getProperty("user.dir")+ File.separator + "test");
+
+        String testSrcRoot = System.getProperty("test.src") + File.separator;
+        sslAgentConfig = testSrcRoot + "sslConfigAgent";
+        sslClientConfig = testSrcRoot + "sslConfigClient";
+        passwordFile = testSrcRoot + "password.properties";
+        configFile = testSrcRoot + "mgmt.properties";
+
+        createAgentSslConfigFile(sslAgentConfig);
+        createClientSslConfigFile(sslClientConfig);
+
+        SSLContext ctx = getSSlContext(sslClientConfig);
+        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
+        HttpsURLConnection.setDefaultHostnameVerifier(
+                (String hostname, javax.net.ssl.SSLSession sslSession) -> {
+                    try {
+                        return hostname.equals(InetAddress.getLocalHost().getHostName());
+                    } catch (UnknownHostException ex) {
+                        throw new RuntimeException(ex);
+                    }
+                });
+    }
+
+    private static SSLContext getSSlContext(String sslConfigFileName) {
+        final String keyStore, keyStorePassword, trustStore, trustStorePassword;
+
+        try {
+            Properties p = new Properties();
+            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
+            p.load(bin);
+            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
+            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
+            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
+            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
+
+            char[] keyStorePasswd = null;
+            if (keyStorePassword.length() != 0) {
+                keyStorePasswd = keyStorePassword.toCharArray();
+            }
+
+            char[] trustStorePasswd = null;
+            if (trustStorePassword.length() != 0) {
+                trustStorePasswd = trustStorePassword.toCharArray();
+            }
+
+            KeyStore ks = null;
+            if (keyStore != null) {
+                ks = KeyStore.getInstance(KeyStore.getDefaultType());
+                FileInputStream ksfis = new FileInputStream(keyStore);
+                ks.load(ksfis, keyStorePasswd);
+
+            }
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
+                    KeyManagerFactory.getDefaultAlgorithm());
+            kmf.init(ks, keyStorePasswd);
+
+            KeyStore ts = null;
+            if (trustStore != null) {
+                ts = KeyStore.getInstance(KeyStore.getDefaultType());
+                FileInputStream tsfis = new FileInputStream(trustStore);
+                ts.load(tsfis, trustStorePasswd);
+            }
+            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
+                    TrustManagerFactory.getDefaultAlgorithm());
+            tmf.init(ts);
+
+            SSLContext ctx = SSLContext.getInstance("SSL");
+            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+            return ctx;
+        } catch (Exception ex) {
+            Logger.getLogger(PlatformRestAdapter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return null;
+    }
+
+    @Test
+    public void testHttpNoAuth() throws Exception {
+        setupMgmtConfig(configFile, false, false);
+        test.setupServers();
+        tasks.forEach(Runnable::run);
+        test.tearDownServers();
+    }
+
+    public void testHttpsNoAuth() throws Exception {
+        setupMgmtConfig(configFile, true, false);
+        test.setupServers();
+        tasks.forEach(Runnable::run);
+        test.tearDownServers();
+    }
+
+    public void testHttpAuth() throws Exception {
+        setupMgmtConfig(configFile, false, true);
+        test.setupServers();
+        tasks.forEach(Runnable::run);
+        test.tearDownServers();
+    }
+
+    public void testHttpsAuth() throws Exception {
+        setupMgmtConfig(configFile, true, true);
+        test.setupServers();
+        tasks.forEach(Runnable::run);
+        test.tearDownServers();
+    }
+
+    @AfterClass
+    public void tearDown() {
+        File f = new File(sslAgentConfig);
+        if (f.exists())
+            f.delete();
+        f = new File(sslClientConfig);
+        if (f.exists())
+            f.delete();
+        f = new File(configFile);
+        if (f.exists())
+            f.delete();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/management/remote/rest/RestAdapterPerfTest.java	Mon Jan 01 23:59:14 2018 +0530
@@ -0,0 +1,49 @@
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Test
+public class RestAdapterPerfTest {
+
+    private static Random random = new Random(System.currentTimeMillis());
+    private static AtomicInteger count = new AtomicInteger(1);
+
+    public static void main(String[] args) throws Exception {
+        RestAdapterTest test = new RestAdapterTest();
+        List<Runnable> tasks = new ArrayList<>();
+
+        tasks.add(test::testAllMBeanServers);
+        tasks.add(test::testAllMBeanInfo);
+        tasks.add(test::testAllMBeans);
+        tasks.add(test::testMBeanFiltering);
+        tasks.add(test::testMBeanGetAttributes);
+        tasks.add(test::testMBeanSetAttributes);
+        tasks.add(test::testMbeanNoArgOperations);
+        tasks.add(test::testAllMBeansBulkRequest);
+        tasks.add(test::testThreadMXBeanBulkRequest);
+        tasks.add(test::testThreadMXBeanThreadInfo);
+
+        ThreadPoolExecutor es = (ThreadPoolExecutor) Executors.newFixedThreadPool(20);
+        es.setThreadFactory((Runnable R) -> new Thread(R, "perf-" + count.getAndIncrement()));
+        long current = System.currentTimeMillis();
+        test.setupServers();
+        for (int i = 0; i < 200; i++) {
+            Runnable task = tasks.get(random.nextInt(tasks.size()));
+            es.execute(task);
+        }
+
+        System.out.println("Submitted 200 tasks");
+        es.shutdown();
+        es.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
+        float v = (float) (System.currentTimeMillis() - current) / (float) 1000;
+        System.out.println("Total time = " + v + "s");
+        test.tearDownServers();
+    }
+}
--- a/test/jdk/javax/management/remote/rest/RestAdapterSSLTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,477 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-import com.oracle.jmx.remote.rest.json.JSONArray;
-import com.oracle.jmx.remote.rest.json.JSONElement;
-import com.oracle.jmx.remote.rest.json.JSONObject;
-import com.oracle.jmx.remote.rest.json.JSONPrimitive;
-import com.oracle.jmx.remote.rest.json.parser.JSONParser;
-import com.oracle.jmx.remote.rest.json.parser.ParseException;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.security.KeyStore;
-import java.security.cert.Certificate;
-import java.util.Base64;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.remote.rest.PlatformRestAdapter;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLPeerUnverifiedException;
-import javax.net.ssl.TrustManagerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @modules java.logging
- *          java.management
- *          java.management.rest
- * @run testng/othervm RestAdapterSSLTest
- * 
- */
-@Test
-public class RestAdapterSSLTest {
-
-    private static final String CHARSET = "UTF-8";
-    private static String sslAgentConfig;
-    private static String sslClientConfig;
-    private static String passwordFile;
-    private static String configFile;
-
-    private void createAgentSslConfigFile(String fileName) throws IOException {
-        File f = new File(fileName);
-        if (f.exists()) {
-            return;
-        }
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreAgent");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreAgent");
-        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
-        }
-    }
-
-    private void createClientSslConfigFile(String fileName) throws IOException {
-        File f = new File(fileName);
-        if (f.exists()) {
-            return;
-        }
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreClient");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreClient");
-        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
-        }
-    }
-
-    private void setupMgmtConfig(String fileName) throws IOException {
-        Properties props = new Properties();
-        
-        props.setProperty("com.sun.management.jmxremote.ssl", "true");
-        props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
-        props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
-        props.setProperty("com.sun.management.jmxremote.rest.port", "0");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
-        }
-    }
-
-    private void setupConfig() throws Exception {
-        String testSrcRoot = System.getProperty("test.src") + File.separator;
-        sslAgentConfig = testSrcRoot + "sslConfigAgent";
-        sslClientConfig = testSrcRoot + "sslConfigClient";
-        passwordFile = testSrcRoot + "password.properties";
-        configFile = testSrcRoot + "mgmt.properties";
-        createAgentSslConfigFile(sslAgentConfig);
-        createClientSslConfigFile(sslClientConfig);
-        setupMgmtConfig(configFile);
-    }
-
-    @BeforeClass
-    public void setupAdapter() throws Exception {
-        setupConfig();
-        File file = new File(configFile);
-        Properties props = new Properties();
-        props.load(new FileInputStream(file));
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
-        }
-        SSLContext ctx = getSSlContext(sslClientConfig);
-        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
-        HttpsURLConnection.setDefaultHostnameVerifier(
-                (String hostname, javax.net.ssl.SSLSession sslSession) -> hostname.equals("Harsha-Wardhana-B"));
-        setupMbean();
-    }
-
-    @AfterClass
-    public void tearDown() {
-        PlatformRestAdapter.stop();
-    }
-
-    @DataProvider
-    public Object[][] getUrlList() {
-        Object[][] data = new Object[7][1];
-        data[0][0] = "?domain=default";
-        data[1][0] = "mbeans";
-        data[2][0] = "domains";
-        data[3][0] = "java.lang:type=Memory";
-        data[4][0] = "java.lang:type=Memory/HeapMemoryUsage";
-        data[5][0] = "java.lang:type=Memory/?attributes=HeapMemoryUsage,ObjectPendingFinalizationCount,NonHeapMemoryUsage";
-        data[6][0] = "java.lang:type=Memory/?attributes=all";
-        return data;
-    }
-
-    @DataProvider
-    public Object[][] getMalformedUrlList() {
-        Object[][] data = new Object[1][1];
-        data[0][0] = "com.example:type=QueueSamplerMBean";
-        return data;
-    }
-
-    private String executeHttpRequest(String inputUrl) throws IOException {
-        return executeHttpRequest(inputUrl, null);
-    }
-
-    private String executeHttpRequest(String inputUrl, String charset) throws IOException {
-        if (inputUrl != null && !inputUrl.isEmpty()) {
-            URL url = new URL(PlatformRestAdapter.getBaseURL() + (charset != null ? URLEncoder.encode(inputUrl, charset) : inputUrl));
-            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-            con.setDoOutput(false);
-            String userCredentials = "username1:password1";
-            String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-            con.setRequestProperty("Authorization", basicAuth);
-            if (charset != null && !charset.isEmpty()) {
-                con.setRequestProperty("Content-Type", "application/json; charset=" + charset);
-            }
-            try {
-                int status = con.getResponseCode();
-                if (status == 200) {
-
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getInputStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(charset != null ? URLDecoder.decode(input, charset) : input);
-                        }
-                    }
-                    return sbuf.toString();
-                } else {
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getErrorStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(charset != null ? URLDecoder.decode(input, charset) : input);
-                        }
-                    }
-                    return sbuf.toString();
-                }
-            } catch (IOException e) {
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void testMisc() throws IOException, ParseException {
-        String mBeanInfo = executeHttpRequest("com.sun.management:type=DiagnosticCommand");
-        System.out.println(mBeanInfo);
-        JSONParser parser = new JSONParser(mBeanInfo);
-        JSONObject response = (JSONObject) parser.parse();
-        long status = (Long) ((JSONPrimitive) response.get("status")).getValue();
-        Assert.assertEquals(status, 200);
-    }
-
-    @Test(enabled = false)
-    public void testCharset() throws IOException {
-        String result1 = executeHttpRequest("?domain=default");
-        String result2 = executeHttpRequest("?domain=default", CHARSET);
-        Assert.assertEquals(result1, result2);
-    }
-
-    @Test
-    public void testPostMisc() throws IOException {
-        URL url = new URL(PlatformRestAdapter.getBaseURL());
-        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
-        connection.setRequestProperty("Content-Type", "application/json; charset=" + CHARSET);
-        connection.setDoOutput(true);
-        connection.setRequestMethod("POST");
-        String userCredentials = "username1:password1";
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        connection.setRequestProperty("Authorization", basicAuth);
-
-        String req = "{\n"
-                + "    \"name\":\"java.lang:type=Memory\"\n"
-                + "    \"write\":\"Verbose\"\n"
-                + "    \"arguments\" : [true]\n"
-                + "}";
-        try (OutputStreamWriter out = new OutputStreamWriter(
-                connection.getOutputStream(), CHARSET)) {
-            out.write(URLEncoder.encode(req, CHARSET));
-            out.flush();
-        }
-
-        print_content(connection);
-    }
-
-    @Test
-    public void testBasicHttps() throws Exception {
-        URL url = new URL(PlatformRestAdapter.getBaseURL());
-        HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-        con.setDoOutput(false);
-
-        String userCredentials = "username1:password1";
-
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        con.setRequestProperty("Authorization", basicAuth);
-        print_https_cert(con);
-        print_content(con);
-    }
-
-    @Test(dataProvider = "getUrlList")
-    public void testGetRequests(String urlStr) throws Exception {
-        String input = executeHttpRequest(urlStr);
-        System.out.println("URL : [" + urlStr + "] ----> " + input);
-        System.out.println(input);
-        JSONParser parser = new JSONParser(input);
-        JSONElement parse = parser.parse();
-        JSONElement jstatus = ((JSONObject) parse).get("status");
-        long status = (Long) ((JSONPrimitive) jstatus).getValue();
-        Assert.assertEquals(status, 200);
-    }
-
-    @Test
-    public void testAllGetMBeanInfo() throws Exception {
-        String input = executeHttpRequest("mbeans");
-        JSONParser parser = new JSONParser(input);
-        JSONElement jsonObj = parser.parse();
-        if (jsonObj instanceof JSONObject) {
-            JSONElement jelem = ((JSONObject) jsonObj).get("response");
-            if (jelem instanceof JSONArray) {
-                for (JSONElement elem : ((JSONArray) jelem)) {
-                    String objName = (String) ((JSONPrimitive) elem).getValue();
-                    String mBeanInfo = executeHttpRequest(objName);
-                    System.out.println(mBeanInfo);
-                    parser = new JSONParser(mBeanInfo);
-                    JSONObject response = (JSONObject) parser.parse();
-                    long status = (Long) ((JSONPrimitive) response.get("status")).getValue();
-                    Assert.assertEquals(status, 200);
-                }
-            }
-        }
-    }
-
-    @Test(enabled = false, dataProvider = "getMalformedUrlList")
-    public void negTestGetRequests(String urlStr) throws Exception {
-        URL url = new URL(PlatformRestAdapter.getBaseURL() + urlStr);
-        HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-        con.setDoOutput(false);
-        String userCredentials = "username1:password1";
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        con.setRequestProperty("Authorization", basicAuth);
-        print_content(con);
-    }
-
-    @Test
-    public void testPost() throws Exception {
-        URL url = new URL(PlatformRestAdapter.getBaseURL());
-        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
-        connection.setRequestProperty("Content-Type", "application/json; charset=" + CHARSET);
-        connection.setDoOutput(true);
-        connection.setRequestMethod("POST");
-        String userCredentials = "username1:password1";
-        String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-        connection.setRequestProperty("Authorization", basicAuth);
-
-        String postReq = "{\"name\":\"com.example:type=QueueSampler\",\"exec\":\"testMethod1\",\"arguments\":[[1,2,3],\"abc\",5,[\"asd\",\"3\",\"67\",\"778\"],[{date:\"2016-03-02\",size:3,head:\"head\"}],[{date:\"2016-03-02\",size:3,head:\"head\"}]]}";
-        JSONArray jarr = new JSONArray();
-
-        JSONObject jobject = new JSONObject();
-        jobject.put("name", "com.example:type=QueueSampler");
-        jobject.put("write", "QueueName");
-        JSONArray jarr1 = new JSONArray();
-        jarr1.add(new JSONPrimitive("Dequeue"));
-        jobject.put("arguments", jarr1);
-        jarr.add(jobject);
-
-        jobject = new JSONObject();
-        jobject.put("name", "com.example:type=QueueSampler");
-        jobject.put("read", "QueueName");
-        jarr.add(jobject);
-
-        jarr.add(new JSONParser(postReq).parse());
-
-        try (OutputStreamWriter out = new OutputStreamWriter(
-                connection.getOutputStream(), CHARSET)) {
-            out.write(URLEncoder.encode(jarr.toJsonString(), CHARSET));
-            out.flush();
-        }
-        print_content(connection);
-    }
-
-    @Test(enabled = false)
-    public void testMBeanFilter() throws MalformedObjectNameException {
-        // Add non-compliant MBean to platform mbean server
-        ObjectName mbeanName = new ObjectName("com.example:type=QueueSamplerMBean");
-    }
-
-    private void setupMbean() throws Exception {
-        // Get the Platform MBean Server
-//        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-//
-//        // Construct the ObjectName for the QueueSampler MXBean we will register
-//        ObjectName mxbeanName = new ObjectName("com.example:type=QueueSampler");
-//        ObjectName mbeanName = new ObjectName("com.example:type=QueueSamplerMBean");
-//
-//        // Create the Queue Sampler MXBean
-//        Queue<String> queue = new ArrayBlockingQueue<>(10);
-//        queue.add("Request-1");
-//        queue.add("Request-2");
-//        queue.add("Request-3");
-//        QueueSampler mxbean = new QueueSampler(queue);
-//        QueueSamplerBean mbean = new QueueSamplerBean(queue);
-//
-//        // Register the Queue Sampler MXBean
-//        mbs.registerMBean(mxbean, mxbeanName);
-//        mbs.registerMBean(mbean, mbeanName);
-    }
-
-    private void print_content(HttpURLConnection con) {
-        if (con != null) {
-            try {
-                System.out.println("****** Content of the URL ********");
-                int status = con.getResponseCode();
-
-                System.out.println("Status = " + status);
-                InputStream is;
-                if (status == HttpURLConnection.HTTP_OK) {
-                    is = con.getInputStream();
-                } else {
-                    is = con.getErrorStream();
-                }
-                BufferedReader br
-                        = new BufferedReader(new InputStreamReader(is));
-                String input;
-                while ((input = br.readLine()) != null) {
-                    System.out.println(URLDecoder.decode(input, CHARSET));
-                }
-                br.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private void print_https_cert(HttpsURLConnection con) {
-        if (con != null) {
-            try {
-                System.out.println("Response Code : " + con.getResponseCode());
-                System.out.println("Cipher Suite : " + con.getCipherSuite());
-                System.out.println("\n");
-
-                Certificate[] certs = con.getServerCertificates();
-                for (Certificate cert : certs) {
-                    System.out.println("Cert Type : " + cert.getType());
-                    System.out.println("Cert Hash Code : " + cert.hashCode());
-                    System.out.println("Cert Public Key Algorithm : "
-                            + cert.getPublicKey().getAlgorithm());
-                    System.out.println("Cert Public Key Format : "
-                            + cert.getPublicKey().getFormat());
-                    System.out.println("\n");
-                }
-
-            } catch (SSLPeerUnverifiedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private static SSLContext getSSlContext(String sslConfigFileName) {
-        final String keyStore, keyStorePassword, trustStore, trustStorePassword;
-
-        try {
-            Properties p = new Properties();
-            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
-            p.load(bin);
-            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
-            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
-            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
-            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
-
-            char[] keyStorePasswd = null;
-            if (keyStorePassword.length() != 0) {
-                keyStorePasswd = keyStorePassword.toCharArray();
-            }
-
-            char[] trustStorePasswd = null;
-            if (trustStorePassword.length() != 0) {
-                trustStorePasswd = trustStorePassword.toCharArray();
-            }
-
-            KeyStore ks = null;
-            if (keyStore != null) {
-                ks = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream ksfis = new FileInputStream(keyStore);
-                ks.load(ksfis, keyStorePasswd);
-
-            }
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
-                    KeyManagerFactory.getDefaultAlgorithm());
-            kmf.init(ks, keyStorePasswd);
-
-            KeyStore ts = null;
-            if (trustStore != null) {
-                ts = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream tsfis = new FileInputStream(trustStore);
-                ts.load(tsfis, trustStorePasswd);
-            }
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
-                    TrustManagerFactory.getDefaultAlgorithm());
-            tmf.init(ts);
-
-            SSLContext ctx = SSLContext.getInstance("SSL");
-            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-            return ctx;
-        } catch (Exception ex) {
-            Logger.getLogger(PlatformRestAdapter.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        return null;
-    }
-}
--- a/test/jdk/javax/management/remote/rest/RestAdapterTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/test/jdk/javax/management/remote/rest/RestAdapterTest.java	Mon Jan 01 23:59:14 2018 +0530
@@ -1,221 +1,657 @@
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.security.KeyStore;
-import java.util.Base64;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.remote.rest.PlatformRestAdapter;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-import org.testng.annotations.Test;
+import com.oracle.jmx.remote.rest.http.HttpResponse;
+import com.oracle.jmx.remote.rest.http.HttpUtil;
+import com.oracle.jmx.remote.rest.json.JSONArray;
+import com.oracle.jmx.remote.rest.json.JSONElement;
+import com.oracle.jmx.remote.rest.json.JSONObject;
+import com.oracle.jmx.remote.rest.json.JSONPrimitive;
+import com.oracle.jmx.remote.rest.json.parser.JSONParser;
+import com.oracle.jmx.remote.rest.mapper.JSONMapper;
+import com.oracle.jmx.remote.rest.mapper.JSONMappingFactory;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-/**
- * @test @modules java.logging java.management java.management.rest
- * @run testng/othervm RestAdapterTest
- *
- */
+import javax.management.*;
+import javax.management.remote.*;
+import javax.management.remote.rest.PlatformRestAdapter;
+import java.io.*;
+import java.lang.management.ManagementFactory;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 @Test
 public class RestAdapterTest {
 
-    private static final String CHARSET = "UTF-8";
-    private static String sslAgentConfig;
-    private static String sslClientConfig;
-    private static String passwordFile;
-    private static String configFile;
+    private JMXConnectorServer cs;
+    private String restUrl = "";
+    JMXConnector connector;
 
-    private void createAgentSslConfigFile(String fileName) throws IOException {
-        File f = new File(fileName);
+    @BeforeClass
+    public void setupServers() throws IOException {
+        MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+        JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
+        cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, platformMBeanServer);
+        cs.start();
+        JMXServiceURL addr = cs.getAddress();
+        connector = JMXConnectorFactory.connect(addr, null);
+
+        System.setProperty("test.src", System.getProperty("user.dir") + "/test");
+
+        String testSrcRoot = System.getProperty("test.src") + File.separator;
+        String configFile = testSrcRoot + "mgmt.properties";
+        File f = new File(configFile);
+        Properties properties = null;
         if (f.exists()) {
-            return;
+            properties = new Properties();
+            properties.load(new FileInputStream(f));
         }
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreAgent");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreAgent");
-        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
+
+        PlatformRestAdapter.init(properties);
+        restUrl = PlatformRestAdapter.getBaseURL();
+    }
 
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
+    @AfterClass
+    public void tearDownServers() throws IOException {
+        connector.close();
+        cs.stop();
+        PlatformRestAdapter.stop();
+    }
+
+    private Set<String> rmiGetAllMBeans() {
+        try {
+            MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
+            Set<ObjectInstance> objectInstances = mBeanServer.queryMBeans(null, null);
+            return objectInstances.stream().map(a -> a.getObjectName().toString()).collect(Collectors.toSet());
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
         }
     }
 
-    private void createClientSslConfigFile(String fileName) throws IOException {
-        File f = new File(fileName);
-        if (f.exists()) {
-            return;
-        }
-        Properties props = new Properties();
-        String testDir = System.getProperty("test.src");
-        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreClient");
-        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
-        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreClient");
-        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
+    private Map<String, Object> rmiGetAttributes(String name) {
+        try {
+            MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
+            ObjectName objectName = new ObjectName(name);
+            MBeanInfo mInfo = mBeanServer.getMBeanInfo(objectName);
+            String[] attrs = Stream.of(mInfo.getAttributes())
+                    .map(MBeanAttributeInfo::getName)
+                    .toArray(String[]::new);
+
+            Map<String, Object> result = new LinkedHashMap<>();
+            AttributeList attrVals = mBeanServer.getAttributes(objectName, attrs);
+            List<String> missingAttrs = new ArrayList<>(Arrays.asList(attrs));
+            attrVals.asList().forEach(a -> {
+                missingAttrs.remove(a.getName());
+                result.put(a.getName(), a.getValue());
+            });
 
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
+            for (String attr : missingAttrs) {
+                try {
+                    mBeanServer.getAttribute(objectName, attr);
+                    result.put(attr, "< Error: No such attribute >");
+                } catch (RuntimeException ex) {
+                    if (ex.getCause() instanceof UnsupportedOperationException) {
+                        result.put(attr, "< Attribute not supported >");
+                    } else if (ex.getCause() instanceof IllegalArgumentException) {
+                        result.put(attr, "< Invalid attributes >");
+                    }
+                } catch (AttributeNotFoundException e) {
+                    result.put(attr, "< Attribute not found >");
+                }
+            }
+            return result;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
         }
     }
 
-    private void setupMgmtConfig(String fileName) throws IOException {
-        Properties props = new Properties();
-
-        props.setProperty("com.sun.management.jmxremote.ssl", "true");
-        props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
-        props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
-        props.setProperty("com.sun.management.jmxremote.rest.port", "0");
-
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
-            props.store(writer, "");
+    private Set<String> rmiGetOperations(String name) {
+        try {
+            MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
+            ObjectName objectName = new ObjectName(name);
+            MBeanOperationInfo[] operationInfos = mBeanServer.getMBeanInfo(objectName).getOperations();
+            Set<String> rmiOps = Stream.of(operationInfos)
+                    .map(MBeanFeatureInfo::getName).collect(Collectors.toSet());
+            return rmiOps;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
         }
     }
 
-    private void setupConfig() throws Exception {
-        String testSrcRoot = System.getProperty("test.src") + File.separator;
-        sslAgentConfig = testSrcRoot + "sslConfigAgent";
-        sslClientConfig = testSrcRoot + "sslConfigClient";
-        passwordFile = testSrcRoot + "password.properties";
-        configFile = testSrcRoot + "mgmt.properties";
-        createAgentSslConfigFile(sslAgentConfig);
-        createClientSslConfigFile(sslClientConfig);
-        setupMgmtConfig(configFile);
+    private Set<String> restGetAllMBeans() {
+        try {
+            String url = restUrl + "/platform/mbeans";
+            Set<String> mbeanNames = new HashSet<>();
+            do {
+                HttpResponse httpResponse = executeHttpRequest(url);
+                if (httpResponse.getCode() != 200)
+                    throw new RuntimeException(httpResponse.getBody());
+
+                String firstPage = httpResponse.getBody();
+                JSONParser parser = new JSONParser(firstPage);
+                JSONObject root = (JSONObject) parser.parse();
+                JSONArray mbeansNode = (JSONArray) root.get("mbeans");
+                for (JSONElement je : mbeansNode) {
+                    JSONObject jobj = (JSONObject) je;
+                    JSONPrimitive jp = (JSONPrimitive) jobj.get("name");
+                    String name = (String) jp.getValue();
+                    mbeanNames.add(name);
+                }
+
+                JSONObject linkObj = (JSONObject) root.get("_links");
+                if (linkObj == null) {
+                    break;
+                }
+                if (linkObj.get("next") == null)
+                    break;
+
+                JSONPrimitive element = (JSONPrimitive) linkObj.get("next");
+                String nextUrl = (String) element.getValue();
+                if (nextUrl.equalsIgnoreCase(url)) {
+                    break;
+                } else {
+                    url = nextUrl;
+                }
+            } while (true);
+            return mbeanNames;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
-    @BeforeClass
-    public void setupAdapter() throws Exception {
-        setupConfig();
-        File file = new File(configFile);
-        Properties props = new Properties();
-        props.load(new FileInputStream(file));
-        if (props.get("com.sun.management.jmxremote.rest.port") != null) {
-            PlatformRestAdapter.init((String) props.get("com.sun.management.jmxremote.rest.port"), props);
+    private JSONObject restGetAttributes(String name) {
+        try {
+            String url = "/platform/mbeans/" + name;
+            HttpResponse httpResponse = executeHttpRequest(url);
+            if (httpResponse.getCode() == 200) {
+                JSONParser parser = new JSONParser(httpResponse.getBody());
+                JSONElement root = parser.parse();
+                JSONElement element = ((JSONObject) root).get("attributes");
+                if (element != null && element instanceof JSONObject)
+                    return (JSONObject) element;
+                else {
+                    return new JSONObject();
+                }
+            } else {
+                throw new RuntimeException("HTTP GET for [" + url + "] failed, response = " + httpResponse.getBody());
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
         }
-        SSLContext ctx = getSSlContext(sslClientConfig);
-        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
-        HttpsURLConnection.setDefaultHostnameVerifier(
-                (String hostname, javax.net.ssl.SSLSession sslSession) -> hostname.equals("Harsha-Wardhana-B"));
-    }
-
-    @AfterClass
-    public void tearDown() {
-        PlatformRestAdapter.stop();
     }
 
-    private static SSLContext getSSlContext(String sslConfigFileName) {
-        final String keyStore, keyStorePassword, trustStore, trustStorePassword;
-
+    private JSONArray restGetOperations(String name) {
         try {
-            Properties p = new Properties();
-            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
-            p.load(bin);
-            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
-            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
-            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
-            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
+            String url = "/platform/mbeans/" + name;
+            HttpResponse httpResponse = executeHttpRequest(url);
+            if (httpResponse.getCode() == 200) {
+                JSONParser parser = new JSONParser(httpResponse.getBody());
+                JSONElement root = parser.parse();
+                JSONElement element = ((JSONObject) root).get("operations");
+                if (element != null && element instanceof JSONArray)
+                    return (JSONArray) element;
+                else {
+                    return new JSONArray();
+                }
+            } else {
+                throw new RuntimeException("HTTP GET for [" + url + "] failed, response = " + httpResponse.getBody());
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
 
-            char[] keyStorePasswd = null;
-            if (keyStorePassword.length() != 0) {
-                keyStorePasswd = keyStorePassword.toCharArray();
-            }
-
-            char[] trustStorePasswd = null;
-            if (trustStorePassword.length() != 0) {
-                trustStorePasswd = trustStorePassword.toCharArray();
-            }
+    private HttpResponse executeHttpRequest(String inputUrl) {
+        return executeHttpRequest(inputUrl, "", false);
+    }
 
-            KeyStore ks = null;
-            if (keyStore != null) {
-                ks = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream ksfis = new FileInputStream(keyStore);
-                ks.load(ksfis, keyStorePasswd);
-            }
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
-                    KeyManagerFactory.getDefaultAlgorithm());
-            kmf.init(ks, keyStorePasswd);
+    private HttpResponse executeHttpRequest(String inputUrl, String body, boolean isPost) {
+        try {
+            if (inputUrl != null && !inputUrl.isEmpty()) {
+                URL url;
+                if (!inputUrl.startsWith("http")) {
+                    url = new URL(HttpUtil.escapeUrl(restUrl + inputUrl));
+                } else {
+                    url = new URL(inputUrl);
+                }
+                HttpURLConnection con = (HttpURLConnection) url.openConnection();
+                con.setRequestProperty("Content-Type", "application/json;");
+                String userCredentials = "username1:password1";
+                String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
+                con.setRequestProperty("Authorization", basicAuth);
+                if (isPost) {
+                    con.setDoOutput(true);
+                    con.setRequestMethod("POST");
+
+                    try (OutputStreamWriter out = new OutputStreamWriter(
+                            con.getOutputStream())) {
+                        out.write(body);
+                        out.flush();
+                    }
+                } else {
+                    con.setDoOutput(false);
+                }
 
-            KeyStore ts = null;
-            if (trustStore != null) {
-                ts = KeyStore.getInstance(KeyStore.getDefaultType());
-                FileInputStream tsfis = new FileInputStream(trustStore);
-                ts.load(tsfis, trustStorePasswd);
+                try {
+                    int status = con.getResponseCode();
+                    StringBuilder sbuf;
+                    if (status == 200) {
+                        try (BufferedReader br = new BufferedReader(
+                                new InputStreamReader(con.getInputStream()))) {
+                            sbuf = new StringBuilder();
+                            String input;
+                            while ((input = br.readLine()) != null) {
+                                sbuf.append(input);
+                            }
+                        }
+                    } else {
+                        try (BufferedReader br = new BufferedReader(
+                                new InputStreamReader(con.getErrorStream()))) {
+                            sbuf = new StringBuilder();
+                            String input;
+                            while ((input = br.readLine()) != null) {
+                                sbuf.append(input);
+                            }
+                        }
+                    }
+                    return new HttpResponse(status, sbuf.toString());
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
             }
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
-                    TrustManagerFactory.getDefaultAlgorithm());
-            tmf.init(ts);
-
-            SSLContext ctx = SSLContext.getInstance("SSL");
-            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-            return ctx;
         } catch (Exception ex) {
-            Logger.getLogger(PlatformRestAdapter.class.getName()).log(Level.SEVERE, null, ex);
+            throw new RuntimeException(ex);
         }
         return null;
     }
 
-    private String executeHttpRequest(String inputUrl, String charset) throws IOException {
-        if (inputUrl != null) {
-            URL url = new URL(PlatformRestAdapter.getBaseURL() + (charset != null ? URLEncoder.encode(inputUrl, charset) : inputUrl));
-            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
-            con.setDoOutput(false);
-            String userCredentials = "username1:password1";
-            String basicAuth = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes());
-            con.setRequestProperty("Authorization", basicAuth);
-            if (charset != null && !charset.isEmpty()) {
-                con.setRequestProperty("Content-Type", "application/json; charset=" + charset);
+    private void verifyHttpResponse(HttpResponse httpResponse) {
+        try {
+            Assert.assertEquals(httpResponse.getCode(), 200);
+            JSONParser parser = new JSONParser(httpResponse.getBody());
+            parser.parse();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private JSONObject restGetMBeanOperationsBulkOp(String name) {
+        JSONArray jsonArray = restGetOperations(name);
+        JSONArray ops = jsonArray.stream()
+                .filter(a -> ((JSONObject) a).get("arguments") == null)
+                .map((JSONElement a) -> ((JSONObject) a).get("name"))
+                .collect(Collectors.toCollection(JSONArray::new));
+        JSONObject result = new JSONObject();
+        if (ops != null && !ops.isEmpty()) {
+            result.put("operations", ops);
+        }
+        return result;
+    }
+
+    private JSONObject restGetMBeanAttributeBulkOp(String name) {
+        try {
+            MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
+            ObjectName objectName = new ObjectName(name);
+
+            MBeanAttributeInfo[] attrInfos = mBeanServer.getMBeanInfo(objectName).getAttributes();
+            Set<String> writableAttrs = Stream.of(attrInfos)
+                    .filter(MBeanAttributeInfo::isWritable)
+                    .map(MBeanFeatureInfo::getName).collect(Collectors.toSet());
+
+            JSONObject writeAttrMap = new JSONObject();
+            List<String> invalidAttrs = Arrays.asList("< Attribute not supported >",
+                    "< Invalid attributes >",
+                    "< Attribute not found >",
+                    "< Error: No such attribute >");
+
+            JSONObject attrMap = restGetAttributes(name);
+            writableAttrs.stream().filter(a -> {
+                JSONElement element = attrMap.get(a);
+                if (element instanceof JSONPrimitive
+                        && ((JSONPrimitive) element).getValue() instanceof String) {
+                    String attrVal = (String) ((JSONPrimitive) element).getValue();
+                    if (invalidAttrs.contains(attrVal))
+                        return false;
+                }
+                return true;
+            }).forEach(a -> writeAttrMap.put(a, attrMap.get(a)));
+
+            JSONObject jsonObject = new JSONObject();
+            JSONArray attrs = new JSONArray();
+            attrMap.keySet().forEach(a -> attrs.add(new JSONPrimitive(a)));
+            if (attrs != null && !attrs.isEmpty()) {
+                jsonObject.put("get", attrs);
             }
-            try {
-                int status = con.getResponseCode();
-                if (status == 200) {
+            if (writeAttrMap != null && !writeAttrMap.isEmpty()) {
+                jsonObject.put("set", writeAttrMap);
+            }
+
+            JSONObject result = new JSONObject();
+            if (jsonObject != null && !jsonObject.isEmpty()) {
+                result.put("attributes", jsonObject);
+            }
+            return result;
+        } catch (Exception ex) {
+            ex.getCause().printStackTrace();
+            throw new RuntimeException(ex);
+        }
+    }
+
+    @DataProvider(name = "allMBeans")
+    private Object[][] allMBeans() {
+        Set<String> names = restGetAllMBeans();
+        Object[] objects = names.stream().toArray(Object[]::new);
+        Object[][] result = new Object[objects.length][1];
+        for (int i = 0; i < objects.length; i++) {
+            result[i][0] = objects[i];
+        }
+        return result;
+    }
 
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getInputStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(charset != null ? URLDecoder.decode(input, charset) : input);
-                        }
-                    }
-                    return sbuf.toString();
+    @Test
+    public void testAllMBeanServers() {
+        try {
+            HttpResponse httpResponse = executeHttpRequest(restUrl);
+            Assert.assertEquals(httpResponse.getCode(), 200);
+            JSONParser parser = new JSONParser(httpResponse.getBody());
+            JSONObject parse = (JSONObject) parser.parse();
+            JSONArray links = (JSONArray) parse.get("mBeanServers");
+            for(JSONElement elem : links) {
+                JSONObject jobj = (JSONObject) elem;
+                String link = (String) ((JSONPrimitive)jobj.get("href")).getValue();
+                HttpResponse hr = executeHttpRequest(link);
+                Assert.assertEquals(httpResponse.getCode(), 200);
+                JSONParser parser1 = new JSONParser(hr.getBody());
+                JSONObject parse1 = (JSONObject) parser1.parse();
+                JSONObject links1 = (JSONObject) parse1.get("_links");
+                String link3 = (String) ((JSONPrimitive)links1.get("mbeans")).getValue();
+                verifyHttpResponse(executeHttpRequest(link3));
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    @Test
+    public void testAllMBeans() {
+        Set<String> restMbeans = restGetAllMBeans();
+        Set<String> rmiMbeans = rmiGetAllMBeans();
+        long count = restMbeans.stream().filter(mbeanName -> !rmiMbeans.contains(mbeanName)).count();
+        Assert.assertEquals(count, 0);
+    }
+
+    public void testMBeanFiltering() {
+        String url = restUrl + "/platform/mbeans?";
+        List<String> filtersOk = Arrays.asList("query=*:type=DiagnosticCommand,*",
+        "query=java.lang:*&page=2",
+        "query=java.lang:*&page=1",
+        "query=*:type=Diag*");
+
+        List<String> filtersKo = Arrays.asList("","*:type=DiagnosticCommand,*","query=java.lang:*&page=1&invalid=4");
+
+        for(String filter : filtersOk) {
+            HttpResponse httpResponse = executeHttpRequest(url + filter);
+            Assert.assertEquals(httpResponse.getCode(),200);
+        }
+
+        for(String filter : filtersKo) {
+            HttpResponse httpResponse = executeHttpRequest(url + filter);
+            Assert.assertEquals(httpResponse.getCode(),HttpURLConnection.HTTP_BAD_REQUEST);
+        }
+    }
+
+    @Test
+    public void testAllMBeanInfo() {
+        Set<String> names = restGetAllMBeans();
+        for (String name : names) {
+            String url = "/platform/mbeans/" + name + "/info";
+            HttpResponse httpResponse = executeHttpRequest(url);
+            verifyHttpResponse(httpResponse);
+        }
+    }
+
+    @Test(priority = 3)
+    public void testMbeanNoArgOperations() {
+        Set<String> mbeans = restGetAllMBeans();
+        for (String name : mbeans) {
+            JSONArray restoperations = restGetOperations(name);
+            Set<String> rmiOps = rmiGetOperations(name);
+            Set<String> restOps = restoperations.stream().map((JSONElement a) -> {
+                JSONElement elem = ((JSONObject) a).get("name");
+                if (elem instanceof JSONPrimitive
+                        && (((JSONPrimitive) elem).getValue() instanceof String)) {
+                    return (String) ((JSONPrimitive) elem).getValue();
                 } else {
-                    StringBuilder sbuf;
-                    try (BufferedReader br = new BufferedReader(
-                            new InputStreamReader(con.getErrorStream()))) {
-                        sbuf = new StringBuilder();
-                        String input;
-                        while ((input = br.readLine()) != null) {
-                            sbuf.append(charset != null ? URLDecoder.decode(input, charset) : input);
-                        }
-                    }
-                    return sbuf.toString();
+                    return null;
                 }
-            } catch (IOException e) {
+            }).collect(Collectors.toSet());
+            Assert.assertEquals(rmiOps, restOps);
+
+            for (JSONElement jsonElement : restoperations) {
+                JSONObject jsonObject = (JSONObject) jsonElement;
+                String opUrl = (String) ((JSONPrimitive) jsonObject.get("href")).getValue();
+                if (jsonObject.get("arguments") == null) {
+                    HttpResponse httpResponse = executeHttpRequest(opUrl, "", true);
+                    verifyHttpResponse(httpResponse);
+                }
             }
         }
-        return null;
+    }
+
+    @Test(priority = 2)
+    public void testMBeanSetAttributes() {
+        try {
+            Set<String> mbeans = restGetAllMBeans();
+            MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
+            for (String name : mbeans) {
+                ObjectName objectName = new ObjectName(name);
+                String url = "/platform/mbeans/" + objectName.toString();
+                JSONObject attrMap = restGetAttributes(name);
+                MBeanAttributeInfo[] attrInfos = mBeanServer.getMBeanInfo(objectName).getAttributes();
+                Set<String> writableAttrs = Stream.of(attrInfos)
+                        .filter(MBeanAttributeInfo::isWritable)
+                        .map(MBeanFeatureInfo::getName).collect(Collectors.toSet());
+
+                if (writableAttrs.isEmpty())
+                    continue;
+
+                JSONObject writeAttrMap = new JSONObject();
+                List<String> invalidAttrs = Arrays.asList(new String[]{"< Attribute not supported >",
+                        "< Invalid attributes >",
+                        "< Attribute not found >",
+                        "< Error: No such attribute >"});
+
+                writableAttrs.stream().filter(a -> {
+                    JSONElement element = attrMap.get(a);
+                    if (element instanceof JSONPrimitive
+                            && ((JSONPrimitive) element).getValue() instanceof String) {
+                        String attrVal = (String) ((JSONPrimitive) element).getValue();
+                        if (invalidAttrs.contains(attrVal))
+                            return false;
+                    }
+                    return true;
+                }).forEach(a -> writeAttrMap.put(a, attrMap.get(a)));
+                HttpResponse httpResponse = executeHttpRequest(url, writeAttrMap.toJsonString(), true);
+                if (httpResponse.getCode() == 200) {
+                    String body = httpResponse.getBody();
+                    JSONParser parser = new JSONParser(body);
+                    JSONObject jsonObject = (JSONObject) parser.parse();
+                    Assert.assertEquals(jsonObject.size(), writeAttrMap.size());
+                    Assert.assertEquals(jsonObject.keySet(), writeAttrMap.keySet());
+
+                    for (JSONElement elem : jsonObject.values()) {
+                        String output = (String) ((JSONPrimitive) elem).getValue();
+                        Assert.assertEquals(output.equalsIgnoreCase("success"), true);
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    @Test(priority = 1)
+    public void testMBeanGetAttributes() {
+        try {
+            Set<String> mbeans = restGetAllMBeans();
+            for (String name : mbeans) {
+                Map<String, Object> rmiAttrs = rmiGetAttributes(name);
+                JSONMapper typeMapper = JSONMappingFactory.INSTANCE.getTypeMapper(rmiAttrs);
+                JSONObject rmiJson = (JSONObject) typeMapper.toJsonValue(rmiAttrs);
+                JSONObject restJson = restGetAttributes(name);
+                Assert.assertEquals(restJson.size(), rmiJson.size());
+                Assert.assertEquals(rmiJson.keySet(), restJson.keySet());
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
     }
-    
-    @Test
-    public void testMBeanServerCollection() throws IOException {
-        System.out.println(executeHttpRequest("/platform/mbeans/java.lang:type=Runtime",null));
-//        System.out.println(executeHttpRequest("/platform/mbeans/java.lang:name=CodeHeap%20'non-nmethods',type=MemoryPool/info", null));
+
+    @Test(priority = 4)
+    public void testThreadMXBeanBulkRequest() {
+        String name = "java.lang:type=Threading";
+        String url = "/platform/mbeans/java.lang:type=Threading";
+
+        JSONObject jsonObject = restGetAttributes(name);
+        JSONArray jarr = (JSONArray) jsonObject.get("AllThreadIds");
+
+        Long[] threadIds = jarr.stream().map(a -> {
+            if (a instanceof JSONPrimitive && ((JSONPrimitive) a).getValue() instanceof Long) {
+                return (Long) ((JSONPrimitive) a).getValue();
+            } else {
+                return -1;
+            }
+        }).toArray(Long[]::new);
+
+        JSONObject args = new JSONObject();
+        JSONArray array = new JSONArray();
+        Stream.of(threadIds).forEach(a -> array.add(new JSONPrimitive(a)));
+        args.put("p0", array);
+        args.put("p1", new JSONPrimitive(true));
+        args.put("p2", new JSONPrimitive(true));
+        JSONObject jobj1 = new JSONObject();
+        jobj1.put("getThreadInfo", args);
+
+        JSONObject jobj2 = new JSONObject();
+
+        jobj2.putAll(restGetMBeanAttributeBulkOp(name));
+        jobj2.put("operations", jobj1);
+
+        HttpResponse httpResponse = executeHttpRequest(url, jobj2.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+
+        JSONArray arr = new JSONArray();
+        arr.add(new JSONPrimitive("findMonitorDeadlockedThreads"));
+        arr.add(new JSONPrimitive("resetPeakThreadCount"));
+        arr.add(new JSONPrimitive("findDeadlockedThreads"));
+        arr.add(jobj1);
+
+        jobj2.clear();
+        jobj2.putAll(restGetMBeanAttributeBulkOp(name));
+        jobj2.put("operations", arr);
+
+        httpResponse = executeHttpRequest(url, jobj2.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+
+        jobj2.clear();
+        jobj2.putAll(restGetMBeanAttributeBulkOp(name));
+        jobj2.put("operations", "resetPeakThreadCount");
+
+        httpResponse = executeHttpRequest(url, jobj2.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
     }
-}
+
+    @Test(priority = 5)
+    public void testThreadMXBeanThreadInfo() {
+        String name = "java.lang:type=Threading";
+
+        JSONObject jsonObject = restGetAttributes(name);
+        JSONArray jarr = (JSONArray) jsonObject.get("AllThreadIds");
+
+        Long[] threadIds = jarr.stream().map(a -> {
+            if (a instanceof JSONPrimitive && ((JSONPrimitive) a).getValue() instanceof Long) {
+                return (Long) ((JSONPrimitive) a).getValue();
+            } else {
+                return -1;
+            }
+        }).toArray(Long[]::new);
+
+        JSONArray operations = restGetOperations("java.lang:type=Threading");
+
+        JSONObject threadInfoRequest = (JSONObject) operations.stream()
+                .filter(a -> {
+                    JSONObject jobj = (JSONObject) a;
+                    JSONElement elem = ((JSONObject) a).get("name");
+                    if (elem instanceof JSONPrimitive
+                            && (((JSONPrimitive) elem).getValue() instanceof String)) {
+                        return ((JSONPrimitive) elem).getValue().equals("getThreadInfo");
+                    } else {
+                        return false;
+                    }
+                }).findFirst().get();
+
+        String postUrl1 = (String) ((JSONPrimitive) threadInfoRequest.get("href")).getValue();
+
+        // Build arguments
+        // 1. getThreadInfo(long id)
+        JSONObject args = new JSONObject();
+        args.put("p0", new JSONPrimitive(threadIds[0]));
+        HttpResponse httpResponse = executeHttpRequest(postUrl1, args.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+        args.clear();
+
+        // 2. getThreadInfo(long[] ids)
+        JSONArray array = new JSONArray();
+        Stream.of(threadIds).forEach(a -> array.add(new JSONPrimitive(a)));
+        args.put("p0", array);
+        httpResponse = executeHttpRequest(postUrl1, args.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+
+        //3. getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers)
+        args.put("p1", new JSONPrimitive(true));
+        args.put("p2", new JSONPrimitive(true));
+        httpResponse = executeHttpRequest(postUrl1, args.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+        args.clear();
+
+        //4. getThreadInfo(long id, int maxDepth)
+        args.put("p0", new JSONPrimitive(threadIds[0]));
+        args.put("p1", new JSONPrimitive(10));
+        httpResponse = executeHttpRequest(postUrl1, args.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+        args.clear();
+
+        //5. getThreadInfo(long[] ids, int maxDepth)
+        JSONArray jarr1 = new JSONArray();
+        Stream.of(threadIds).forEach(a -> jarr1.add(new JSONPrimitive(a)));
+        args.put("p0", jarr1);
+        args.put("p1", new JSONPrimitive(10));
+        httpResponse = executeHttpRequest(postUrl1, args.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+    }
+
+    @Test(priority = 4)
+    public void testAllMBeansBulkRequest() {
+        Set<String> allNames = restGetAllMBeans();
+        String url = restUrl + "/platform/mbeans";
+        JSONObject result = new JSONObject();
+        for (String name : allNames) {
+            JSONObject attrNode = restGetMBeanAttributeBulkOp(name);
+            JSONObject opsNode = restGetMBeanOperationsBulkOp(name);
+            JSONObject jobj = new JSONObject();
+            if (attrNode != null && !attrNode.isEmpty()) {
+                jobj.putAll(attrNode);
+            }
+            if (opsNode != null && !opsNode.isEmpty()) {
+                jobj.putAll(opsNode);
+            }
+            result.put(name, jobj);
+        }
+        HttpResponse httpResponse = executeHttpRequest(url, result.toJsonString(), true);
+        verifyHttpResponse(httpResponse);
+    }
+}
\ No newline at end of file
--- a/test/jdk/javax/management/remote/rest/RunRestAdapter.java	Thu Dec 28 20:34:32 2017 +0530
+++ b/test/jdk/javax/management/remote/rest/RunRestAdapter.java	Mon Jan 01 23:59:14 2018 +0530
@@ -5,7 +5,6 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Properties;
-import java.util.Scanner;
 import javax.management.remote.rest.PlatformRestAdapter;
 
 
@@ -23,6 +22,7 @@
 
     public static void main(String[] args) throws Exception {
         RunRestAdapter rr = new RunRestAdapter();
+        System.setProperty("test.src",System.getProperty("user.dir") + "/test");
         rr.run();
         while (true)
         {
@@ -64,7 +64,7 @@
         }
     }
 
-    private void setupMgmtConfig(String fileName) throws IOException {
+    private void setupManagementConfig(String fileName) throws IOException {
         Properties props = new Properties();
         props.setProperty("com.sun.management.jmxremote.ssl", "true");
         props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
@@ -84,7 +84,7 @@
         configFile = testSrcRoot + "mgmt1.properties";
         createAgentSslConfigFile(sslAgentConfig);
         createClientSslConfigFile(sslClientConfig);
-        setupMgmtConfig(configFile);
+        setupManagementConfig(configFile);
     }
 
     public void run() throws Exception {
--- a/test/jdk/javax/management/remote/rest/data/QueueSample.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-package javax.management.remote.rest.test.data;
-
-/*
- * QueueSample.java - Java type representing a snapshot of a given queue.
- * It bundles together the instant time the snapshot was taken, the queue
- * size and the queue head.
- */
-
-
-
-import java.beans.ConstructorProperties;
-import java.util.Date;
-
-public class QueueSample {
-    
-    private final Date date;
-    private final int size;
-    private final String head;
-
-    @ConstructorProperties({"date", "size", "head"})
-    public QueueSample(Date date, int size, String head) {
-        this.date = date;
-        this.size = size;
-        this.head = head;
-    }
-
-    public Date getDate() {
-        return date;
-    }
-
-    public int getSize() {
-        return size;
-    }
-
-    public String getHead() {
-        return head;
-    }
-}
--- a/test/jdk/javax/management/remote/rest/data/QueueSampler.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-package javax.management.remote.rest.test.data;
-
-/*
- * QueueSampler.java - MXBean implementation for the QueueSampler MXBean.
- * This class must implement all the Java methods declared in the
- * QueueSamplerMXBean interface, with the appropriate behavior for each one.
- */
-
-
-import java.util.Date;
-import java.util.List;
-import java.util.Queue;
-
-public class QueueSampler implements QueueSamplerMXBean {
-
-    private Queue<String> queue;
-    private QueueSample sample;
-    private String name;
-
-    public QueueSampler(Queue<String> queue) {
-        this.queue = queue;
-        synchronized (queue) {
-            sample = new QueueSample(new Date(), queue.size(), queue.peek());
-        }
-        name = "BoogeyMan";
-    }
-
-    public QueueSample getQueueSample() {
-        return sample;
-    }
-    
-    public void clearQueue() {
-        synchronized (queue) {
-            queue.clear();
-        }
-    }
-
-    @Override
-    public String[] testMethod1(int[] param2, String param1, int sd34, String[] param3, QueueSample[] param4, List<QueueSample> param5) {
-        System.out.println("########## Invoke TestMethod1");
-        return new String[]{"1","2","3","4","5"};
-    }
-
-    @Override
-    public void setQueueSample(QueueSample sample) {
-        this.sample = sample;
-    }
-
-    @Override
-    public String getQueueName() {
-        return name;
-    }
-
-    @Override
-    public void setQueueName(String name) {
-        this.name = name;
-    }
-}
--- a/test/jdk/javax/management/remote/rest/data/QueueSamplerBean.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package javax.management.remote.rest.test.data;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Queue;
-
-/**
- *
- * @author harsha
- */
-public class QueueSamplerBean implements QueueSamplerBeanMBean {
-
-    private Queue<String> queue;
-    private QueueSample sample;
-    private String name;
-
-    public QueueSamplerBean(Queue<String> queue) {
-        this.queue = queue;
-        synchronized (queue) {
-            sample = new QueueSample(new Date(), queue.size(), queue.peek());
-        }
-        name = "BoogeyMan";
-    }
-
-    public QueueSample getQueueSample() {
-        return sample;
-    }
-    
-    public void clearQueue() {
-        synchronized (queue) {
-            queue.clear();
-        }
-    }
-
-    @Override
-    public String[] testMethod1(int[] param2, String param1, int sd34, String[] param3, QueueSample[] param4, List<QueueSample> param5) {
-        return new String[]{"1","2","3","4","5"};
-    }
-
-    @Override
-    public void setQueueSample(QueueSample sample) {
-        this.sample = sample;
-    }
-
-    @Override
-    public String getQueueName() {
-        return name;
-    }
-
-    @Override
-    public void setQueueName(String name) {
-        this.name = name;
-    }    
-}
--- a/test/jdk/javax/management/remote/rest/data/QueueSamplerBeanMBean.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package javax.management.remote.rest.test.data;
-
-import java.util.List;
-
-/**
- *
- * @author harsha
- */
-public interface QueueSamplerBeanMBean {
-        public QueueSample getQueueSample();
-    
-    public void setQueueSample(QueueSample sample);
-
-    public String getQueueName();
-    
-    public void setQueueName(String name);
-    
-    public void clearQueue();
-
-    public String[] testMethod1(int[] param2, String param1, int sd34, String[] param3, QueueSample[] param4, List<QueueSample> param5);
-}
--- a/test/jdk/javax/management/remote/rest/data/QueueSamplerMXBean.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-package javax.management.remote.rest.test.data;
-
-
-import java.util.List;
-
-public interface QueueSamplerMXBean {
-    
-    public QueueSample getQueueSample();
-    
-    public void setQueueSample(QueueSample sample);
-
-    public String getQueueName();
-    
-    public void setQueueName(String name);
-    
-    public void clearQueue();
-
-    public String[] testMethod1(int[] param2, String param1, int sd34, String[] param3, QueueSample[] param4, List<QueueSample> param5);
-}
--- a/test/jdk/javax/management/remote/rest/json/JSONTest.java	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,408 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-import com.oracle.jmx.remote.rest.json.parser.JSONParser;
-import com.oracle.jmx.remote.rest.json.parser.ParseException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * @test @modules java.management.rest
- * @run main JSONTest
- */
-public class JSONTest {
-
-    public static void main(String[] args) throws ParseException {
-        JSONGraphGenerator graphGen = new JSONGraphGenerator(50);
-        JSONElement jElem = graphGen.generateJsonGraph(20000);
-        System.out.println("Graph Generated");
-        String str = jElem.toJsonString();
-        System.out.println(str);
-
-        JSONParser parser = new JSONParser(str);
-
-        com.oracle.jmx.remote.rest.json.JSONElement parse = parser.parse();
-        String resultJson = parse.toJsonString();
-        System.out.println(resultJson);
-    }
-}
-
-interface JSONElement {
-
-    String toJsonString();
-}
-
-interface Visitable {
-
-    public void accept(NodeVisitor visitor);
-}
-
-interface NodeVisitor {
-
-    public void visit(Node node);
-
-    //visit other concrete items
-    public void visit(Digit19 digit12);
-
-    public void visit(Digits dvd);
-}
-
-class Node implements Visitable {
-
-    final private String label;
-
-    public Node(String label) {
-        children = new LinkedList<>();
-        this.label = label;
-    }
-
-    public Node() {
-        this("");
-    }
-
-    public void add(Node node) {
-        if (!children.contains(node)) {
-            children.add(node);
-        }
-    }
-
-    public String getLabel() {
-        return label;
-    }
-    List<Node> children;
-
-    @Override
-    public void accept(NodeVisitor visitor) {
-        visitor.visit(this);
-    }
-}
-
-class Digit19 extends Node {
-
-    Random rnd = new Random();
-
-    public Digit19() {
-        super();
-    }
-
-    @Override
-    public String getLabel() {
-        return "" + (rnd.nextInt(9) + 1);
-    }
-}
-
-class Digits extends Node {
-
-    Random rnd = new Random();
-
-    public Digits() {
-        super();
-    }
-
-    @Override
-    public String getLabel() {
-        return "" + (rnd.nextInt(10));
-    }
-}
-
-class JSONNumberGenerator {
-
-    private final static Node root;
-    Number num;
-
-    static {
-        root = new Node("R");
-        Node minus1 = new Node("-");
-        Node zero = new Node("0");
-        Node digit19 = new Digit19();
-        Node digits1 = new Digits();
-        Node dot = new Node(".");
-        Node digits2 = new Digits();
-        Node e = new Node("e");
-        Node E = new Node("E");
-        Node plus = new Node("+");
-        Node minus2 = new Node("-");
-        Node digits3 = new Digits();
-        Node terminal = new Node("T");
-
-        root.add(zero);
-        root.add(minus1);
-        root.add(digit19);
-
-        minus1.add(zero);
-        minus1.add(digit19);
-
-        zero.add(dot);
-//        zero.add(e);
-//        zero.add(E);
-        zero.add(terminal);
-
-        digit19.add(dot);
-        digit19.add(digits1);
-//        digit19.add(e);
-//        digit19.add(E);
-        digit19.add(terminal);
-
-        digits1.add(dot);
-        digits1.add(digits1);
-//        digits1.add(e);
-//        digits1.add(E);
-        digits1.add(terminal);
-
-        dot.add(digits2);
-
-        digits2.add(digits2);
-        digits2.add(e);
-        digits2.add(E);
-        digits2.add(terminal);
-
-        e.add(plus);
-        e.add(minus2);
-        e.add(digits3);
-
-        E.add(plus);
-        E.add(minus2);
-        E.add(digits3);
-
-        plus.add(digits3);
-        minus2.add(digits3);
-
-        digits3.add(digits3);
-        digits3.add(terminal);
-    }
-
-    private static class NumberNodeVisitor implements NodeVisitor {
-
-        private final StringBuilder sbuf = new StringBuilder();
-        Random rnd = new Random();
-
-        public NumberNodeVisitor() {
-        }
-
-        @Override
-        public void visit(Node node) {
-            if (!node.getLabel().equals("R")) {
-                sbuf.append(node.getLabel());
-            }
-            if (node.children.size() > 0) {
-                Node child = node.children.get(rnd.nextInt(node.children.size()));
-                if (!child.getLabel().equals("T")) {
-                    visit(child);
-                }
-            } else {
-                System.out.println("Found node " + node.getLabel() + " with children : " + node.children.size());
-            }
-        }
-
-        @Override
-        public void visit(Digit19 digit12) {
-            sbuf.append(digit12.getLabel());
-            Node child = digit12.children.get(rnd.nextInt(digit12.children.size()));
-            if (!child.getLabel().equals("T")) {
-                visit(child);
-            }
-        }
-
-        @Override
-        public void visit(Digits digits) {
-            sbuf.append(digits.getLabel());
-            Node child = digits.children.get(rnd.nextInt(digits.children.size()));
-            if (!child.getLabel().equals("T")) {
-                visit(child);
-            }
-        }
-
-        public String getNumber() {
-            return sbuf.toString();
-        }
-
-    }
-
-    public String generate() {
-        NumberNodeVisitor visitor = new NumberNodeVisitor();
-        visitor.visit(root);
-        // System.out.println(visitor.getNumber());
-//        Double.parseDouble(visitor.getNumber());
-        return visitor.getNumber();
-    }
-}
-
-class TestJsonObject extends LinkedHashMap<String, JSONElement> implements JSONElement {
-
-    @Override
-    public String toJsonString() {
-        if (isEmpty()) {
-            return null;
-        }
-
-        StringBuilder sbuild = new StringBuilder();
-        sbuild.append("{");
-        keySet().forEach((elem) -> {
-            sbuild.append(elem).append(": ").
-                    append((get(elem) != null) ? get(elem).toJsonString() : "null").append(",");
-        });
-
-        sbuild.deleteCharAt(sbuild.lastIndexOf(","));
-        sbuild.append("}");
-        return sbuild.toString();
-    }
-}
-
-class TestJsonArray extends ArrayList<JSONElement> implements JSONElement {
-
-    @Override
-    public String toJsonString() {
-        if (isEmpty()) {
-            return null;
-        }
-        StringBuilder sbuild = new StringBuilder();
-        sbuild.append("[");
-        Iterator<JSONElement> itr = iterator();
-        while (itr.hasNext()) {
-            JSONElement val = itr.next();
-            if (val != null) {
-                sbuild.append(val.toJsonString()).append(", ");
-            } else {
-                sbuild.append("null").append(", ");
-            }
-        }
-
-        sbuild.deleteCharAt(sbuild.lastIndexOf(","));
-        sbuild.append("]");
-        return sbuild.toString();
-    }
-}
-
-class TestJsonPrimitive implements JSONElement {
-
-    private final String s;
-
-    public TestJsonPrimitive(String s) {
-        this.s = s;
-    }
-
-    @Override
-    public String toJsonString() {
-        return s;
-    }
-}
-
-class JSONStringGenerator {
-
-    private static final int minStringLength = 0;
-    private static final int maxStringLength = 10;
-
-    private final Random rnd = new Random(System.currentTimeMillis());
-
-    private static final String specials = "\b" + "\f" + "\n" + "\r" + "\t" + "\\" + "\"";    // TODO: Special characters '/', '\', '"', "\\uxxxx"
-    private static final String alphanums = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-    public String generate() {
-        char ch;
-        StringBuilder sbuf = new StringBuilder();
-        int len = minStringLength + rnd.nextInt(maxStringLength - minStringLength + 1);
-        sbuf.append("\"");
-        for (int i = 0; i < len; i++) {
-            if (rnd.nextInt(10) == 1) { // 1/10 chances of a control character
-                ch = specials.charAt(rnd.nextInt(specials.length()));
-            } else {
-//                ch = alphanums.charAt(rnd.nextInt(alphanums.length()));
-                ch = (char) rnd.nextInt(Character.MAX_VALUE + 1);
-            }
-            switch (ch) {
-                case '\"':
-                case '\\':
-                    sbuf.append('\\');
-            }
-            sbuf.append(ch);
-        }
-        sbuf.append("\"");
-        return sbuf.toString();
-    }
-}
-
-class JSONGraphGenerator {
-
-    JSONStringGenerator stringGen;
-    JSONNumberGenerator numGen;
-    private final int maxChildPerNode;
-    static Random rnd = new Random(System.currentTimeMillis());
-
-    public JSONGraphGenerator(int maxChildPerNode) {
-        this.maxChildPerNode = maxChildPerNode;
-        stringGen = new JSONStringGenerator();
-        numGen = new JSONNumberGenerator();
-    }
-
-    private TestJsonPrimitive generatePrimitiveData() {
-        int primitiveTypre = rnd.nextInt(10) + 1;
-        switch (primitiveTypre) {
-            case 1:
-            case 2:
-            case 3:
-            case 4:
-                return new TestJsonPrimitive(stringGen.generate());
-            case 5:
-            case 6:
-            case 7:
-            case 8:
-                return new TestJsonPrimitive(numGen.generate());
-            case 9:
-                return new TestJsonPrimitive(Boolean.toString(rnd.nextBoolean()));
-            case 10:
-                return null;
-        }
-        return null;
-    }
-
-    public TestJsonObject generateJsonObject(int size) {
-        TestJsonObject jobj = new TestJsonObject();
-        if (size <= maxChildPerNode) {
-            for (int i = 0; i < size; i++) {
-                jobj.put(stringGen.generate(), generatePrimitiveData());
-            }
-        } else {
-            int newSize = size;
-            do {
-                int childSize = rnd.nextInt(newSize);
-                jobj.put(stringGen.generate(), generateJsonGraph(childSize));
-                newSize = newSize - childSize;
-            } while (newSize > maxChildPerNode);
-            jobj.put(stringGen.generate(), generateJsonGraph(newSize));
-        }
-        return jobj;
-    }
-
-    public TestJsonArray generateJsonArray(int size) {
-        TestJsonArray array = new TestJsonArray();
-        if (size <= maxChildPerNode) {
-            for (int i = 0; i < size; i++) {
-                array.add(generatePrimitiveData());
-            }
-        } else if (size >= maxChildPerNode) {
-            int newSize = size;
-            do {
-                int childSize = rnd.nextInt(newSize);
-                array.add(generateJsonGraph(childSize));
-                newSize = newSize - childSize;
-            } while (newSize > maxChildPerNode);
-            array.add(generateJsonGraph(newSize));
-        }
-        return array;
-    }
-
-    public JSONElement generateJsonGraph(int size) {
-        if (rnd.nextBoolean()) {
-            return generateJsonArray(size);
-        } else {
-            return generateJsonObject(size);
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/management/remote/rest/json/JsonParserTest.java	Mon Jan 01 23:59:14 2018 +0530
@@ -0,0 +1,49 @@
+package json;
+
+import com.oracle.jmx.remote.rest.json.JSONElement;
+import com.oracle.jmx.remote.rest.json.parser.JSONParser;
+import com.oracle.jmx.remote.rest.json.parser.ParseException;
+import com.oracle.jmx.remote.rest.json.parser.TokenMgrError;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+@Test
+public class JsonParserTest {
+
+    @DataProvider(name = "getOkStrings")
+    Object[][] getOkStrings() {
+        Object[][] output = new Object[5][1];
+        output[0][0] = "\"ac" + "\nde\\bf\"";
+        output[1][0] = "\"abcd\\\"cdef\"";
+        output[2][0] = "\"abcd\\\\cdef\"";
+        output[3][0] = "\"abc\\rdcde\\f\"";
+        output[4][0] = "\"\"";
+        return output;
+    }
+
+    @DataProvider(name = "getKoStrings")
+    Object[][] getKoStrings() {
+        Object[][] output = new Object[3][1];
+        output[0][0] = "\"a\\ef\"";
+        output[1][0] = "\"abg\"cde\"";
+        output[2][0] = "\"a\\\bgcde\"";
+        return output;
+    }
+
+    @Test(dataProvider = "getOkStrings")
+    public void testOk(String input) throws ParseException {
+        JSONParser parser = new JSONParser(input);
+        System.out.println("Input: " + input + ", Output: " +parser.parse().toJsonString());
+    }
+
+    @Test(dataProvider = "getKoStrings")
+    public void testKo(String input) {
+        try{
+            JSONParser parser = new JSONParser(input);
+            JSONElement parse = parser.parse();
+            System.out.println("Input: " + input + ", Output: " + parse.toJsonString());
+            throw new RuntimeException("FAILED");
+        } catch (ParseException ex) {
+        } catch (TokenMgrError error) {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/management/remote/rest/json/JsonTester.java	Mon Jan 01 23:59:14 2018 +0530
@@ -0,0 +1,354 @@
+package json;
+
+import com.oracle.jmx.remote.rest.json.parser.JSONParser;
+import com.oracle.jmx.remote.rest.json.parser.ParseException;
+
+import java.util.*;
+
+/**
+ * Below class tests JSON parser for a randomly generated JSON string.
+ * The Json string is generated by converting a randomly generated tree into a string
+ * Each node in the tree is either a json Object, array or a primitive.
+ * Primitive node generates string, number, boolean or null as a string.
+ * Json Number is generated according to the syntax graph as in json.org
+ * Json string is generated along with all the control characters, and by escaping
+ * only backslash and double quote characters.
+ */
+public class JsonTester {
+
+    static final Random RANDOM = new Random(System.currentTimeMillis());
+    static int maxChildrenPerNode;
+
+    public static void main(String[] args) throws ParseException {
+
+        for(int i=0; i<100; i++) {
+            maxChildrenPerNode = RANDOM.nextInt(90) + 10;
+            int totalNodes = RANDOM.nextInt(90000) + 10000;
+            boolean isArray = RANDOM.nextBoolean();         // Generate either a Json Array or a Json Object
+            JsonNode node;
+            if (isArray) {
+                node = JsonNodeGenerator.ArrayGenerator.generate(totalNodes);
+            } else {
+                node = JsonNodeGenerator.ObjectGenerator.generate(totalNodes);
+            }
+            String str = node.toJsonString();
+            JSONParser parser = new JSONParser(str);
+            com.oracle.jmx.remote.rest.json.JSONElement parse = parser.parse();
+            parse.toJsonString();
+            System.out.println("Finished iteration : " + i + ", Node count :" + totalNodes);
+        }
+    }
+}
+
+
+interface JsonNode {
+
+    class ObjectNode extends LinkedHashMap<String, JsonNode> implements JsonNode {
+
+        @Override
+        public String toJsonString() {
+            if (isEmpty()) {
+                return null;
+            }
+
+            StringBuilder sbuild = new StringBuilder();
+            sbuild.append("{");
+            keySet().forEach((elem) -> sbuild.append(elem).append(": ").
+                    append((get(elem) != null) ? get(elem).toJsonString() : "null").append(","));
+
+            sbuild.deleteCharAt(sbuild.lastIndexOf(","));
+            sbuild.append("}");
+            return sbuild.toString();
+        }
+    }
+
+    class ArrayNode extends ArrayList<JsonNode> implements JsonNode {
+
+        @Override
+        public String toJsonString() {
+            if (isEmpty()) {
+                return null;
+            }
+            StringBuilder sbuild = new StringBuilder();
+            sbuild.append("[");
+            for (JsonNode val : this) {
+                if (val != null) {
+                    sbuild.append(val.toJsonString()).append(", ");
+                } else {
+                    sbuild.append("null").append(", ");
+                }
+            }
+
+            sbuild.deleteCharAt(sbuild.lastIndexOf(","));
+            sbuild.append("]");
+            return sbuild.toString();
+        }
+    }
+
+    class PrimitiveNode implements JsonNode {
+
+        private final String s;
+
+        PrimitiveNode(String s) {
+            this.s = s;
+        }
+
+        @Override
+        public String toJsonString() {
+            return s;
+        }
+    }
+
+    String toJsonString();
+}
+
+interface JsonNodeGenerator {
+
+    class NumberGenerator {
+
+         // Node that returns the assigned label
+        private static class Node {
+            final private String label;
+
+            Node(String label) {
+                children = new LinkedList<>();
+                this.label = label;
+            }
+
+            Node() {
+                this("");
+            }
+
+            void add(Node node) {
+                if (!children.contains(node)) {
+                    children.add(node);
+                }
+            }
+
+            String getLabel() {
+                return label;
+            }
+
+            List<Node> children;
+        }
+
+        // Node that generates a random digit from 1-9
+        private static class Digit19 extends Node {
+            Digit19() {
+                super();
+            }
+
+            @Override
+            String getLabel() {
+                return "" + (JsonTester.RANDOM.nextInt(9) + 1);
+            }
+        }
+
+        // Node that generates a random digit from 0-9
+        private static class Digits extends Node {
+            Digits() {
+                super();
+            }
+
+            @Override
+            String getLabel() {
+                return "" + (JsonTester.RANDOM.nextInt(10));
+            }
+        }
+
+        private final static Node root;
+
+        // Setup a graph for the grammar productions for JSON number as outlined in json.org
+        // The graph below mimics the syntax diagram for JSON number.
+        // Node "R" is the start node and "T" is the terminal node
+        static {
+
+            // Create all the nodes
+            root = new Node("R");
+            Node minus1 = new Node("-");
+            Node zero = new Node("0");
+            Node digit19 = new Digit19();
+            Node digits1 = new Digits();
+            Node dot = new Node(".");
+            Node digits2 = new Digits();
+            Node e = new Node("e");
+            Node E = new Node("E");
+            Node plus = new Node("+");
+            Node minus2 = new Node("-");
+            Node digits3 = new Digits();
+            Node terminal = new Node("T");
+
+            //set up graph
+            root.add(zero);
+            root.add(minus1);
+            root.add(digit19);
+
+            minus1.add(zero);
+            minus1.add(digit19);
+
+            zero.add(dot);
+            zero.add(terminal);
+
+            digit19.add(dot);
+            digit19.add(digits1);
+            digit19.add(terminal);
+
+            digits1.add(dot);
+            digits1.add(digits1);
+            digits1.add(terminal);
+
+            dot.add(digits2);
+
+            digits2.add(digits2);
+            digits2.add(e);
+            digits2.add(E);
+            digits2.add(terminal);
+
+            e.add(plus);
+            e.add(minus2);
+            e.add(digits3);
+
+            E.add(plus);
+            E.add(minus2);
+            E.add(digits3);
+
+            plus.add(digits3);
+            minus2.add(digits3);
+
+            digits3.add(digits3);
+            digits3.add(terminal);
+        }
+
+        static String generate() {
+            // Get a random path from start to finish
+            StringBuilder sbuf = new StringBuilder();
+            Node parent = root;
+            Node child = parent.children.get(JsonTester.RANDOM.nextInt(parent.children.size()));
+            while (!child.getLabel().equals("T")) {
+                sbuf.append(child.getLabel());
+                parent = child;
+                child = parent.children.get(JsonTester.RANDOM.nextInt(parent.children.size()));
+            }
+            return sbuf.toString();
+        }
+    }
+
+    class StringGenerator {
+
+        private static final int minStringLength = 0;
+        private static final int maxStringLength = 50;
+
+        private static final String controlChars = "\b" + "\f" + "\n" + "\r" + "\t" + "\\b";
+//        private static final String escapedControls = "\\b" + "\\f" + "\\n" + "\\r" + "\\t" + "\\b";
+
+        private static final String specials = "\\" + "\"" + controlChars;// + escapedControls;    // TODO: "\\uxxxx"
+//        private static final String alphanums = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+        static String generate() {
+            char ch;
+            StringBuilder sbuf = new StringBuilder();
+            int len = minStringLength + JsonTester.RANDOM.nextInt(maxStringLength - minStringLength + 1);
+            sbuf.append("\"");
+            for (int i = 0; i < len; i++) {
+                if (JsonTester.RANDOM.nextInt(10) == 1) { // 1/10 chances of a control character
+                    ch = specials.charAt(JsonTester.RANDOM.nextInt(specials.length()));
+                } else {
+//                ch = alphanums.charAt(JsonTester.RANDOM.nextInt(alphanums.length()));
+                    ch = (char) JsonTester.RANDOM.nextInt(Character.MAX_VALUE + 1);
+                }
+                switch (ch) {
+                    case '\"':
+                    case '\\':
+                        sbuf.append('\\');
+                }
+                sbuf.append(ch);
+            }
+            sbuf.append("\"");
+            return sbuf.toString();
+        }
+    }
+
+    class ArrayGenerator {
+
+         static JsonNode.ArrayNode generate(int size) {
+            JsonNode.ArrayNode array = new JsonNode.ArrayNode();
+            if (size <= JsonTester.maxChildrenPerNode) {
+                for (int i = 0; i < size; i++) {
+                    array.add(PrimtiveGenerator.generate());
+                }
+            } else if (size >= JsonTester.maxChildrenPerNode) {
+                int newSize = size;
+                do {
+                    int childSize = JsonTester.RANDOM.nextInt(newSize);
+                    if (JsonTester.RANDOM.nextBoolean()) {
+                        array.add(ArrayGenerator.generate(childSize));
+                    } else {
+                        array.add(ObjectGenerator.generate(childSize));
+                    }
+                    newSize = newSize - childSize;
+                } while (newSize > JsonTester.maxChildrenPerNode);
+                if (JsonTester.RANDOM.nextBoolean()) {
+                    array.add(ArrayGenerator.generate(newSize));
+                } else {
+                    array.add(ObjectGenerator.generate(newSize));
+                }
+            }
+            return array;
+        }
+    }
+
+    class PrimtiveGenerator {
+
+        static JsonNode.PrimitiveNode generate() {
+            int primitiveTypre = JsonTester.RANDOM.nextInt(10) + 1;
+            switch (primitiveTypre) {
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                    return new JsonNode.PrimitiveNode(StringGenerator.generate());
+                case 5:
+                case 6:
+                case 7:
+                case 8:
+                    return new JsonNode.PrimitiveNode(NumberGenerator.generate());
+                case 9:
+                    return new JsonNode.PrimitiveNode(Boolean.toString(JsonTester.RANDOM.nextBoolean()));
+                case 10:
+                    return null;
+            }
+            return null;
+        }
+    }
+
+    class ObjectGenerator {
+
+        static JsonNode.ObjectNode generate(int size) {
+            JsonNode.ObjectNode jobj = new JsonNode.ObjectNode();
+            if (size <= JsonTester.maxChildrenPerNode) {
+                for (int i = 0; i < size; i++) {
+                    jobj.put(StringGenerator.generate(), PrimtiveGenerator.generate());
+                }
+            } else {
+                int newSize = size;
+                do {
+                    int childSize = JsonTester.RANDOM.nextInt(newSize);
+                    if (JsonTester.RANDOM.nextBoolean()) {
+                        jobj.put(StringGenerator.generate(), ArrayGenerator.generate(childSize));
+                    } else {
+                        jobj.put(StringGenerator.generate(), ObjectGenerator.generate(childSize));
+                    }
+                    newSize = newSize - childSize;
+                } while (newSize > JsonTester.maxChildrenPerNode);
+                if (JsonTester.RANDOM.nextBoolean()) {
+                    jobj.put(StringGenerator.generate(), ArrayGenerator.generate(newSize));
+                } else {
+                    jobj.put(StringGenerator.generate(), ObjectGenerator.generate(newSize));
+                }
+            }
+            return jobj;
+        }
+    }
+}
+
+
--- a/test/jdk/javax/management/remote/rest/management.properties	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-com.sun.management.jmxremote.ssl=true
-com.sun.management.jmxremote.ssl.config.file=sslconfig
-# com.sun.management.jmxremote.login.config=<config-name>
-com.sun.management.jmxremote.password.file=password.properties
-# com.sun.management.jmxremote.host=<host-or-interface-name>
-com.sun.management.jmxremote.rest.port=8686
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/management/remote/rest/management.properties.template	Mon Jan 01 23:59:14 2018 +0530
@@ -0,0 +1,6 @@
+# com.sun.management.jmxremote.ssl=true
+# com.sun.management.jmxremote.ssl.config.file=sslconfig
+# com.sun.management.jmxremote.login.config=<config-name>
+# com.sun.management.jmxremote.password.file=password.properties
+# com.sun.management.jmxremote.host=<host-or-interface-name>
+# com.sun.management.jmxremote.rest.port=8686
--- a/test/jdk/javax/management/remote/rest/management1.properties	Thu Dec 28 20:34:32 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-com.sun.management.jmxremote.ssl=true
-com.sun.management.jmxremote.ssl.config.file=/home/harsha/work/jdk10_rest/jdk/test/sun/management/jmxremote/rest/sslconfig
-# com.sun.management.jmxremote.login.config=<config-name>
-com.sun.management.jmxremote.authenticate=false
-com.sun.management.jmxremote.password.file=/home/harsha/work/jdk10_rest/jdk/test/sun/management/jmxremote/rest/password.properties
-# com.sun.management.jmxremote.host=<host-or-interface-name>
-com.sun.management.jmxremote.rest.port=8686