Advertisement
Guest User

CAMEL-9970

a guest
May 16th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.99 KB | None | 0 0
  1. Index: camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java    (revision 13b79316bc0590bc99e6886ca0ff95fe3b5fea86)
  7. +++ camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileProcessStrategySupport.java    (revision )
  8. @@ -50,6 +50,20 @@
  9.              if (!lock) {
  10.                  // do not begin since we could not get the exclusive read lock
  11.                  return false;
  12. +            } else {
  13. +                // check current file length and lastModify
  14. +                if (file.getFile() instanceof File) { // todo if not File what else?
  15. +                    final long length = ((File) file.getFile()).length();
  16. +                    final long lastModified = ((File) file.getFile()).lastModified();
  17. +                    if (file.getFileLength() != length || file.getLastModified() != lastModified) {
  18. +                        // updating generic file length and lastModified
  19. +                        file.setFileLength(length);
  20. +                        file.setLastModified(lastModified);
  21. +                        // updating headers
  22. +                        exchange.getIn().setHeader(Exchange.FILE_LENGTH, length);
  23. +                        exchange.getIn().setHeader(Exchange.FILE_LAST_MODIFIED, lastModified);
  24. +                    }
  25. +                }
  26.              }
  27.          }
  28.  
  29. Index: camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java
  30. IDEA additional info:
  31. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  32. <+>UTF-8
  33. ===================================================================
  34. --- camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java  (revision 13b79316bc0590bc99e6886ca0ff95fe3b5fea86)
  35. +++ camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockTest.java  (revision )
  36. @@ -20,6 +20,7 @@
  37.  import java.io.FileOutputStream;
  38.  
  39.  import org.apache.camel.ContextTestSupport;
  40. +import org.apache.camel.Exchange;
  41.  import org.apache.camel.builder.RouteBuilder;
  42.  import org.apache.camel.component.mock.MockEndpoint;
  43.  import org.slf4j.Logger;
  44. @@ -39,10 +40,19 @@
  45.          super.setUp();
  46.      }
  47.  
  48. +    long expectedFileLength() {
  49. +        long length = 0;
  50. +        for (int i = 0; i < 20; i++) {
  51. +            length += ("Line " + i + LS).getBytes().length;
  52. +        }
  53. +        return length;
  54. +    }
  55. +
  56.      public void testChangedReadLock() throws Exception {
  57.          MockEndpoint mock = getMockEndpoint("mock:result");
  58.          mock.expectedMessageCount(1);
  59.          mock.expectedFileExists("target/changed/out/slowfile.dat");
  60. +        mock.expectedHeaderReceived(Exchange.FILE_LENGTH, expectedFileLength());
  61.  
  62.          writeSlowFile();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement