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 bu...@apache.org on 2004/12/17 15:42:12 UTC

DO NOT REPLY [Bug 32752] New: - MDC.put and MDC.get signatures changed between 1.2 and 1.3

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32752>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32752

           Summary: MDC.put and MDC.get signatures changed between 1.2 and
                    1.3
           Product: Log4j
           Version: 1.3alpha
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: ceki@apache.org


At 01:01 PM 12/17/2004, Hein Meling wrote:

I've noticed that MDC.put(String, Object) has been deprecated and is
being replaced by MDC.put(String, String) instead.  At first, I didn't
think of this as a problem other than calling the Object.toString()
method instead.

But, later I discovered that this is flawed, because the Object might
change its state (and hence toString() output might be different)
between debug calls.  Consider my example:

  Group g = new Group(1);
  g.setState(IDLE);
  MDC.put("group", g.toString());
  log.debug("Hi");
  g.setState(SYNC);
  log.debug("Ciao");

This sequence, will result in both debug statements printing the same
state (IDLE) even if in SYNC state, as opposed to using the now
deprecated method (actually the 1.3 version does not work; it does work
in 1.2.8 though):

  MDC.put("group", g);

which would print the correct state.

To overcome this problem, I would have to identify every location that
modify the state of the Group object, and update the MDC entry, causing
a lot of clutter.

So to my question: is this signature change in 1.3alpha3 really
warranted??  Is there a good reason for it?

Thanks,

Hein

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org