You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2012/11/11 15:11:26 UTC

svn commit: r1407995 - /camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java

Author: bvahdat
Date: Sun Nov 11 14:11:25 2012
New Revision: 1407995

URL: http://svn.apache.org/viewvc?rev=1407995&view=rev
Log:
CAMEL-5784: Extracted the String-tailing-whitespace-trimming-logic into an extra method.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java?rev=1407995&r1=1407994&r2=1407995&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesResolver.java Sun Nov 11 14:11:25 2012
@@ -131,25 +131,30 @@ public class DefaultPropertiesResolver i
         for (Map.Entry<Object, Object> entry : properties.entrySet()) {
             Object key = entry.getKey();
             Object value = entry.getValue();
-            // trim any trailing spaces which can be a problem when loading from
-            // a properties file, note that java.util.Properties does already this
-            // for any potential leading spaces so there's nothing to do there
             if (value instanceof String) {
                 String s = (String) value;
-                int endIndex = s.length();
-                for (int index = s.length() - 1; index >= 0; index--) {
-                    if (s.charAt(index) == ' ') {
-                        endIndex = index;
-                    } else {
-                        break;
-                    }
-                }
-                s = s.substring(0, endIndex);
-                value = s;
+
+                // trim any trailing spaces which can be a problem when loading from
+                // a properties file, note that java.util.Properties does already this
+                // for any potential leading spaces so there's nothing to do there
+                value = trimTrailingWhitespaces(s);
             }
             answer.put(key, value);
         }
         return answer;
     }
 
+    private static String trimTrailingWhitespaces(String s) {
+        int endIndex = s.length();
+        for (int index = s.length() - 1; index >= 0; index--) {
+            if (s.charAt(index) == ' ') {
+                endIndex = index;
+            } else {
+                break;
+            }
+        }
+        String answer = s.substring(0, endIndex);
+        return answer;
+    }
+
 }