RichTextFX
RichTextFX copied to clipboard
java.util.ConcurrentModificationException
I use richtextFx for a json viewer, and try to assemble bracket highlight and fold paragraphs. but I meet a trouble.
in org.fxmisc.richtext.TextFlowLayout#getLineCount
, when foreach flow.getChildren()
, the code n.getBoundsInParent()
will call javafx.scene.Node.LazyBoundsProperty#get
, and call com.sun.javafx.collections.VetoableListDecorator#add(int, E)
, final trigger java.util.ConcurrentModificationException
, how can I avoid it? thank you!
- richTextFx: 0.10.9
- flowless: 0.6.10
- java: 11
stacktrace:
java.util.ConcurrentModificationException
at javafx.base/com.sun.javafx.collections.VetoableListDecorator$VetoableIteratorDecorator.checkForComodification(VetoableListDecorator.java:714)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator$VetoableIteratorDecorator.hasNext(VetoableListDecorator.java:682)
at [email protected]/org.fxmisc.richtext.TextFlowLayout.getLineCount(TextFlowLayout.java:78)
at [email protected]/org.fxmisc.richtext.TextFlowExt.getLineCount(TextFlowExt.java:35)
at [email protected]/org.fxmisc.richtext.ParagraphText.getRangeShapeSafely(ParagraphText.java:409)
at [email protected]/org.fxmisc.richtext.ParagraphText.getRangeShapeSafely(ParagraphText.java:339)
at [email protected]/org.fxmisc.richtext.ParagraphText.updateSingleSelection(ParagraphText.java:335)
at [email protected]/org.fxmisc.richtext.ParagraphText.lambda$new$1(ParagraphText.java:115)
at javafx.base/com.sun.javafx.collections.MapListenerHelper$SingleChange.fireValueChangedEvent(MapListenerHelper.java:163)
at javafx.base/com.sun.javafx.collections.MapListenerHelper.fireValueChangedEvent(MapListenerHelper.java:72)
at javafx.base/com.sun.javafx.collections.ObservableMapWrapper.callObservers(ObservableMapWrapper.java:115)
at javafx.base/com.sun.javafx.collections.ObservableMapWrapper.put(ObservableMapWrapper.java:173)
at [email protected]/org.fxmisc.richtext.GenericStyledArea.lambda$createCell$65(GenericStyledArea.java:1967)
at [email protected]/org.reactfx.util.NonAccumulativeStreamNotifications.lambda$head$0(NotificationAccumulator.java:134)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.ProperEventStream.emit(ProperEventStream.java:18)
at [email protected]/org.reactfx.EventStreams$27.tryEmit(EventStreams.java:599)
at [email protected]/org.reactfx.EventStreams$27.lambda$observeInputs$1(EventStreams.java:593)
at [email protected]/org.reactfx.util.NonAccumulativeStreamNotifications.lambda$head$0(NotificationAccumulator.java:134)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.ProperEventStream.emit(ProperEventStream.java:18)
at [email protected]/org.reactfx.EventStreams$4.lambda$observeInputs$0(EventStreams.java:123)
at [email protected]/org.reactfx.value.ChangeListenerWrapper.accept(Val.java:786)
at [email protected]/org.reactfx.util.AbstractReducingStreamNotifications.lambda$head$0(NotificationAccumulator.java:248)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.value.ValBase.invalidate(ValBase.java:32)
at [email protected]/org.reactfx.value.MappedVal.lambda$connect$0(MappedVal.java:28)
at [email protected]/org.reactfx.value.InvalidationListenerWrapper.accept(Val.java:765)
at [email protected]/org.reactfx.util.AbstractReducingStreamNotifications.lambda$head$0(NotificationAccumulator.java:248)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.value.ValBase.invalidate(ValBase.java:32)
at [email protected]/org.reactfx.value.MappedVal.lambda$connect$0(MappedVal.java:28)
at [email protected]/org.reactfx.value.InvalidationListenerWrapper.accept(Val.java:765)
at [email protected]/org.reactfx.util.AbstractReducingStreamNotifications.lambda$head$0(NotificationAccumulator.java:248)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.value.ValBase.invalidate(ValBase.java:32)
at [email protected]/org.reactfx.value.SimpleVar.setValue(SimpleVar.java:59)
at [email protected]/org.fxmisc.richtext.SelectionImpl.lambda$new$4(SelectionImpl.java:197)
at [email protected]/org.reactfx.value.InvalidationListenerWrapper.accept(Val.java:765)
at [email protected]/org.reactfx.util.AbstractReducingStreamNotifications.lambda$head$0(NotificationAccumulator.java:248)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
at [email protected]/org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
at [email protected]/org.reactfx.value.ValBase.invalidate(ValBase.java:32)
at [email protected]/org.reactfx.value.SimpleVar.setValue(SimpleVar.java:59)
at [email protected]/org.fxmisc.richtext.SelectionImpl.lambda$selectRange$8(SelectionImpl.java:304)
at [email protected]/org.fxmisc.richtext.SelectionImpl.selectRange(SelectionImpl.java:306)
at [email protected]/org.fxmisc.richtext.SelectionImpl.selectRange(SelectionImpl.java:300)
at [email protected]/org.fxmisc.richtext.CaretSelectionBindImpl.lambda$doSelect$6(CaretSelectionBindImpl.java:457)
at [email protected]/org.reactfx.Suspendable.suspendWhile(Suspendable.java:49)
at [email protected]/org.fxmisc.richtext.CaretSelectionBindImpl.doUpdate(CaretSelectionBindImpl.java:467)
at [email protected]/org.fxmisc.richtext.CaretSelectionBindImpl.doSelect(CaretSelectionBindImpl.java:456)
at [email protected]/org.fxmisc.richtext.CaretSelectionBindImpl.selectRangeExpl(CaretSelectionBindImpl.java:360)
at [email protected]/org.fxmisc.richtext.TextEditingArea.selectRange(TextEditingArea.java:270)
at [email protected]/org.fxmisc.richtext.GenericStyledArea.replace(GenericStyledArea.java:1549)
at [email protected]/org.fxmisc.richtext.GenericStyledArea.replaceText(GenericStyledArea.java:1533)
at [email protected]/org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:396)
at [email protected]/org.fxmisc.richtext.EditActions.replaceSelection(EditActions.java:179)
at [email protected]/org.fxmisc.richtext.GenericStyledAreaBehavior.lambda$static$2(GenericStyledAreaBehavior.java:86)
at org.fxmisc.wellbehaved.event.template.InputMapTemplate.lambda$consume$0(InputMapTemplate.java:221)
at org.fxmisc.wellbehaved.event.template.PatternActionTemplate.lambda$null$1(InputMapTemplate.java:425)
at java.base/java.util.Optional.map(Optional.java:265)
at org.fxmisc.wellbehaved.event.template.PatternActionTemplate.lambda$getInputHandlerTemplateMap$2(InputMapTemplate.java:425)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:25)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputMapTemplate$2.lambda$null$0(InputMapTemplate.java:341)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputMapTemplate$1.lambda$null$0(InputMapTemplate.java:202)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputMapTemplate$1.lambda$null$0(InputMapTemplate.java:202)
at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$0(InputHandlerTemplateMap.java:24)
at org.fxmisc.wellbehaved.event.template.InputMapTemplate$HandlerTemplateConsumer$1.lambda$accept$0(InputMapTemplate.java:103)
at org.fxmisc.wellbehaved.event.InputHandler.handle(InputHandler.java:50)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.access$1500(Scene.java:4004)
at javafx.graphics/javafx.scene.Scene.processKeyEvent(Scene.java:2121)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(View.java:547)
at javafx.graphics/com.sun.glass.ui.View.notifyKey(View.java:971)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
github: https://github.com/FrogIf/FrogJson branch: feature-fold
the demo:
and if I remove one code, the problem will be solved, like this:
Thanks for the bug report and demo, it's greatly appreciated !!! Have submitted a PR to fix ....