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 3296CD27C for ; Sat, 25 Aug 2012 09:51:24 +0000 (UTC) Received: (qmail 40744 invoked by uid 500); 25 Aug 2012 09:51:22 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 40545 invoked by uid 500); 25 Aug 2012 09:51:16 -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 40485 invoked by uid 99); 25 Aug 2012 09:51:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Aug 2012 09:51:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Aug 2012 09:51:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 10318238897F; Sat, 25 Aug 2012 09:50:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1377243 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/file/FileConsumer.java test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java Date: Sat, 25 Aug 2012 09:50:28 -0000 To: commits@camel.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120825095029.10318238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Sat Aug 25 09:50:28 2012 New Revision: 1377243 URL: http://svn.apache.org/viewvc?rev=1377243&view=rev Log: CAMEL-5540: Fixed NPE when consuming from root dir with file consumer Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=1377243&r1=1377242&r2=1377243&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java Sat Aug 25 09:50:28 2012 @@ -139,7 +139,7 @@ public class FileConsumer extends Generi // compute the file path as relative to the starting directory File path; String endpointNormalized = FileUtil.normalizePath(endpointPath); - if (file.getPath().startsWith(endpointNormalized)) { + if (file.getPath().startsWith(endpointNormalized + File.separator)) { // skip duplicate endpoint path path = new File(ObjectHelper.after(file.getPath(), endpointNormalized + File.separator)); } else { Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java?rev=1377243&view=auto ============================================================================== --- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java (added) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeRootDirManualTest.java Sat Aug 25 09:50:28 2012 @@ -0,0 +1,49 @@ +/** + * 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.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; + +public class FileConsumeRootDirManualTest extends ContextTestSupport { + + public void testSkipMe() { + // noop + } + + // manual test + public void xxxTestPollRootDirectory() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(2); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("file:/?noop=true") + .log("File: ${in.header.CamelFileName}") + .to("mock:result"); + } + }; + } +} +