Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BAD1718D4D for ; Thu, 3 Mar 2016 18:30:29 +0000 (UTC) Received: (qmail 22089 invoked by uid 500); 3 Mar 2016 18:30:29 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 22044 invoked by uid 500); 3 Mar 2016 18:30:29 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 22027 invoked by uid 99); 3 Mar 2016 18:30:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 18:30:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 50FC8E78E9; Thu, 3 Mar 2016 18:30:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lukaszlenart@apache.org To: commits@struts.apache.org Date: Thu, 03 Mar 2016 18:30:29 -0000 Message-Id: <457b66bec598421daeec5963c5518b4d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] struts git commit: Improve LocalizedTextUtil.getMessage() defend NPE 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 Authored: Mon Sep 14 08:50:43 2015 +0800 Committer: zhouyanming 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) {