[1/6] struts git commit: WW-4762 Drops unused code

2017-05-10 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/default-provider [created] bb19a6209


WW-4762 Drops unused code


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

Branch: refs/heads/default-provider
Commit: 45d1a491311a82f6b2404d839e7e18269a26192f
Parents: b46a6e7
Author: Lukasz Lenart 
Authored: Wed Apr 26 11:55:49 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 11:55:49 2017 +0200

--
 .../org/apache/struts2/util/StrutsTestCaseHelper.java| 11 ---
 1 file changed, 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/45d1a491/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java 
b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
index 9c449f5..f8994d1 100644
--- a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
+++ b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
@@ -23,7 +23,6 @@ package org.apache.struts2.util;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import org.apache.struts2.dispatcher.Dispatcher;
@@ -40,16 +39,6 @@ import java.util.Map;
  */
 public class StrutsTestCaseHelper {
 
-/**
- * Sets up the configuration settings, XWork configuration, and
- * message resources
- *
- * @throws Exception in case of any error
- */
-public static void setUp() throws Exception {
-DefaultLocalizedTextProvider.clearDefaultResourceBundles();
-}
-
 public static Dispatcher initDispatcher(ServletContext ctx, 
Map params) {
 if (params == null) {
 params = new HashMap<>();



[4/6] struts git commit: WW-4762 Uses Struts prefix for the main implementation

2017-05-10 Thread lukaszlenart
WW-4762 Uses Struts prefix for the main implementation


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

Branch: refs/heads/default-provider
Commit: 8bf77a1d19d31dbc8574dcbf958c3da2a4724c84
Parents: 3ffc9b8
Author: Lukasz Lenart 
Authored: Wed Apr 26 11:56:48 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 11:56:48 2017 +0200

--
 .../config/impl/DefaultConfiguration.java   |2 +-
 .../providers/XWorkConfigurationProvider.java   |4 +-
 .../util/DefaultLocalizedTextProvider.java  | 1000 --
 .../util/StrutsLocalizedTextProvider.java   | 1000 ++
 core/src/main/resources/struts-default.xml  |2 +-
 .../util/DefaultLocalizedTextProviderTest.java  |  267 -
 .../util/StrutsLocalizedTextProviderTest.java   |  267 +
 7 files changed, 1271 insertions(+), 1271 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/8bf77a1d/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
index 8882a2f..a1b6490 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
@@ -261,7 +261,7 @@ public class DefaultConfiguration implements Configuration {
 
 builder.factory(TextProvider.class, "system", 
DefaultTextProvider.class, Scope.SINGLETON);
 
-builder.factory(LocalizedTextProvider.class, 
DefaultLocalizedTextProvider.class, Scope.SINGLETON);
+builder.factory(LocalizedTextProvider.class, 
StrutsLocalizedTextProvider.class, Scope.SINGLETON);
 builder.factory(TextProviderFactory.class, 
StrutsTextProviderFactory.class, Scope.SINGLETON);
 builder.factory(LocaleProviderFactory.class, 
DefaultLocaleProviderFactory.class, Scope.SINGLETON);
 

http://git-wip-us.apache.org/repos/asf/struts/blob/8bf77a1d/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
index 1bc6986..e5692a1 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
@@ -72,7 +72,7 @@ import 
com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor;
 import com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.LocalizedTextProvider;
-import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
+import com.opensymphony.xwork2.util.StrutsLocalizedTextProvider;
 import com.opensymphony.xwork2.util.OgnlTextParser;
 import com.opensymphony.xwork2.util.PatternMatcher;
 import com.opensymphony.xwork2.util.TextParser;
@@ -182,7 +182,7 @@ public class XWorkConfigurationProvider implements 
ConfigurationProvider {
 .factory(ActionValidatorManager.class, "no-annotations", 
DefaultActionValidatorManager.class, Scope.SINGLETON)
 
 .factory(TextProvider.class, "system", 
DefaultTextProvider.class, Scope.SINGLETON)
-.factory(LocalizedTextProvider.class, 
DefaultLocalizedTextProvider.class, Scope.SINGLETON)
+.factory(LocalizedTextProvider.class, 
StrutsLocalizedTextProvider.class, Scope.SINGLETON)
 .factory(TextProviderFactory.class, 
StrutsTextProviderFactory.class, Scope.SINGLETON)
 .factory(LocaleProviderFactory.class, 
DefaultLocaleProviderFactory.class, Scope.SINGLETON)
 

http://git-wip-us.apache.org/repos/asf/struts/blob/8bf77a1d/core/src/main/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProvider.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProvider.java
deleted file mode 100644
index 21f7477..000
--- 
a/core/src/main/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProvider.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*
- * $Id$
- *
- * Licensed to the Apache So

[2/6] struts git commit: WW-4762 Drops unused imports

2017-05-10 Thread lukaszlenart
WW-4762 Drops unused imports


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

Branch: refs/heads/default-provider
Commit: 3ffc9b8450845d7a90a623607e3b4bb05888e2f9
Parents: 45d1a49
Author: Lukasz Lenart 
Authored: Wed Apr 26 11:56:09 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 11:56:09 2017 +0200

--
 .../java/com/opensymphony/xwork2/DefaultTextProvider.java| 8 +---
 .../main/java/org/apache/struts2/dispatcher/Dispatcher.java  | 1 -
 .../struts2/config/PropertiesConfigurationProviderTest.java  | 1 -
 3 files changed, 1 insertion(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/3ffc9b84/core/src/main/java/com/opensymphony/xwork2/DefaultTextProvider.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/DefaultTextProvider.java 
b/core/src/main/java/com/opensymphony/xwork2/DefaultTextProvider.java
index 51ed449..116a0a1 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultTextProvider.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultTextProvider.java
@@ -16,7 +16,6 @@
 package com.opensymphony.xwork2;
 
 import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 
 import java.io.Serializable;
@@ -27,12 +26,7 @@ import java.util.List;
 import java.util.ResourceBundle;
 
 /**
- * DefaultTextProvider gets texts from only the default resource bundles 
associated with the
- * LocalizedTextUtil.
- *
- * @author Jason Carreira jcarre...@gmail.com
- * @author Rainer Hermanns
- * @see DefaultLocalizedTextProvider#addDefaultResourceBundle(String)
+ * DefaultTextProvider gets texts from only the default resource bundles 
associated with the default bundles.
  */
 public class DefaultTextProvider implements TextProvider, Serializable, 
Unchainable {
 

http://git-wip-us.apache.org/repos/asf/struts/blob/3ffc9b84/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
--
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java 
b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 667f37d..55707a4 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -32,7 +32,6 @@ import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.Interceptor;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
-import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;

http://git-wip-us.apache.org/repos/asf/struts/blob/3ffc9b84/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
--
diff --git 
a/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
 
b/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
index b4fd408..a82a8c6 100644
--- 
a/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
+++ 
b/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
@@ -23,7 +23,6 @@ package org.apache.struts2.config;
 
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
-import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import junit.framework.TestCase;
 import org.apache.commons.lang3.LocaleUtils;



[3/6] struts git commit: WW-4762 Uses Struts prefix for the main implementation

2017-05-10 Thread lukaszlenart
http://git-wip-us.apache.org/repos/asf/struts/blob/8bf77a1d/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
--
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
deleted file mode 100644
index a9dca08..000
--- 
a/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2002-2006,2009 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.opensymphony.xwork2.util;
-
-import com.mockobjects.dynamic.Mock;
-import com.opensymphony.xwork2.*;
-import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
-import com.opensymphony.xwork2.test.ModelDrivenAction2;
-import com.opensymphony.xwork2.test.TestBean2;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-
-/**
- * Unit test for {@link DefaultLocalizedTextProvider}.
- *
- * @author jcarreira
- * @author tm_jee
- * 
- * @version $Date$ $Id$
- */
-public class DefaultLocalizedTextProviderTest extends XWorkTestCase {
-
-private LocalizedTextProvider localizedTextProvider;
-
-   public void testNpeWhenClassIsPrimitive() throws Exception {
-   ValueStack stack = ActionContext.getContext().getValueStack();
-   stack.push(new MyObject());
-   String result = localizedTextProvider.findText(MyObject.class, 
"someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack);
-   System.out.println(result);
-   }
-   
-   public static class MyObject extends ActionSupport {
-   public boolean getSomeObj() {
-   return true;
-   }
-   }
-   
-   public void testActionGetTextWithNullObject() throws Exception {
-   MyAction action = new MyAction();
-container.inject(action);
-   
-   Mock mockActionInvocation = new Mock(ActionInvocation.class);
-mockActionInvocation.expectAndReturn("getAction", action);
-ActionContext.getContext().setActionInvocation((ActionInvocation) 
mockActionInvocation.proxy());
-   ActionContext.getContext().getValueStack().push(action);
-   
-   String message = action.getText("barObj.title");
-   assertEquals("Title:", message);
-   }
-   
-   
-   public static class MyAction extends ActionSupport {
-   private Bar testBean2;
-   
-   public Bar getBarObj() {
-   return testBean2;
-   }
-   public void setBarObj(Bar testBean2) {
-   this.testBean2 = testBean2;
-   }
-   }
-   
-public void testActionGetText() throws Exception {
-ModelDrivenAction2 action = new ModelDrivenAction2();
-container.inject(action);
-
-TestBean2 bean = (TestBean2) action.getModel();
-Bar bar = new Bar();
-bean.setBarObj(bar);
-
-Mock mockActionInvocation = new Mock(ActionInvocation.class);
-mockActionInvocation.expectAndReturn("getAction", action);
-ActionContext.getContext().setActionInvocation((ActionInvocation) 
mockActionInvocation.proxy());
-ActionContext.getContext().getValueStack().push(action);
-ActionContext.getContext().getValueStack().push(action.getModel());
-
-String message = action.getText("barObj.title");
-assertEquals("Title:", message);
-}
-
-public void testNullKeys() {
-localizedTextProvider.findText(this.getClass(), null, 
Locale.getDefault());
-}
-
-public void testActionGetTextXXX() throws Exception {
-
localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/FindMe");
-
-SimpleAction action = new SimpleAction();
-container.inject(action);
-
-Mock mockActionInvocation = new Mock(ActionInvocation.class);
-mockActionInvocation.expectAndReturn("getAction", action);
-ActionContext.getContext().setActionInvocation((ActionInvocation) 
mockActionInvocation.proxy());
-ActionC

[5/6] struts git commit: WW-4762 Extracts base abstract class

2017-05-10 Thread lukaszlenart
WW-4762 Extracts base abstract class


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

Branch: refs/heads/default-provider
Commit: 2e23d7a07ea4313136dc38b8de2451b04c882064
Parents: 8bf77a1
Author: Lukasz Lenart 
Authored: Wed Apr 26 12:24:57 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 12:24:57 2017 +0200

--
 .../util/AbstractLocalizedTextProvider.java | 355 ++
 .../util/StrutsLocalizedTextProvider.java   | 368 +--
 2 files changed, 363 insertions(+), 360 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/2e23d7a0/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
new file mode 100644
index 000..a2578bc
--- /dev/null
+++ 
b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
@@ -0,0 +1,355 @@
+package com.opensymphony.xwork2.util;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.LocalizedTextProvider;
+import com.opensymphony.xwork2.inject.Inject;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsConstants;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+public abstract class AbstractLocalizedTextProvider implements 
LocalizedTextProvider {
+
+private static final Logger LOG = 
LogManager.getLogger(AbstractLocalizedTextProvider.class);
+
+public static final String XWORK_MESSAGES_BUNDLE = 
"com/opensymphony/xwork2/xwork-messages";
+public static final String STRUTS_MESSAGES_BUNDLE = 
"org/apache/struts2/struts-messages";
+
+private static final String TOMCAT_RESOURCE_ENTRIES_FIELD = 
"resourceEntries";
+private final String RELOADED = 
"com.opensymphony.xwork2.util.LocalizedTextProvider.reloaded";
+
+protected final ConcurrentMap bundlesMap = new 
ConcurrentHashMap<>();
+protected boolean devMode = false;
+protected boolean reloadBundles = false;
+
+private final ConcurrentMap 
messageFormats = new ConcurrentHashMap<>();
+private final ConcurrentMap> classLoaderMap = new 
ConcurrentHashMap<>();
+private final Set missingBundles = Collections.synchronizedSet(new 
HashSet());
+private final ConcurrentMap delegatedClassLoaderMap 
= new ConcurrentHashMap<>();
+
+/**
+ * Add's the bundle to the internal list of default bundles.
+ * If the bundle already exists in the list it will be re-added.
+ *
+ * @param resourceBundleName the name of the bundle to add.
+ */
+@Override
+public void addDefaultResourceBundle(String resourceBundleName) {
+//make sure this doesn't get added more than once
+final ClassLoader ccl = getCurrentThreadContextClassLoader();
+synchronized (XWORK_MESSAGES_BUNDLE) {
+List bundles = classLoaderMap.get(ccl.hashCode());
+if (bundles == null) {
+bundles = new CopyOnWriteArrayList<>();
+classLoaderMap.put(ccl.hashCode(), bundles);
+}
+bundles.remove(resourceBundleName);
+bundles.add(0, resourceBundleName);
+}
+
+if (LOG.isDebugEnabled()) {
+LOG.debug("Added default resource bundle '{}' to default resource 
bundles for the following classloader '{}'", resourceBundleName, 
ccl.toString());
+}
+}
+
+protected List getCurrentBundleNames() {
+return 
classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
+}
+
+protected ClassLoader getCurrentThreadContextClassLoader() {
+return Thread.currentThread().getContextClassLoader();
+}
+
+/**
+ * Returns a localized message for the specified key, aTextName.  Neither 
the key nor the
+ * message is evaluated.
+ *
+ * @param aTextName the message key
+ * @param localethe locale the message should be for

[6/6] struts git commit: WW-4762 Introduces default provider which only uses default bundles

2017-05-10 Thread lukaszlenart
WW-4762 Introduces default provider which only uses default bundles


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

Branch: refs/heads/default-provider
Commit: bb19a6209886795b76385e48fd86424c144ee029
Parents: 2e23d7a
Author: Lukasz Lenart 
Authored: Wed Apr 26 20:28:11 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 20:28:11 2017 +0200

--
 .../util/AbstractLocalizedTextProvider.java | 145 -
 .../util/DefaultLocalizedTextProvider.java  | 310 +++
 .../util/StrutsLocalizedTextProvider.java   | 161 +-
 3 files changed, 461 insertions(+), 155 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/bb19a620/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
index a2578bc..8c377c1 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java
@@ -20,11 +20,12 @@ import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-public abstract class AbstractLocalizedTextProvider implements 
LocalizedTextProvider {
+abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider {
 
 private static final Logger LOG = 
LogManager.getLogger(AbstractLocalizedTextProvider.class);
 
@@ -302,6 +303,26 @@ public abstract class AbstractLocalizedTextProvider 
implements LocalizedTextProv
 }
 
 /**
+ * Determines if we found the text in the bundles.
+ *
+ * @param result the result so far
+ * @return true if we could not find the text, 
false if the text was found (=success).
+ */
+protected boolean unableToFindTextForKey(GetDefaultMessageReturnArg 
result) {
+if (result == null || result.message == null) {
+return true;
+}
+
+// did we find it in the bundle, then no problem?
+if (result.foundInBundle) {
+return false;
+}
+
+// not found in bundle
+return true;
+}
+
+/**
  * Creates a key to used for lookup/storing in the bundle misses cache.
  *
  * @param prefix  the prefix for the returning String - it is supposed 
to be the ClassLoader hash code.
@@ -313,6 +334,128 @@ public abstract class AbstractLocalizedTextProvider 
implements LocalizedTextProv
 return prefix + aBundleName + "_" + locale.toString();
 }
 
+/**
+ * @return the default message.
+ */
+protected GetDefaultMessageReturnArg getDefaultMessage(String key, Locale 
locale, ValueStack valueStack, Object[] args,
+String 
defaultMessage) {
+GetDefaultMessageReturnArg result = null;
+boolean found = true;
+
+if (key != null) {
+String message = findDefaultText(key, locale);
+
+if (message == null) {
+message = defaultMessage;
+found = false; // not found in bundles
+}
+
+// defaultMessage may be null
+if (message != null) {
+MessageFormat mf = 
buildMessageFormat(TextParseUtil.translateVariables(message, valueStack), 
locale);
+
+String msg = formatWithNullDetection(mf, args);
+result = new GetDefaultMessageReturnArg(msg, found);
+}
+}
+
+return result;
+}
+
+/**
+ * @return the message from the named resource bundle.
+ */
+protected String getMessage(String bundleName, Locale locale, String key, 
ValueStack valueStack, Object[] args) {
+ResourceBundle bundle = findResourceBundle(bundleName, locale);
+if (bundle == null) {
+return null;
+}
+if (valueStack != null)
+reloadBundles(valueStack.getContext());
+try {
+   String message = bundle.getString(key);
+   if (valueStack != null)
+   message = 
TextParseUtil.translateVariables(bundle.getString(key), valueStack);
+MessageFormat mf = buildMessageFormat(message, locale);
+return formatWithNullD

[struts] Git Push Summary

2017-05-10 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/default-provider [deleted] bb19a6209


[02/10] struts git commit: Moves documentation to wiki

2017-05-10 Thread lukaszlenart
Moves documentation to wiki


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

Branch: refs/heads/master
Commit: 787150d041e32e8e579df5d44c1258881fad6c94
Parents: d739be3
Author: Lukasz Lenart 
Authored: Wed Apr 26 08:48:01 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 08:48:01 2017 +0200

--
 .../views/freemarker/FreemarkerResult.java  | 51 
 1 file changed, 51 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/787150d0/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index 0c7de59..226fb70 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -48,57 +46,8 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.Locale;
 
-
 /**
- * 
- *
  * Renders a view using the Freemarker template engine.
- * 
- * The FreemarkarManager class configures the template loaders so that the
- * template location can be either
- * 
- *
- * 
- *
- * relative to the web root folder. eg /WEB-INF/views/home.ftl
- * 
- *
- * a classpath resuorce. eg 
/com/company/web/views/home.ftl
- *
- * 
- *
- * 
- *
- * This result type takes the following parameters:
- *
- * 
- *
- * 
- *
- * location (default) - the location of the template to 
process.
- *
- * parse - true by default. If set to false, the location param will
- * not be parsed for Ognl expressions.
- *
- * contentType - defaults to "text/html" unless specified.
- * 
- * writeIfCompleted - false by default, write to stream only if 
there isn't any error 
- * processing the template. Setting template_exception_handler=rethrow in 
freemarker.properties
- * will have the same effect.
- *
- * 
- *
- * 
- *
- * Example:
- *
- * 
- * 
- *
- * foo.ftl
- *
- * 
- * 
  */
 public class FreemarkerResult extends StrutsResultSupport {
 



[03/10] struts git commit: WW-4749 Defines setter to allow specify useBufferedWriter

2017-05-10 Thread lukaszlenart
WW-4749 Defines setter to allow specify useBufferedWriter


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

Branch: refs/heads/master
Commit: f5125bcd1bb97a75ab54e266399c2bf96987c1dc
Parents: 787150d
Author: Lukasz Lenart 
Authored: Wed Apr 26 08:51:45 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 08:51:45 2017 +0200

--
 .../struts2/views/freemarker/FreemarkerResult.java | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/f5125bcd/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index 226fb70..7ea7fe3 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -147,7 +147,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 try {
 final boolean willUseBufferedWriter;
 if (useBufferedWriter != null) {
-willUseBufferedWriter = 
Boolean.parseBoolean(useBufferedWriter);
+willUseBufferedWriter = isUseBufferedWriter();
 } else {
 willUseBufferedWriter = isWriteIfCompleted() || 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
 }
@@ -370,4 +370,15 @@ public class FreemarkerResult extends StrutsResultSupport {
 public void setWriteIfCompleted(boolean writeIfCompleted) {
 this.writeIfCompleted = writeIfCompleted;
 }
+
+public boolean isUseBufferedWriter() {
+return useBufferedWriter != null && 
Boolean.parseBoolean(useBufferedWriter);
+}
+
+/**
+ * @param useBufferedWriter template is processed and flushed according to 
freemarker library policies
+ */
+public void setUseBufferedWriter(String useBufferedWriter) {
+this.useBufferedWriter = useBufferedWriter;
+}
 }



[10/10] struts git commit: WW-4749 Implements buffer/flush behaviour in FreemarkerResult

2017-05-10 Thread lukaszlenart
WW-4749 Implements buffer/flush behaviour in FreemarkerResult


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

Branch: refs/heads/master
Commit: 5a0f2e1aaf8d420bd74033175e6e459883160487
Parents: 0314ddc b842a4c
Author: Lukasz Lenart 
Authored: Wed May 10 16:39:41 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed May 10 16:39:41 2017 +0200

--
 .../views/freemarker/FreemarkerResult.java  | 83 
 .../views/freemarker/FreeMarkerResultTest.java  | 12 ---
 2 files changed, 16 insertions(+), 79 deletions(-)
--




[07/10] struts git commit: WW-4749 Uses Boolean to allow define behaviour per result

2017-05-10 Thread lukaszlenart
WW-4749 Uses Boolean to allow define behaviour per result


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

Branch: refs/heads/master
Commit: 3034b3a97050bcb24e34f39b203a960a0ddca93e
Parents: 6dad53c
Author: Lukasz Lenart 
Authored: Fri Apr 28 13:00:09 2017 +0200
Committer: Lukasz Lenart 
Committed: Fri Apr 28 13:00:09 2017 +0200

--
 .../struts2/views/freemarker/FreemarkerResult.java | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/3034b3a9/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index c9683b8..b083796 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -60,7 +60,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 protected ObjectWrapper wrapper;
 protected FreemarkerManager freemarkerManager;
 private Writer writer;
-private boolean useBufferedWriter = false;
+private Boolean useBufferedWriter = null;
 
 /*
  * Struts results are constructed for each result execution
@@ -144,7 +144,12 @@ public class FreemarkerResult extends StrutsResultSupport {
 // Give subclasses a chance to hook into preprocessing
 if (preTemplateProcess(template, model)) {
 try {
-final boolean willUseBufferedWriter = isUseBufferedWriter() || 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
+final boolean willUseBufferedWriter;
+if (useBufferedWriter != null) {
+willUseBufferedWriter = isUseBufferedWriter();
+} else {
+willUseBufferedWriter = 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
+}
 
 // Process the template
 Writer writer = getWriter();
@@ -352,13 +357,13 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 }
 
 public boolean isUseBufferedWriter() {
-return useBufferedWriter;
+return useBufferedWriter != null && useBufferedWriter;
 }
 
 /**
  * @param useBufferedWriter template is processed and flushed according to 
freemarker library policies
  */
-public void setUseBufferedWriter(boolean useBufferedWriter) {
+public void setUseBufferedWriter(Boolean useBufferedWriter) {
 this.useBufferedWriter = useBufferedWriter;
 }
 }



[04/10] struts git commit: WW-4749 Drops writeIfCompleted and uses Boolean instead String

2017-05-10 Thread lukaszlenart
WW-4749 Drops writeIfCompleted and uses Boolean instead String


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

Branch: refs/heads/master
Commit: 1df89792f93fa71f374eef8a2b1a72b43cc28eab
Parents: f5125bc
Author: Lukasz Lenart 
Authored: Fri Apr 28 09:32:47 2017 +0200
Committer: Lukasz Lenart 
Committed: Fri Apr 28 09:32:47 2017 +0200

--
 .../views/freemarker/FreemarkerResult.java  | 28 +++-
 1 file changed, 4 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/1df89792/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index 7ea7fe3..4ff393d 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -60,8 +60,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 protected ObjectWrapper wrapper;
 protected FreemarkerManager freemarkerManager;
 private Writer writer;
-private boolean writeIfCompleted = false;
-private String useBufferedWriter;
+private Boolean useBufferedWriter = null;
 
 /*
  * Struts results are constructed for each result execution
@@ -145,12 +144,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 // Give subclasses a chance to hook into preprocessing
 if (preTemplateProcess(template, model)) {
 try {
-final boolean willUseBufferedWriter;
-if (useBufferedWriter != null) {
-willUseBufferedWriter = isUseBufferedWriter();
-} else {
-willUseBufferedWriter = isWriteIfCompleted() || 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
-}
+final boolean willUseBufferedWriter = isUseBufferedWriter() || 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
 
 // Process the template
 Writer writer = getWriter();
@@ -357,28 +351,14 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 return (Boolean) ObjectUtils.defaultIfNull(attribute, Boolean.FALSE);
 }
 
-/**
- * @return true write to the stream only when template processing 
completed successfully (false by default)
- */
-public boolean isWriteIfCompleted() {
-return writeIfCompleted;
-}
-
-/**
- * @param writeIfCompleted Writes to the stream only when template 
processing completed successfully
- */
-public void setWriteIfCompleted(boolean writeIfCompleted) {
-this.writeIfCompleted = writeIfCompleted;
-}
-
 public boolean isUseBufferedWriter() {
-return useBufferedWriter != null && 
Boolean.parseBoolean(useBufferedWriter);
+return useBufferedWriter != null && useBufferedWriter;
 }
 
 /**
  * @param useBufferedWriter template is processed and flushed according to 
freemarker library policies
  */
-public void setUseBufferedWriter(String useBufferedWriter) {
+public void setUseBufferedWriter(Boolean useBufferedWriter) {
 this.useBufferedWriter = useBufferedWriter;
 }
 }



[05/10] struts git commit: WW-4749 Uses ordinary boolean instead of Boolean

2017-05-10 Thread lukaszlenart
WW-4749 Uses ordinary boolean instead of Boolean


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

Branch: refs/heads/master
Commit: bbcd9dc2514b286065a16657d58418aa9ef4be75
Parents: 1df8979
Author: Lukasz Lenart 
Authored: Fri Apr 28 09:33:56 2017 +0200
Committer: Lukasz Lenart 
Committed: Fri Apr 28 09:33:56 2017 +0200

--
 .../org/apache/struts2/views/freemarker/FreemarkerResult.java  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/bbcd9dc2/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index 4ff393d..c9683b8 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -60,7 +60,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 protected ObjectWrapper wrapper;
 protected FreemarkerManager freemarkerManager;
 private Writer writer;
-private Boolean useBufferedWriter = null;
+private boolean useBufferedWriter = false;
 
 /*
  * Struts results are constructed for each result execution
@@ -352,13 +352,13 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 }
 
 public boolean isUseBufferedWriter() {
-return useBufferedWriter != null && useBufferedWriter;
+return useBufferedWriter;
 }
 
 /**
  * @param useBufferedWriter template is processed and flushed according to 
freemarker library policies
  */
-public void setUseBufferedWriter(Boolean useBufferedWriter) {
+public void setUseBufferedWriter(boolean useBufferedWriter) {
 this.useBufferedWriter = useBufferedWriter;
 }
 }



[01/10] struts git commit: WW-4749 Implements buffered write

2017-05-10 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/master 0314ddcb5 -> 5a0f2e1aa


WW-4749 Implements buffered write


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

Branch: refs/heads/master
Commit: d739be34bccebbde2972c9e2c6225b94bad68d27
Parents: 8f75e1a
Author: Lukasz Lenart 
Authored: Wed Apr 26 08:42:42 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed Apr 26 08:42:42 2017 +0200

--
 .../views/freemarker/FreemarkerResult.java  | 22 
 1 file changed, 13 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/d739be34/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index 52ad637..0c7de59 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -112,6 +112,8 @@ public class FreemarkerResult extends StrutsResultSupport {
 protected FreemarkerManager freemarkerManager;
 private Writer writer;
 private boolean writeIfCompleted = false;
+private String useBufferedWriter;
+
 /*
  * Struts results are constructed for each result execution
  *
@@ -194,11 +196,18 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 // Give subclasses a chance to hook into preprocessing
 if (preTemplateProcess(template, model)) {
 try {
+final boolean willUseBufferedWriter;
+if (useBufferedWriter != null) {
+willUseBufferedWriter = 
Boolean.parseBoolean(useBufferedWriter);
+} else {
+willUseBufferedWriter = isWriteIfCompleted() || 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
+}
+
 // Process the template
 Writer writer = getWriter();
-if (isWriteIfCompleted() || 
configuration.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER) {
+if (willUseBufferedWriter){
 CharArrayWriter parentCharArrayWriter = (CharArrayWriter) 
req.getAttribute(PARENT_TEMPLATE_WRITER);
-boolean isTopTemplate = false;
+boolean isTopTemplate;
 if (isTopTemplate = (parentCharArrayWriter == null)) {
 //this is the top template
 parentCharArrayWriter = new CharArrayWriter();
@@ -213,18 +222,13 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 parentCharArrayWriter.flush();
 parentCharArrayWriter.writeTo(writer);
 }
-} catch (TemplateException e) {
+} catch (TemplateException | IOException e) {
 if (LOG.isErrorEnabled()) {
 LOG.error("Error processing Freemarker result!", 
e);
 }
 throw e;
-} catch (IOException e) {
-if (LOG.isErrorEnabled()){
-LOG.error("Error processing Freemarker result!", 
e);
-}
-throw e;
 } finally {
-if (isTopTemplate && parentCharArrayWriter != null) {
+if (isTopTemplate) {
 req.removeAttribute(PARENT_TEMPLATE_WRITER);
 parentCharArrayWriter.close();
 }



[09/10] struts git commit: WW-4749 Renames local variable to better express its meaning

2017-05-10 Thread lukaszlenart
WW-4749 Renames local variable to better express its meaning


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

Branch: refs/heads/master
Commit: b842a4c779e45e1193e6319970c2dc6f52ec6bf1
Parents: 38a2ebb
Author: Lukasz Lenart 
Authored: Wed May 10 10:08:48 2017 +0200
Committer: Lukasz Lenart 
Committed: Wed May 10 10:08:48 2017 +0200

--
 .../apache/struts2/views/freemarker/FreemarkerResult.java| 8 
 1 file changed, 4 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/b842a4c7/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index da631d9..c9130ac 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -144,16 +144,16 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 // Give subclasses a chance to hook into preprocessing
 if (preTemplateProcess(template, model)) {
 try {
-final boolean willUseBufferedWriter;
+final boolean willWriteIfCompleted;
 if (writeIfCompleted != null) {
-willUseBufferedWriter = isWriteIfCompleted();
+willWriteIfCompleted = isWriteIfCompleted();
 } else {
-willUseBufferedWriter = 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
+willWriteIfCompleted = 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
 }
 
 // Process the template
 Writer writer = getWriter();
-if (willUseBufferedWriter){
+if (willWriteIfCompleted){
 CharArrayWriter parentCharArrayWriter = (CharArrayWriter) 
req.getAttribute(PARENT_TEMPLATE_WRITER);
 boolean isTopTemplate;
 if (isTopTemplate = (parentCharArrayWriter == null)) {



[08/10] struts git commit: WW-4749 Uses writeIfCompleted to keep backward compatibility

2017-05-10 Thread lukaszlenart
WW-4749 Uses writeIfCompleted to keep backward compatibility


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

Branch: refs/heads/master
Commit: 38a2ebb72abd90c74bd52d6a81e3a0d967965c7b
Parents: 3034b3a
Author: Lukasz Lenart 
Authored: Fri Apr 28 13:14:30 2017 +0200
Committer: Lukasz Lenart 
Committed: Fri Apr 28 13:14:30 2017 +0200

--
 .../struts2/views/freemarker/FreemarkerResult.java  | 16 
 .../views/freemarker/FreeMarkerResultTest.java  | 14 +-
 2 files changed, 9 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/38a2ebb7/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
index b083796..da631d9 100644
--- 
a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
+++ 
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java
@@ -60,7 +60,7 @@ public class FreemarkerResult extends StrutsResultSupport {
 protected ObjectWrapper wrapper;
 protected FreemarkerManager freemarkerManager;
 private Writer writer;
-private Boolean useBufferedWriter = null;
+private Boolean writeIfCompleted = null;
 
 /*
  * Struts results are constructed for each result execution
@@ -145,8 +145,8 @@ public class FreemarkerResult extends StrutsResultSupport {
 if (preTemplateProcess(template, model)) {
 try {
 final boolean willUseBufferedWriter;
-if (useBufferedWriter != null) {
-willUseBufferedWriter = isUseBufferedWriter();
+if (writeIfCompleted != null) {
+willUseBufferedWriter = isWriteIfCompleted();
 } else {
 willUseBufferedWriter = 
template.getTemplateExceptionHandler() == 
TemplateExceptionHandler.RETHROW_HANDLER;
 }
@@ -356,14 +356,14 @@ public class FreemarkerResult extends StrutsResultSupport 
{
 return (Boolean) ObjectUtils.defaultIfNull(attribute, Boolean.FALSE);
 }
 
-public boolean isUseBufferedWriter() {
-return useBufferedWriter != null && useBufferedWriter;
+public boolean isWriteIfCompleted() {
+return writeIfCompleted != null && writeIfCompleted;
 }
 
 /**
- * @param useBufferedWriter template is processed and flushed according to 
freemarker library policies
+ * @param writeIfCompleted template is processed and flushed according to 
freemarker library policies
  */
-public void setUseBufferedWriter(Boolean useBufferedWriter) {
-this.useBufferedWriter = useBufferedWriter;
+public void setWriteIfCompleted(Boolean writeIfCompleted) {
+this.writeIfCompleted = writeIfCompleted;
 }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/38a2ebb7/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
--
diff --git 
a/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
 
b/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
index ec8ec05..1d8cb8f 100644
--- 
a/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
+++ 
b/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
@@ -22,32 +22,20 @@
 package org.apache.struts2.views.freemarker;
 
 import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.mock.MockActionInvocation;
 import com.opensymphony.xwork2.mock.MockActionProxy;
-import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
-import freemarker.template.Configuration;
-import freemarker.template.TemplateExceptionHandler;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsInternalTestCase;
 import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.dispatcher.Dispatcher;
-import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.views.jsp.StrutsMockHttpServletResponse;
 import org.apache.struts2.views.jsp.StrutsMockServletContext;
-import org.easymock.EasyMock;
 import org.springframework.mock.web.MockHttpServletRequest;
 

[06/10] struts git commit: WW-4749 Fixes test

2017-05-10 Thread lukaszlenart
WW-4749 Fixes test


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

Branch: refs/heads/master
Commit: 6dad53c5e316b3be2551a1bab47ee71b64ac3542
Parents: bbcd9dc
Author: Lukasz Lenart 
Authored: Fri Apr 28 10:01:27 2017 +0200
Committer: Lukasz Lenart 
Committed: Fri Apr 28 10:01:27 2017 +0200

--
 .../org/apache/struts2/views/freemarker/FreeMarkerResultTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/6dad53c5/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
--
diff --git 
a/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
 
b/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
index 060b927..ec8ec05 100644
--- 
a/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
+++ 
b/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
@@ -70,7 +70,7 @@ public class FreeMarkerResultTest extends 
StrutsInternalTestCase {
 FreemarkerResult result = new FreemarkerResult();
 result.setLocation("someFreeMarkerFile.ftl");
 result.setFreemarkerManager(mgr);
-result.setWriteIfCompleted(true);
+result.setUseBufferedWriter(true);
 
 try {
 result.execute(invocation);