From ece4052501cbe22d244b4e3e15e02a5527a5c7d1 Mon Sep 17 00:00:00 2001 From: Matt Gill Date: Tue, 17 Jul 2018 10:27:57 +0100 Subject: [PATCH 1/2] Fixed InstanceHandler JVM options error handling. --- .../admingui/common/handlers/InstanceHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/InstanceHandler.java b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/InstanceHandler.java index 2ded241c96e..ed83cc1434d 100644 --- a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/InstanceHandler.java +++ b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/InstanceHandler.java @@ -97,7 +97,7 @@ public static void getJvmOptionsValues(HandlerContext handlerCtx) { } handlerCtx.setOutputValue("result", optionValues); } catch (Exception ex){ - handlerCtx.setOutputValue("result", new HashMap()); + handlerCtx.setOutputValue("result", new ArrayList<>()); GuiUtil.getLogger().info(GuiUtil.getCommonMessage("log.error.getJvmOptionsValues") + ex.getLocalizedMessage()); if (GuiUtil.getLogger().isLoggable(Level.FINE)){ ex.printStackTrace(); @@ -106,15 +106,17 @@ public static void getJvmOptionsValues(HandlerContext handlerCtx) { } public static List> getJvmOptions(HandlerContext handlerCtx) { - ArrayList> list; + List> list; String endpoint = (String) handlerCtx.getInputValue("endpoint"); if (!endpoint.endsWith(".json")) endpoint = endpoint + ".json"; Map attrs = (Map) handlerCtx.getInputValue("attrs"); Map result = (Map) RestUtil.restRequest(endpoint, attrs, "get", handlerCtx, false).get("data"); - list = (ArrayList>) result.get("extraProperties").get("leafList"); - if (list == null) + if (result == null) { list = new ArrayList<>(); + } else { + list = (ArrayList>) result.get("extraProperties").get("leafList"); + } return list; } From 13c5e52246a1dd81feebb954ed56182fed881169 Mon Sep 17 00:00:00 2001 From: Matt Gill Date: Tue, 17 Jul 2018 12:11:46 +0100 Subject: [PATCH 2/2] Set JVM options without server restart. --- .../resources/CollectionLeafResource.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/resources/CollectionLeafResource.java b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/resources/CollectionLeafResource.java index 50dd00b22a2..cc957b547f7 100644 --- a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/resources/CollectionLeafResource.java +++ b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/resources/CollectionLeafResource.java @@ -108,14 +108,17 @@ public List getEntity() { public void setParentAndTagName(Dom parent, String tagName) { this.parent = parent; this.tagName = tagName; - if (parent!=null){ - if (parent.getImplementationClass().equals(JavaConfig.class) && isJvmOptions(tagName)) { - JavaConfig javaConfig = (JavaConfig)parent.get(); - entity = javaConfig.getJvmRawOptions(); - isJvmOptions = true; - } - else { - synchronized (parent) { + if (parent != null) { + synchronized (parent) { + if (parent.getImplementationClass().equals(JavaConfig.class) && isJvmOptions(tagName)) { + JavaConfig javaConfig = (JavaConfig) parent.get(); + if (javaConfig != null) { + entity = javaConfig.getJvmRawOptions(); + } else { + entity = parent.leafElements(tagName); + } + isJvmOptions = true; + } else { entity = parent.leafElements(tagName); } }