Apache Camel - 比较方法违反了其总合同

时间:2017-04-03 11:52:18

标签: apache-camel

似乎Apache Camel的某个内部类对GenericFile类的Comparator实现错误。

我使用的是Apache Camel版本2.17.3,但同样的问题也发生在2.18.3上。

我意识到它只发生在一个场景中:

我有一个处理器,它查看目录(和子目录)查找zip文件,当发现它们将它们解压缩到另一个目录时。

另一个处理提取目录的处理器,在那里寻找任何类型的文件。

e.g:

+ folder
  + sub1
    - zip1.zip
  + sub2
    - zip2.zip
+ extracted
  + zip1
    - <files from zip1.zip>
  + zip2
    - <files from zip2.zip>

当zip1.zip和zip2.zip包含具有相同名称的文件时,会出现问题。

e.g:

- zip1.zip
  - a1.txt
  - a2.txt 
- zip2.zip
  - a1.txt
  - a2.txt

即使我在不​​同的文件夹中提取它们,它也会在Camel中搞乱一些东西。这是StackTrace:

2017-04-03T14:08:18.846 WARN  - [Camel (CORE-AARE) thread #16 - file://...] - [org.apache.camel.component.file.FileConsumer] - Consumer Consumer[file://...] Will try again at next poll. Caused by: [java.lang.IllegalArgumentException - Comparison method violates its general contract!] 
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899)
at java.util.TimSort.mergeAt(TimSort.java:516)
at java.util.TimSort.mergeCollapse(TimSort.java:441)
at java.util.TimSort.sort(TimSort.java:245)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:152)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案