Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D5FD211F97 for ; Thu, 24 Jul 2014 00:44:58 +0000 (UTC) Received: (qmail 12697 invoked by uid 500); 24 Jul 2014 00:44:58 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 12643 invoked by uid 500); 24 Jul 2014 00:44:58 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 12634 invoked by uid 99); 24 Jul 2014 00:44:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jul 2014 00:44:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 57FE79B2371; Thu, 24 Jul 2014 00:44:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Thu, 24 Jul 2014 00:44:59 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: CAMEL-7630 Fixed the BlueprintPropertiesParser paser issue with multiple PropertyPlaceholders. CAMEL-7630 Fixed the BlueprintPropertiesParser paser issue with multiple PropertyPlaceholders. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/07841d5b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/07841d5b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/07841d5b Branch: refs/heads/master Commit: 07841d5be1175be1e9f383497588ff4e29e3008e Parents: 9f88bcb Author: Willem Jiang Authored: Thu Jul 24 08:42:10 2014 +0800 Committer: Willem Jiang Committed: Thu Jul 24 08:44:20 2014 +0800 ---------------------------------------------------------------------- .../blueprint/BlueprintPropertiesParser.java | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/07841d5b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java ---------------------------------------------------------------------- diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java index 4069c5f..d1bbde6 100644 --- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java +++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java @@ -122,7 +122,6 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { // lookup key in blueprint and return its value if (answer == null && key != null) { for (AbstractPropertyPlaceholder placeholder : placeholders) { - boolean isDefault = false; if (placeholders.size() > 1) { // okay we have multiple placeholders and we want to return the answer that @@ -133,28 +132,36 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser { } log.trace("Blueprint property key: {} is part of default properties: {}", key, isDefault); } - - String candidate = (String) ObjectHelper.invokeMethod(method, placeholder, key); - - if (candidate != null) { - if (answer == null || !isDefault) { - log.trace("Blueprint parsed candidate property key: {} as value: {}", key, answer); - answer = candidate; + + try { + String candidate = (String) ObjectHelper.invokeMethod(method, placeholder, key); + + if (candidate != null) { + if (answer == null || !isDefault) { + log.trace("Blueprint parsed candidate property key: {} as value: {}", key, answer); + answer = candidate; + } } - } + } catch (Exception ex) { + // Here we just catch the exception and try to use other candidate + } } - log.debug("Blueprint parsed property key: {} as value: {}", key, answer); } - + // if there is a delegate then let it parse the current answer as it may be jasypt which // need to decrypt values if (delegate != null) { String delegateAnswer = delegate.parseProperty(key, answer != null ? answer : value, properties); if (delegateAnswer != null) { answer = delegateAnswer; + log.debug("delegate property parser parsed the property key:{} as value: {}", key, answer); } } + + if (answer == null) { + throw new IllegalArgumentException("Cannot parser the property key: " + key + " with value: " + value); + } log.trace("Returning parsed property key: {} as value: {}", key, answer); return answer;