struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/2] struts git commit: Improve LocalizedTextUtil.getMessage() defend NPE
Date Thu, 03 Mar 2016 18:30:29 GMT
Repository: struts
Updated Branches:
  refs/heads/master f9fb3549c -> 5bcdd3d9f


Improve LocalizedTextUtil.getMessage() defend NPE

Defend NPE if not ValueStack presented, for example non-struts request like static util method
or backend thread.

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

Branch: refs/heads/master
Commit: f2f5338ded3c2256c878a9d7cb3a62c1b07ce2e7
Parents: 4cd9a74
Author: zhouyanming <zhouyanming@gmail.com>
Authored: Mon Sep 14 08:50:43 2015 +0800
Committer: zhouyanming <zhouyanming@gmail.com>
Committed: Mon Sep 14 08:50:43 2015 +0800

----------------------------------------------------------------------
 .../java/com/opensymphony/xwork2/util/LocalizedTextUtil.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f2f5338d/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java b/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
index fa5a178..2277bec 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
@@ -736,9 +736,12 @@ public class LocalizedTextUtil {
         if (bundle == null) {
             return null;
         }
+        if (valueStack != null) 
             reloadBundles(valueStack.getContext());
         try {
-            String message = TextParseUtil.translateVariables(bundle.getString(key), valueStack);
+        	String message = bundle.getString(key);
+        	if (valueStack != null) 
+        		message = TextParseUtil.translateVariables(bundle.getString(key), valueStack);
             MessageFormat mf = buildMessageFormat(message, locale);
             return formatWithNullDetection(mf, args);
         } catch (MissingResourceException e) {


Mime
View raw message