[
https://issues.apache.org/jira/browse/CAMEL-12352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16401550#comment-16401550
]
ASF GitHub Bot commented on CAMEL-12352:
----------------------------------------
onderson closed pull request #2255: CAMEL-12352 - make system property
uppercase if given lowercase in si…
URL: https://github.com/apache/camel/pull/2255
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index db91f214565..bab24bc8bce 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -765,7 +765,7 @@ public static Expression systemEnvironmentExpression(final
String propertyName,
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
String text =
simpleExpression(propertyName).evaluate(exchange, String.class);
- String answer = System.getenv(text);
+ String answer = System.getenv(text.toUpperCase());
if (answer == null) {
String text2 =
simpleExpression(defaultValue).evaluate(exchange, String.class);
answer = text2;
diff --git
a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 57132652c8f..0f1e357777e 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -238,6 +238,13 @@ public void testSimpleSystemEnvironmentExpressions()
throws Exception {
assertExpression("sysenv.PATH", path);
}
}
+
+ public void testSimpleSystemEnvironmentExpressionsIfLowercase() throws
Exception {
+ String path = System.getenv("PATH");
+ if (path != null) {
+ assertExpression("sysenv.path", path);
+ }
+ }
public void testSimpleCamelId() throws Exception {
assertExpression("camelId", context.getName());
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> simple - Lookup env var should be case-insensitive
> --------------------------------------------------
>
> Key: CAMEL-12352
> URL: https://issues.apache.org/jira/browse/CAMEL-12352
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Priority: Major
> Fix For: 2.22.0
>
>
> We should upper-case env var text before looking it up in System.getenv as
> ENV vars are upper-case.
> Today you have to do
> .setBody().simple("${sysenv.FALLBACK}")
> But you may type
> .setBody().simple("${sysenv.fallback}")
> To lookup an ENV with key FALLBACK
>
> This can be implemented in the
> org.apache.camel.builder.ExpressionBuilder#systemEnvironmentExpression(java.lang.String,
> java.lang.String)
> Contributions is welcome
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)