[ 
https://issues.apache.org/jira/browse/CAMEL-10038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15322790#comment-15322790
 ] 

Matthew Zipay commented on CAMEL-10038:
---------------------------------------

In DefaultPropertiesParser:

{code:language=java}
String augmentedKey = getAugmentedKey(key);
boolean shouldFallback = fallbackToUnaugmentedProperty && 
!key.equals(augmentedKey);

String value = doGetPropertyValue(augmentedKey);
if (value == null && shouldFallback) {
    log.debug("Property with key [{}] not found, attempting with unaugmented 
key: {}", augmentedKey, key);
    value = doGetPropertyValue(key);
}
{code}

i.e. When an augmented property key is not found (null value) the lookup is
retried with the UNaugmented property key.

However, DefaultPropertiesParser actually gets "wrapped" by
BlueprintPropertiesParser, and we see the following at the end of the
parseProperty(String, String, Properties) method:

{code:language=java}
if (answer == null) {
    throw new IllegalArgumentException("Property placeholder key: " + key + " 
not found");
}
{code}

In a nutshell:
BlueprintPP gets an augmented property key and null value, and *should* be 
returning null so that DefaultPP can do its fallback behavior (which will 
ultimately throw the IllegalArgumentException itself if the property value is 
still null after fallback behavior. But instead, BlueprintPP throws an 
exception and the fallback behavior never happens.

Actual log events demonstrating this:

Here's what SHOULD happen: (this requires disabling the Blueprint properties 
resolver and bypassing BlueprintPropertiesParser altogether)

{noformat}
2016-06-09 10:50:27,531 | DEBUG | rint Extender: 3 | PropertiesComponent        
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133
 | Parsed location: file:etc/example.bpp.fallback.cfg
2016-06-09 10:50:27,531 | DEBUG | rint Extender: 3 | DefaultPropertiesParser    
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133 
 | Augmenting property key [CamelLogDebugBodyMaxChars] with prefix: LOCAL.
2016-06-09 10:50:27,532 | DEBUG | rint Extender: 3 | DefaultPropertiesParser    
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133 
 | Property with key [LOCAL.CamelLogDebugBodyMaxChars] not found, attempting 
with unaugmented key: CamelLogDebugBodyMaxChars
{noformat}

But here's what ACTUALLY happens when Blueprint properties resolver and parser 
are used: (the defaults)

{noformat}
2016-06-09 10:42:37,664 | DEBUG | rint Extender: 2 | PropertiesComponent        
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133 
 | Parsed location: blueprint:example-bpp-fallback-property-placeholder
2016-06-09 10:42:37,664 | DEBUG | rint Extender: 2 | BlueprintPropertiesParser  
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133 
 | Augmenting property key [CamelLogDebugBodyMaxChars] with prefix: LOCAL.
2016-06-09 10:42:37,664 | DEBUG | rint Extender: 2 | BlueprintPropertiesParser  
      | ?                                   ? | 198 - 
org.apache.camel.camel-core - 2.15.1.redhat-620133 
 | Blueprint parsed property key: LOCAL.CamelLogDebugBodyMaxChars as value: null
2016-06-09 10:42:37,665 | ERROR | rint Extender: 2 | BlueprintCamelContext      
      | ?                                   ? | 204 - 
org.apache.camel.camel-blueprint - 2.15.1.redhat-620133
 | Error occurred during starting Camel: CamelContext(example-bpp-fallback) ... 
because of Error getting property: CamelLogDebugBodyMaxChars
        at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1028)[198:org.apache.camel.camel-core:2.15.1.r
edhat-620133]
...
Caused by: java.lang.IllegalArgumentException: Property placeholder key: 
LOCAL.CamelLogDebugBodyMaxChars not found
        at 
org.apache.camel.blueprint.BlueprintPropertiesParser.parseProperty(BlueprintPropertiesParser.java:164)[204:org.apach
e.camel.camel-blueprint:2.15.1.redhat-620133]
{noformat}


> BlueprintPropertiesParser breaks propertyPlaceholder 
> fallbackToUnaugmentedProperty behavior
> -------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-10038
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10038
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-blueprint
>    Affects Versions: 2.15.1
>         Environment: Camel 2.15.1.redhat-620133
> JBoss Fuse 6.2.0.redhat-133
> openjdk version "1.8.0_45"
> OpenJDK Runtime Environment (build 1.8.0_45-b13)
> OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
> Linux 3.10.0-229.1.2.el7.x86_64 #1 SMP Fri Mar 6 17:12:08 EST 2015 x86_64 
> GNU/Linux (RHEL 7)
>            Reporter: Matthew Zipay
>            Assignee: Grzegorz Grzybek
>            Priority: Minor
>              Labels: patch
>
> When BlueprintPropertiesParser parses an "augmented" property key that is not 
> found (i.e. value is null), it does not return the null value so that the 
> fallbackToUnaugmentedProperty="true" (default) behavior can run. Instead, it 
> immediately throws an IllegalArgumentException.
> As a result, it appears to be impossible to take advantage of 
> fallbackToUnaugmentedProperty="true" behavior when using the Blueprint 
> properties resolver/parser.
> I discovered this against Red Hat's JBoss Fuse impl of Camel, but am 
> reporting it here because it appears to be a bug in base Camel. More details 
> in comments.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to