-
Bug
-
Resolution: Done
-
Normal
-
CSB-3.20.1
In a concurrent situation, access violation occurs due to race condition. Please check the source code here.
rhaf-camel-3.18.3.ER10-src/camel-3.18.3/core/camel-util/src/main/java/org/apache/camel/util/ReflectionHelper.java
public static void setField(Field f, Object instance, Object value) { try { boolean oldAccessible = f.isAccessible(); boolean shouldSetAccessible = !Modifier.isPublic(f.getModifiers()) && !oldAccessible; if (shouldSetAccessible) { f.setAccessible(true); } f.set(instance, value); if (shouldSetAccessible) { f.setAccessible(oldAccessible); } } catch (Exception ex) { throw new UnsupportedOperationException("Cannot inject value of class: " + value.getClass() + " into: " + f); // breakpoint } }
Thread A: invokes check the accessibility and set "shouldSetAccessible" to true.
Thread A: invokes f.setAccessible(true);
Thread B: invokes check the accessibility and set "shouldSetAccessible" to false.
Thread A: invokes f.set(instance, value and f.setAccessible(oldAccessible);
Thread B: invokes f.set(instance, value); and java.lang.IllegalAccessException occurs.
Instruction to reproduce the issue.
- Unizp the attached Eclipse project.
- copy csv files under csb-app/src/main/resources/data to work/cbr/output/uk directory.
- Run com.redhat.MySpringBootApplication.main()
- Following exception will occur.
java.lang.UnsupportedOperationException: Cannot inject value of class: class com.redhat.MyModel2 into: private com.redhat.MyModel2 com.redhat.MyModel.myModel2 at org.apache.camel.util.ReflectionHelper.setField(ReflectionHelper.java:192) ~[camel-util-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.dataformat.bindy.BindyAbstractFactory.link(BindyAbstractFactory.java:150) ~[camel-bindy-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.lambda$consumeFile$0(BindyCsvDataFormat.java:263) ~[camel-bindy-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na] at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[na:na] at java.base/java.util.stream.ReferencePipeline$Head.forEachOrdered(ReferencePipeline.java:772) ~[na:na] at org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:183) ~[camel-bindy-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.support.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:76) ~[camel-support-3.20.1.jar:3.20.1] at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) ~[camel-core-processor-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:181) ~[camel-base-engine-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.impl.engine.DefaultReactiveExecutor.schedule(DefaultReactiveExecutor.java:54) ~[camel-base-engine-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:482) ~[camel-core-processor-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.done(RedeliveryErrorHandler.java:416) ~[camel-core-processor-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:87) ~[camel-core-processor-3.20.1.redhat-00031.jar:3.20.1.redhat-00031] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na] at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
- links to
There are no Sub-Tasks for this issue.