To answer your original question should ListAppender internally use CopyOnWriteArrayList, probably yes. There is certainly no harm and it might prevent unpredictable behavior.
Also, ListAppender actually provides a CountDownLatch that you can set in the test (before logging) with the expected number of events. The appender will count down with each event, so in the test you can do countDownLatch.await(). Sent from my iPhone > On 2016/09/09, at 8:33, Gary Gregory <[email protected]> wrote: > > I'm pretty sure I've "fixed" AsyncAppender for now. The test needs to wait > long enough is all. Feel free to check the current version and AsyncAppender > and tell me what you think. > > Gary > >> On Thu, Sep 8, 2016 at 4:26 PM, Remko Popma <[email protected]> wrote: >> Ah, you're if it's possible that the reason the AsyncAppender test is >> failing is because of a concurrency issue in ListAppender. It is possible >> when the queue is full: our recent change to the DefaultAsyncQueueFullPolicy >> is to log synchronously when the queue is full. This is also used in >> AsyncAppender. >> >> Sent from my iPhone >> >>> On 2016/09/09, at 8:14, Gary Gregory <[email protected]> wrote: >>> >>> Do we have tests that are async (I'd say yes of course) and that could >>> loose events in a list appender (I do not know)? Are we getting lucky? IOW, >>> do we have the kind of async tests that end up stressing the system in a >>> way were we could loose events in a list appender (don't know). If we do >>> not, should we, is that missing? >>> >>> Gary >>> >>>> On Thu, Sep 8, 2016 at 4:09 PM, Ralph Goers <[email protected]> >>>> wrote: >>>> So why are you asking? >>>> >>>> Ralph >>>> >>>>> On Sep 8, 2016, at 2:45 PM, Gary Gregory <[email protected]> wrote: >>>>> >>>>>> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <[email protected]> >>>>>> wrote: >>>>>> Why would it? Do you have multiple threads logging? It wasn’t written to >>>>>> be used by anything but single threaded unit tests. >>>>> >>>>> I do not have multiple threads logging in a test but I do not know if >>>>> there is one such test in the whole suite. >>>>> >>>>> Gary >>>>> >>>>>> >>>>>> Ralph >>>>>> >>>>>>> On Sep 8, 2016, at 1:34 PM, Gary Gregory <[email protected]> wrote: >>>>>>> >>>>>>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either >>>>>>> all the time or when using in aync tests? >>>>>>> >>>>>>> Gary >>>>>>> >>>>>>> -- >>>>>>> E-Mail: [email protected] | [email protected] >>>>>>> Java Persistence with Hibernate, Second Edition >>>>>>> JUnit in Action, Second Edition >>>>>>> Spring Batch in Action >>>>>>> Blog: http://garygregory.wordpress.com >>>>>>> Home: http://garygregory.com/ >>>>>>> Tweet! http://twitter.com/GaryGregory >>>>> >>>>> >>>>> >>>>> -- >>>>> E-Mail: [email protected] | [email protected] >>>>> Java Persistence with Hibernate, Second Edition >>>>> JUnit in Action, Second Edition >>>>> Spring Batch in Action >>>>> Blog: http://garygregory.wordpress.com >>>>> Home: http://garygregory.com/ >>>>> Tweet! http://twitter.com/GaryGregory >>> >>> >>> >>> -- >>> E-Mail: [email protected] | [email protected] >>> Java Persistence with Hibernate, Second Edition >>> JUnit in Action, Second Edition >>> Spring Batch in Action >>> Blog: http://garygregory.wordpress.com >>> Home: http://garygregory.com/ >>> Tweet! http://twitter.com/GaryGregory > > > > -- > E-Mail: [email protected] | [email protected] > Java Persistence with Hibernate, Second Edition > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory
