Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java (revision 13b79316bc0590bc99e6886ca0ff95fe3b5fea86)
- +++ camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java (revision )
- @@ -50,6 +50,20 @@
- if (!lock) {
- // do not begin since we could not get the exclusive read lock
- return false;
- + } else {
- + // check current file length and lastModify
- + if (file.getFile() instanceof File) { // todo if not File what else?
- + final long length = ((File) file.getFile()).length();
- + final long lastModified = ((File) file.getFile()).lastModified();
- + if (file.getFileLength() != length || file.getLastModified() != lastModified) {
- + // updating generic file length and lastModified
- + file.setFileLength(length);
- + file.setLastModified(lastModified);
- + // updating headers
- + exchange.getIn().setHeader(Exchange.FILE_LENGTH, length);
- + exchange.getIn().setHeader(Exchange.FILE_LAST_MODIFIED, lastModified);
- + }
- + }
- }
- }
- Index: camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java (revision 13b79316bc0590bc99e6886ca0ff95fe3b5fea86)
- +++ camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java (revision )
- @@ -20,6 +20,7 @@
- import java.io.FileOutputStream;
- import org.apache.camel.ContextTestSupport;
- +import org.apache.camel.Exchange;
- import org.apache.camel.builder.RouteBuilder;
- import org.apache.camel.component.mock.MockEndpoint;
- import org.slf4j.Logger;
- @@ -39,10 +40,19 @@
- super.setUp();
- }
- + long expectedFileLength() {
- + long length = 0;
- + for (int i = 0; i < 20; i++) {
- + length += ("Line " + i + LS).getBytes().length;
- + }
- + return length;
- + }
- +
- public void testChangedReadLock() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedFileExists("target/changed/out/slowfile.dat");
- + mock.expectedHeaderReceived(Exchange.FILE_LENGTH, expectedFileLength());
- writeSlowFile();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement