You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2016/09/08 20:34:06 UTC

Async tests with ListAppender

Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all
the time or when using in aync tests?

Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Remko Popma <re...@gmail.com>.
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 <ga...@gmail.com> 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 <re...@gmail.com> 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 <ga...@gmail.com> 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 <ra...@dslextreme.com> wrote:
>>>> So why are you asking?
>>>> 
>>>> Ralph
>>>> 
>>>>> On Sep 8, 2016, at 2:45 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>> 
>>>>>> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ra...@dslextreme.com> 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 <ga...@gmail.com> wrote:
>>>>>>> 
>>>>>>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
>>>>>>> 
>>>>>>> Gary
>>>>>>> 
>>>>>>> -- 
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>> 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: garydgregory@gmail.com | ggregory@apache.org 
>>>>> 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: garydgregory@gmail.com | ggregory@apache.org 
>>> 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: garydgregory@gmail.com | ggregory@apache.org 
> 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

Re: Async tests with ListAppender

Posted by Gary Gregory <ga...@gmail.com>.
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 <re...@gmail.com> 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 <ga...@gmail.com> 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 <ra...@dslextreme.com>
> wrote:
>
>> So why are you asking?
>>
>> Ralph
>>
>> On Sep 8, 2016, at 2:45 PM, Gary Gregory <ga...@gmail.com> wrote:
>>
>> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ra...@dslextreme.com>
>> 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 <ga...@gmail.com> wrote:
>>>
>>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either
>>> all the time or when using in aync tests?
>>>
>>> Gary
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> <gg...@apache.org>
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>>
>>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> <gg...@apache.org>
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Remko Popma <re...@gmail.com>.
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 <ga...@gmail.com> 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 <ra...@dslextreme.com> wrote:
>> So why are you asking?
>> 
>> Ralph
>> 
>>> On Sep 8, 2016, at 2:45 PM, Gary Gregory <ga...@gmail.com> wrote:
>>> 
>>>> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ra...@dslextreme.com> 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 <ga...@gmail.com> wrote:
>>>>> 
>>>>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
>>>>> 
>>>>> Gary
>>>>> 
>>>>> -- 
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>> 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: garydgregory@gmail.com | ggregory@apache.org 
>>> 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: garydgregory@gmail.com | ggregory@apache.org 
> 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

Re: Async tests with ListAppender

Posted by Gary Gregory <ga...@gmail.com>.
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 <ra...@dslextreme.com>
wrote:

> So why are you asking?
>
> Ralph
>
> On Sep 8, 2016, at 2:45 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ra...@dslextreme.com>
> 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 <ga...@gmail.com> wrote:
>>
>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all
>> the time or when using in aync tests?
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> <gg...@apache.org>
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> <gg...@apache.org>
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Ralph Goers <ra...@dslextreme.com>.
So why are you asking?

Ralph

> On Sep 8, 2016, at 2:45 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> 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 <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
>> 
>> Gary
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: Async tests with ListAppender

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Sep 8, 2016 at 2:00 PM, Ralph Goers <ra...@dslextreme.com>
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 <ga...@gmail.com> wrote:
>
> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all
> the time or when using in aync tests?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Ralph Goers <ra...@dslextreme.com>.
Why would it? Do you have multiple threads logging? It wasn’t written to be used by anything but single threaded unit tests.

Ralph

> On Sep 8, 2016, at 1:34 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
> 
> Gary
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: Async tests with ListAppender

Posted by Ralph Goers <ra...@dslextreme.com>.
Since it wasn’t designed to be used in a multi-threaded test it would be a mistake to do that.  I don’t know that I have written any multi-threaded tests that use it.

Ralph

