From 6bda5d7e4e80d1aefb4f19203361b7199448e70f Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 5 Mar 2020 10:50:48 +0000 Subject: Use Rhino javascript executor in apex-pdp Integation unit tests resultd in StackOverflowException errors in the Graal Javascript interpreter. Following extensive testing and trouobleshooting, it proved very difficult to fix these issues in Graal as the stck overflow errors were occurring in native class instantiation methods being invoked by Grall on the JVM. The alternative Rhino Javascript engine is developed by mozilla, and was incorporated into the Java 6 JVM and evolved into Nashorn in the Java 8 JVM. Oracle dropped Nashorn in Java 11. However, in parallel, Rhino development has continued. This review brings in the Rhino javascript engine into apex-pdp as the replacement for Nashorn and instead of Graal. Graal seems to be pretty unstable as yet so we may bring it in in future releases but for now Rhino is a more stable and reliable alternative. Issue-ID: POLICY-2106 Change-Id: I0edeff3b0bee404b38e3ebe22001a6e3375a44dc Signed-off-by: liamfallon --- .../SupportRestRequestorEndpoint.java | 25 +++++++++++----------- .../resources/policymodels/RequestorModel.json | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'plugins/plugins-event/plugins-event-carrier') diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java index 8380d0a61..fb59bad2a 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/SupportRestRequestorEndpoint.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,8 +49,8 @@ public class SupportRestRequestorEndpoint { private static int deleteMessagesReceived = 0; private static String EVENT_STRING = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.events\",\n" - + "\"name\": \"ResponseEvent\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" - + getMessagesReceived + "\",\n" + "\"target\": \"apex\",\n" + "\"intPar\": 9080\n" + "}"; + + "\"name\": \"ResponseEvent\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" + + getMessagesReceived + "\",\n" + "\"target\": \"apex\",\n" + "\"intPar\": 9080\n" + "}"; /** * Reset counters. @@ -74,10 +75,10 @@ public class SupportRestRequestorEndpoint { statMessagesReceived++; } return Response.status(200) - .entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}") - .build(); + .entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": " + + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + ",\"DELETE\": " + + deleteMessagesReceived + "}") + .build(); } /** @@ -134,9 +135,9 @@ public class SupportRestRequestorEndpoint { final Map jsonMap = new Gson().fromJson(jsonString, Map.class); assertTrue(jsonMap.containsKey("name")); assertEquals("0.0.1", jsonMap.get("version")); - assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); - assertEquals("Act", jsonMap.get("source")); - assertEquals("Outside", jsonMap.get("target")); + assertEquals("org.onap.policy.apex.events", jsonMap.get("nameSpace")); + assertEquals("apex", jsonMap.get("source")); + assertEquals("server", jsonMap.get("target")); return Response.status(200).entity(EVENT_STRING).build(); } @@ -170,9 +171,9 @@ public class SupportRestRequestorEndpoint { final Map jsonMap = new Gson().fromJson(jsonString, Map.class); assertTrue(jsonMap.containsKey("name")); assertEquals("0.0.1", jsonMap.get("version")); - assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); - assertEquals("Act", jsonMap.get("source")); - assertEquals("Outside", jsonMap.get("target")); + assertEquals("org.onap.policy.apex.events", jsonMap.get("nameSpace")); + assertEquals("apex", jsonMap.get("source")); + assertEquals("server", jsonMap.get("target")); return Response.status(200).entity(EVENT_STRING).build(); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json index 98510d2a5..2ab58e4a6 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/resources/policymodels/RequestorModel.json @@ -460,7 +460,7 @@ "taskLogic" : { "key" : "TaskLogic", "logicFlavour" : "JAVASCRIPT", - "logic" : "executor.logger.debug(executor.subject.getId());\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.getName());\nvar returnValue = executor.isTrue;" + "logic" : "executor.logger.debug(executor.subject.getId());\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.getName());\ntrue;" } } } ] -- cgit 1.2.3-korg