This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch UNOMI-259-jdk11-support
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/UNOMI-259-jdk11-support by 
this push:
     new 621861d  UNOMI-259 - Switch CXF to CXF-JaxRS in feature dependency - 
Upgrade FailSafe to support JDK 11 - Fix OGNL to work with JDK 11
621861d is described below

commit 621861d52838f18818d5e90950875220c4a2e62b
Author: Serge Huber <[email protected]>
AuthorDate: Fri Dec 13 15:17:23 2019 +0100

    UNOMI-259
    - Switch CXF to CXF-JaxRS in feature dependency
    - Upgrade FailSafe to support JDK 11
    - Fix OGNL to work with JDK 11
    
    Signed-off-by: Serge Huber <[email protected]>
---
 itests/pom.xml                                     |  2 +-
 kar/src/main/feature/feature.xml                   |  3 +-
 package/pom.xml                                    |  2 +-
 .../conditions/PropertyConditionEvaluator.java     | 32 ++++++++++++++++++----
 pom.xml                                            |  4 +--
 5 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/itests/pom.xml b/itests/pom.xml
index af2262a..aa7d2ca 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -181,7 +181,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-failsafe-plugin</artifactId>
-                <version>2.20.1</version>
+                <version>3.0.0-M4</version>
                 <configuration>
                     <includes>
                         <include>**/*AllITs.java</include>
diff --git a/kar/src/main/feature/feature.xml b/kar/src/main/feature/feature.xml
index 75a0efb..70c76b1 100644
--- a/kar/src/main/feature/feature.xml
+++ b/kar/src/main/feature/feature.xml
@@ -24,7 +24,7 @@
     <feature description="unomi-kar" version="${project.version}" 
name="unomi-kar"
              start-level="70">
         <feature>war</feature>
-        <feature>cxf</feature>
+        <feature>cxf-jaxrs</feature>
         <feature>cellar</feature>
         <feature>eventadmin</feature>
         <feature>shell-compat</feature>
@@ -52,6 +52,7 @@
         <bundle 
start-level="75">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${version.jackson.core}</bundle>
         <bundle 
start-level="75">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jakarta-regexp/1.4_1</bundle>
         <bundle 
start-level="75">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time/2.3_1</bundle>
+        <bundle 
start-level="75">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/2.9.0</bundle>
 
         <bundle start-level="70" 
start="false">mvn:org.apache.unomi/unomi-lifecycle-watcher/${project.version}</bundle>
         <bundle start-level="75" 
start="false">mvn:org.apache.unomi/unomi-api/${project.version}</bundle>
diff --git a/package/pom.xml b/package/pom.xml
index 9121745..e27ebb2 100644
--- a/package/pom.xml
+++ b/package/pom.xml
@@ -327,7 +327,7 @@
                         <feature>service</feature>
                         <feature>system</feature>
                         <feature>war</feature>
-                        <feature>cxf</feature>
+                        <feature>cxf-jaxrs</feature>
                         <feature>cellar</feature>
                         <feature>aries-blueprint</feature>
                         <feature>shell-compat</feature>
diff --git 
a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
 
b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
index 6a46c54..bb42aeb 100644
--- 
a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
+++ 
b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
@@ -17,10 +17,7 @@
 
 package org.apache.unomi.plugins.baseplugin.conditions;
 
-import ognl.Node;
-import ognl.Ognl;
-import ognl.OgnlContext;
-import ognl.OgnlException;
+import ognl.*;
 import ognl.enhance.ExpressionAccessor;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -36,6 +33,8 @@ import org.elasticsearch.common.joda.JodaDateMathParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Pattern;
@@ -327,7 +326,7 @@ public class PropertyConditionEvaluator implements 
ConditionEvaluator {
 
     protected Object getOGNLPropertyValue(Item item, String expression) throws 
Exception {
         ExpressionAccessor accessor = getPropertyAccessor(item, expression);
-        return accessor != null ? accessor.get((OgnlContext) 
Ognl.createDefaultContext(null), item) : null;
+        return accessor != null ? accessor.get(getOgnlContext(), item) : null;
     }
 
     private Object getNestedPropertyValue(String expressionPart, Map<String, 
Object> properties) {
@@ -345,6 +344,27 @@ public class PropertyConditionEvaluator implements 
ConditionEvaluator {
         }
     }
 
+    private OgnlContext getOgnlContext() {
+        return (OgnlContext) Ognl.createDefaultContext(null, new 
MemberAccess() {
+            @Override
+            public Object setup(Map context, Object target, Member member, 
String propertyName) {
+                return null;
+            }
+
+            @Override
+            public void restore(Map context, Object target, Member member, 
String propertyName, Object state) {
+
+            }
+
+            @Override
+            public boolean isAccessible(Map context, Object target, Member 
member, String propertyName) {
+                int modifiers = member.getModifiers();
+                boolean result = Modifier.isPublic(modifiers);
+                return result;
+            }
+        });
+    }
+
     private ExpressionAccessor getPropertyAccessor(Item item, String 
expression) throws Exception {
         ExpressionAccessor accessor = null;
         String clazz = item.getClass().getName();
@@ -361,7 +381,7 @@ public class PropertyConditionEvaluator implements 
ConditionEvaluator {
             ClassLoader contextCL = current.getContextClassLoader();
             try {
                 
current.setContextClassLoader(PropertyConditionEvaluator.class.getClassLoader());
-                Node node = Ognl.compileExpression((OgnlContext) 
Ognl.createDefaultContext(null), item, expression);
+                Node node = Ognl.compileExpression(getOgnlContext() , item, 
expression);
                 accessor = node.getAccessor();
             } finally {
                 current.setContextClassLoader(contextCL);
diff --git a/pom.xml b/pom.xml
index 314bc39..233c361 100644
--- a/pom.xml
+++ b/pom.xml
@@ -932,12 +932,12 @@
             <dependency>
                 <groupId>ognl</groupId>
                 <artifactId>ognl</artifactId>
-                <version>3.0.11</version>
+                <version>3.2.11</version>
             </dependency>
             <dependency>
                 <groupId>org.javassist</groupId>
                 <artifactId>javassist</artifactId>
-                <version>3.23.1-GA</version>
+                <version>3.24.1-GA</version>
             </dependency>
             <dependency>
                 <groupId>org.antlr</groupId>

Reply via email to