> On Sep 15, 2016, at 12:25 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> Well, that was my initial question. Since we use ListAppender all over our tests, ARE WE in fact using it from IN ANY multithreaded manner? I do not know. If we are, then we might be getting lucky. I do not know.
> 
> Gary
> 
> On Thu, Sep 15, 2016 at 12:17 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Why are we even talking about this.  Does someone really have a use case where they want to use the ListAppender in a multithreaded manner in a unit test?
> 
> Ralph
> 
>> On Sep 15, 2016, at 12:13 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> I'm not sure why. Probably because we want our test code to be more like production code since tests show _how_ to use Log4j for some people. So we might as well do it in a way that is best. It seems that Java has a lot of concurrent classes that are designed to work better that a brute-force synchronous wrapper around a list. 
>> 
>> Gary
>> 
>> On Thu, Sep 15, 2016 at 2:44 AM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>> Why not a synchronized list? The performance might not be optimal, but probably be OK for unit tests.
>> 
>> On Thu, Sep 8, 2016 at 10:34 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
>> 
>> Gary
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>> 
>> 
>> -- 
>>  
>> 
>> Mikael Ståldal
>> Senior software developer 
>> 
>> Magine TV
>> mikael.staldal@magine.com <ma...@magine.com>    
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
>> 
>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>> you should destroy this message and kindly notify the sender by reply email.   
>> 
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: Async tests with ListAppender

Posted by Gary Gregory <ga...@gmail.com>.
Well, that was my initial question. Since we use ListAppender all over our
tests, ARE WE in fact using it from IN ANY multithreaded manner? I do not
know. If we are, then we might be getting lucky. I do not know.

Gary

On Thu, Sep 15, 2016 at 12:17 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Why are we even talking about this.  Does someone really have a use case
> where they want to use the ListAppender in a multithreaded manner in a unit
> test?
>
> Ralph
>
> On Sep 15, 2016, at 12:13 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> I'm not sure why. Probably because we want our test code to be more like
> production code since tests show _how_ to use Log4j for some people. So we
> might as well do it in a way that is best. It seems that Java has a lot of
> concurrent classes that are designed to work better that a brute-force
> synchronous wrapper around a list.
>
> Gary
>
> On Thu, Sep 15, 2016 at 2:44 AM, Mikael Ståldal <mikael.staldal@magine.com
> > wrote:
>
>> Why not a synchronized list? The performance might not be optimal, but
>> probably be OK for unit tests.
>>
>> On Thu, Sep 8, 2016 at 10:34 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either
>>> all the time or when using in aync tests?
>>>
>>> Gary
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Ralph Goers <ra...@dslextreme.com>.
Why are we even talking about this.  Does someone really have a use case where they want to use the ListAppender in a multithreaded manner in a unit test?

Ralph

> On Sep 15, 2016, at 12:13 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> I'm not sure why. Probably because we want our test code to be more like production code since tests show _how_ to use Log4j for some people. So we might as well do it in a way that is best. It seems that Java has a lot of concurrent classes that are designed to work better that a brute-force synchronous wrapper around a list. 
> 
> Gary
> 
> On Thu, Sep 15, 2016 at 2:44 AM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
> Why not a synchronized list? The performance might not be optimal, but probably be OK for unit tests.
> 
> On Thu, Sep 8, 2016 at 10:34 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all the time or when using in aync tests?
> 
> Gary
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>    
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: Async tests with ListAppender

Posted by Gary Gregory <ga...@gmail.com>.
I'm not sure why. Probably because we want our test code to be more like
production code since tests show _how_ to use Log4j for some people. So we
might as well do it in a way that is best. It seems that Java has a lot of
concurrent classes that are designed to work better that a brute-force
synchronous wrapper around a list.

Gary

On Thu, Sep 15, 2016 at 2:44 AM, Mikael Ståldal <mi...@magine.com>
wrote:

> Why not a synchronized list? The performance might not be optimal, but
> probably be OK for unit tests.
>
> On Thu, Sep 8, 2016 at 10:34 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all
>> the time or when using in aync tests?
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Async tests with ListAppender

Posted by Mikael Ståldal <mi...@magine.com>.
Why not a synchronized list? The performance might not be optimal, but
probably be OK for unit tests.

On Thu, Sep 8, 2016 at 10:34 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Should ListAppender use CopyOnWriteArray instead of ArrayList? Either all
> the time or when using in aync tests?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.