You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/03/24 22:05:23 UTC

struts git commit: WW-4619 Disables EL when not supported by container

Repository: struts
Updated Branches:
  refs/heads/master 7256557c3 -> f6039d237


WW-4619 Disables EL when not supported by container


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f6039d23
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f6039d23
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f6039d23

Branch: refs/heads/master
Commit: f6039d2378aa21734c15949bead1769a5247eeff
Parents: 7256557
Author: Lukasz Lenart <lu...@apache.org>
Authored: Thu Mar 24 22:05:12 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Thu Mar 24 22:05:12 2016 +0100

----------------------------------------------------------------------
 .../struts2/tiles/StrutsTilesContainerFactory.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f6039d23/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
index 0cb14f3..fe90d75 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
@@ -22,6 +22,8 @@ package org.apache.struts2.tiles;
 import ognl.OgnlException;
 import ognl.OgnlRuntime;
 import ognl.PropertyAccessor;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.definition.DefinitionsFactory;
 import org.apache.tiles.definition.pattern.DefinitionPatternMatcherFactory;
@@ -63,6 +65,7 @@ import javax.el.ELResolver;
 import javax.el.ListELResolver;
 import javax.el.MapELResolver;
 import javax.el.ResourceBundleELResolver;
+import javax.servlet.jsp.JspFactory;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -81,6 +84,8 @@ import java.util.Map;
  */
 public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
 
+    private static final Logger LOG = LogManager.getLogger(StrutsTilesContainerFactory.class);
+
     /**
      * The freemarker renderer name.
      */
@@ -144,7 +149,11 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
 
         BasicAttributeEvaluatorFactory attributeEvaluatorFactory = new BasicAttributeEvaluatorFactory(new DirectAttributeEvaluator());
         attributeEvaluatorFactory.registerAttributeEvaluator(OGNL, createOGNLEvaluator());
-        attributeEvaluatorFactory.registerAttributeEvaluator(EL, createELEvaluator(applicationContext));
+
+        ELAttributeEvaluator elEvaluator = createELEvaluator(applicationContext);
+        if (elEvaluator != null) {
+            attributeEvaluatorFactory.registerAttributeEvaluator(EL, elEvaluator);
+        }
 
         return attributeEvaluatorFactory;
     }
@@ -189,6 +198,12 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
     }
 
     protected ELAttributeEvaluator createELEvaluator(ApplicationContext applicationContext) {
+
+        if (JspFactory.getDefaultFactory() == null) {
+            LOG.warn("JspFactory.getDefaultFactory returned null, EL support will be disabled");
+            return null;
+        }
+
         ELAttributeEvaluator evaluator = new ELAttributeEvaluator();
         JspExpressionFactoryFactory efFactory = new JspExpressionFactoryFactory();
         efFactory.setApplicationContext(applicationContext);