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 Paul Smith <ps...@aconex.com> on 2005/12/02 06:39:28 UTC
Thread safety issue in LoggingEvent (1.3 code)
Umm, am I missing something or is this thread unsafe in LoggingEvent?
static final Integer[] PARAM_ARRAY = new Integer[1];
....
in readLevel(ObjectInputStream){.
....
PARAM_ARRAY[0] = new Integer(p);
level = (Level)m.invoke(null, (Object[]) PARAM_ARRAY);
Is there some synchronization done here? If not, wouldn't the
PARAM_ARRAY be shared? If this was the case and one had multiple
Receivers reading data from multiple sources, then there is a
possibility of data corruption?
Thoughts?
Paul
Re: Thread safety issue in LoggingEvent (1.3 code)
Posted by Curt Arnold <ca...@apache.org>.
Looks like it to me, also appears in the 1.2 branch.
Is className typically null, resulting in the offending path only
taken with a custom level? If not, could checks for
"org.apache.log4j.Level" and "org.apache.log4j.Priority" avoiding the
reflection overhead except where really needed?
I've got to think the cost of a "new Integer[1]" in anything later
than JDK 1.1 has got to be trivial compared to the method invocation
overhead. Unfortunately, you can't eliminate PARAM_ARRAY since it
wasn't declared private, but you aren't required to use it. You
should mark it deprecated however.
On Dec 1, 2005, at 11:39 PM, Paul Smith wrote:
> Umm, am I missing something or is this thread unsafe in LoggingEvent?
>
> static final Integer[] PARAM_ARRAY = new Integer[1];
>
> ....
> in readLevel(ObjectInputStream){.
> ....
> PARAM_ARRAY[0] = new Integer(p);
> level = (Level)m.invoke(null, (Object[]) PARAM_ARRAY);
>
> Is there some synchronization done here? If not, wouldn't the
> PARAM_ARRAY be shared? If this was the case and one had multiple
> Receivers reading data from multiple sources, then there is a
> possibility of data corruption?
>
> Thoughts?
>
> Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org