You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/09/16 16:12:59 UTC

svn commit: r997755 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/util/concurrent/ test/java/org/apache/camel/component/file/ test/java/org/apache/camel/impl/

Author: davsclaus
Date: Thu Sep 16 14:12:59 2010
New Revision: 997755

URL: http://svn.apache.org/viewvc?rev=997755&view=rev
Log:
CAMEL-3128: Fixed thread name when endpoint had dollar sign.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeWithDollarInPathTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java?rev=997755&r1=997754&r2=997755&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java Thu Sep 16 14:12:59 2010
@@ -69,6 +69,11 @@ public final class ExecutorServiceHelper
             pattern = DEFAULT_PATTERN;
         }
 
+        // the name could potential have a $ sign we want to keep
+        if (name.indexOf("$") > -1) {
+            name = name.replaceAll("\\$", "CAMEL_REPLACE_ME");
+        }
+
         // we support ${longName} and ${name} as name placeholders
         String longName = name;
         String shortName = name.contains("?") ? ObjectHelper.before(name, "?") : name;
@@ -80,6 +85,10 @@ public final class ExecutorServiceHelper
             throw new IllegalArgumentException("Pattern is invalid: " + pattern);
         }
 
+        if (answer.indexOf("CAMEL_REPLACE_ME") > -1) {
+            answer = answer.replaceAll("CAMEL_REPLACE_ME", "\\$");
+        }
+
         return answer;
     }
 

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeWithDollarInPathTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeWithDollarInPathTest.java?rev=997755&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeWithDollarInPathTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeWithDollarInPathTest.java Thu Sep 16 14:12:59 2010
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumeWithDollarInPathTest extends ContextTestSupport {
+
+    private String dir = "target/data/edi$/dev1";
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory(dir);
+        super.setUp();
+    }
+
+    public void testPathWithDollar() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBodyAndHeader("file:" + dir, "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:" + dir).to("mock:result");
+            }
+        };
+    }
+}

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java?rev=997755&r1=997754&r2=997755&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java Thu Sep 16 14:12:59 2010
@@ -51,6 +51,13 @@ public class DefaultExecutorServiceStrat
         assertTrue(bar.endsWith(" - bar"));
     }
 
+    public void testGetThreadNameCustomPatternWithDollar() throws Exception {
+        context.getExecutorServiceStrategy().setThreadNamePattern("Hello - ${name}");
+        String foo = context.getExecutorServiceStrategy().getThreadName("foo$bar");
+
+        assertEquals("Hello - foo$bar", foo);
+    }
+
     public void testGetThreadNameCustomPatternLongName() throws Exception {
         context.getExecutorServiceStrategy().setThreadNamePattern("#${counter} - ${longName}");
         String foo = context.getExecutorServiceStrategy().getThreadName("foo?beer=Carlsberg");