Return-Path: Delivered-To: apmail-velocity-commits-archive@locus.apache.org Received: (qmail 34945 invoked from network); 14 Oct 2007 06:11:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Oct 2007 06:11:18 -0000 Received: (qmail 99029 invoked by uid 500); 14 Oct 2007 06:11:06 -0000 Delivered-To: apmail-velocity-commits-archive@velocity.apache.org Received: (qmail 98998 invoked by uid 500); 14 Oct 2007 06:11:06 -0000 Mailing-List: contact commits-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@velocity.apache.org Delivered-To: mailing list commits@velocity.apache.org Received: (qmail 98989 invoked by uid 99); 14 Oct 2007 06:11:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Oct 2007 23:11:06 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Oct 2007 06:11:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B817B1A9832; Sat, 13 Oct 2007 23:10:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r584488 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java Date: Sun, 14 Oct 2007 06:10:57 -0000 To: commits@velocity.apache.org From: nbubna@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071014061057.B817B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nbubna Date: Sat Oct 13 23:10:52 2007 New Revision: 584488 URL: http://svn.apache.org/viewvc?rev=584488&view=rev Log: avoid NPEs and just return null when there's no source map Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java?rev=584488&r1=584487&r2=584488&view=diff ============================================================================== --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java (original) +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ValueParser.java Sat Oct 13 23:10:52 2007 @@ -54,10 +54,6 @@ protected Map getSource() { - if (source == null) - { - throw new NullPointerException("You must set a Map source for values to be parsed."); - } return this.source; } @@ -91,8 +87,17 @@ return getValue(key); } + /** + * Returns the value mapped to the specified key + * in the {@link Map} returned by {@link #getSource()}. If there is + * no source, then this will always return {@code null}. + */ public Object getValue(String key) { + if (getSource() == null) + { + return null; + } return getSource().get(key); }