Gary,
You mention that it makes XML JSON serialization easier if the ContextStack
held in Log4jLogEvent implements the Collection interface.
Can you explain that a bit more? Perhaps there is another way to achieve
the same benefit.

Remko


On Fri, May 16, 2014 at 11:33 PM, Gary Gregory <[email protected]>wrote:

> It's also hard to think of a "stack" as _not_ being a "collection".
>
> This is a good time to talk about it since we'll be stuck with it when we
> ship 2.0.
>
> Also I could understand why we would not want a java.util.Stack since it
> is a Vector, but Java offers ArrayDeque. So why not use that?
>
> Gary
>
>
> On Fri, May 16, 2014 at 10:29 AM, Gary Gregory <[email protected]>wrote:
>
>> All of the ThreadContextStack implementations we have are Collections
>> though... (that was the case before the refactoring)
>>
>> Gary
>>
>>
>>  On Thu, May 15, 2014 at 11:19 AM, Ralph Goers <
>> [email protected]> wrote:
>>
>>> I actually dislike ThreadContextStack but it is there for compatibility
>>> with Log4j 1.x.  I guess there are people who use it.  I didn’t make it a
>>> Collection in the first place for the exact reasons you mention - they
>>> aren’t used.
>>>
>>> Ralph
>>>
>>> On May 14, 2014, at 9:24 PM, Remko Popma <[email protected]> wrote:
>>>
>>> > Well, the difference is that now the api (the
>>> ThreadContext.ContextStack interface) extends Collection, so all
>>> implementations now *must* support all methods declared on Collection. This
>>> was not a requirement before.
>>> > (Not sure why spi.ThreadContextStack extends Collection, by the way.
>>> ThreadContext will not use these methods...)
>>> >
>>> > Remko
>>> >
>>> > Sent from my iPhone
>>> >
>>> >> On 2014/05/08, at 4:35, [email protected] wrote:
>>> >>
>>> >> Author: ggregory
>>> >> Date: Wed May  7 19:35:45 2014
>>> >> New Revision: 1593125
>>> >>
>>> >> URL: http://svn.apache.org/r1593125
>>> >> Log:
>>> >> ThreadContext.ContextStack is already (conceptually) a collection of
>>> Strings so it should be a Collection<String> instead of it's sub-interface
>>> ThreadContextStack being a Collection<String>. What's the value of
>>> ThreadContextStack now? Should we keep it as a placeholder? It is not
>>> documented in its Javadoc. Note that all implementations of ContextStack
>>> are implementations of ThreadContextStack, so this change has no effect on
>>> implementors. Note that Log4jLogEvent holds a ContextStack so this makes it
>>> a Collection<String> which happens to save a lot of work for XML and JSON
>>> IO for the Jackson based receivers and layouts I am working on.
>>> >>
>>> >> Modified:
>>> >>
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
>>> >>
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
>>> >>
>>> >> Modified:
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
>>> >> URL:
>>> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java?rev=1593125&r1=1593124&r2=1593125&view=diff
>>> >>
>>> ==============================================================================
>>> >> ---
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
>>> (original)
>>> >> +++
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
>>> Wed May  7 19:35:45 2014
>>> >> @@ -347,12 +347,7 @@ public final class ThreadContext  {
>>> >>    /**
>>> >>     * The ThreadContext Stack interface.
>>> >>     */
>>> >> -    public interface ContextStack extends Serializable {
>>> >> -
>>> >> -        /**
>>> >> -         * Clears all elements from the stack.
>>> >> -         */
>>> >> -        void clear();
>>> >> +    public interface ContextStack extends Serializable,
>>> Collection<String> {
>>> >>
>>> >>        /**
>>> >>         * Returns the element at the top of the stack.
>>> >>
>>> >> Modified:
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
>>> >> URL:
>>> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java?rev=1593125&r1=1593124&r2=1593125&view=diff
>>> >>
>>> ==============================================================================
>>> >> ---
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
>>> (original)
>>> >> +++
>>> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/spi/ThreadContextStack.java
>>> Wed May  7 19:35:45 2014
>>> >> @@ -16,12 +16,10 @@
>>> >> */
>>> >> package org.apache.logging.log4j.spi;
>>> >>
>>> >> -import java.util.Collection;
>>> >> -
>>> >> import org.apache.logging.log4j.ThreadContext;
>>> >>
>>> >> /**
>>> >> *
>>> >> */
>>> >> -public interface ThreadContextStack extends
>>> ThreadContext.ContextStack, Collection<String> {
>>> >> +public interface ThreadContextStack extends
>>> ThreadContext.ContextStack {
>>> >> }
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [email protected]
>>> > For additional commands, e-mail: [email protected]
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>>
>> --
>> E-Mail: [email protected] | [email protected]
>> 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: [email protected] | [email protected]
> 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
>

Reply via email to