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 Mikael Ståldal <mi...@magine.com> on 2016/11/10 12:55:05 UTC

ThreadContext.removeAll

Would it make sense to have a removeAll(Iterable<String>) method in
ThreadContext, as a companion to putAll(Map<String, String>)?

And a corresponding method in ThreadContextMap2, which can be implemented
in an atomic way similarly to putAll.

-- 
[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.

Re: ThreadContext.removeAll

Posted by Mikael Ståldal <mi...@magine.com>.
My use case was for a ThreadContext wrapper in the Scala API:
https://issues.apache.org/jira/browse/LOG4J2-1690

On Sat, Nov 26, 2016 at 6:25 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Maybe in a unit test? But then why nit clear the whole map?
>
> Gary
>
> On Nov 26, 2016 8:09 AM, "Apache" <ra...@dslextreme.com> wrote:
>
>> Do you have a use case for it? In all my usages of the ThreadContext I
>> always add attributes one at a time but then clear the whole
>> ThreadContextMap at the end of the request. It isn’t clear to me why
>> someone would want to remove a subset.
>>
>> Ralph
>>
>> On Nov 10, 2016, at 5:55 AM, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> Would it make sense to have a removeAll(Iterable<String>) method in
>> ThreadContext, as a companion to putAll(Map<String, String>)?
>>
>> And a corresponding method in ThreadContextMap2, which can be implemented
>> in an atomic way similarly to putAll.
>>
>> --
>> [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.
>>
>>
>>


-- 
[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.

Re: ThreadContext.removeAll

Posted by Gary Gregory <ga...@gmail.com>.
Maybe in a unit test? But then why nit clear the whole map?

Gary

On Nov 26, 2016 8:09 AM, "Apache" <ra...@dslextreme.com> wrote:

> Do you have a use case for it? In all my usages of the ThreadContext I
> always add attributes one at a time but then clear the whole
> ThreadContextMap at the end of the request. It isn’t clear to me why
> someone would want to remove a subset.
>
> Ralph
>
> On Nov 10, 2016, at 5:55 AM, Mikael Ståldal <mi...@magine.com>
> wrote:
>
> Would it make sense to have a removeAll(Iterable<String>) method in
> ThreadContext, as a companion to putAll(Map<String, String>)?
>
> And a corresponding method in ThreadContextMap2, which can be implemented
> in an atomic way similarly to putAll.
>
> --
> [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.
>
>
>

Re: ThreadContext.removeAll

Posted by Apache <ra...@dslextreme.com>.
Do you have a use case for it? In all my usages of the ThreadContext I always add attributes one at a time but then clear the whole ThreadContextMap at the end of the request. It isn’t clear to me why someone would want to remove a subset.

Ralph

> On Nov 10, 2016, at 5:55 AM, Mikael Ståldal <mi...@magine.com> wrote:
> 
> Would it make sense to have a removeAll(Iterable<String>) method in ThreadContext, as a companion to putAll(Map<String, String>)?
> 
> And a corresponding method in ThreadContextMap2, which can be implemented in an atomic way similarly to putAll.
> 
> -- 
>  
> 
> 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.   


Re: ThreadContext.removeAll

Posted by Gary Gregory <ga...@gmail.com>.
Seems ok with me if you have a use case for it, even if it just makes tests
cleaner.

Gary

On Nov 10, 2016 4:55 AM, "Mikael Ståldal" <mi...@magine.com> wrote:

> Would it make sense to have a removeAll(Iterable<String>) method in
> ThreadContext, as a companion to putAll(Map<String, String>)?
>
> And a corresponding method in ThreadContextMap2, which can be implemented
> in an atomic way similarly to putAll.
>
> --
> [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.
>