At 09:56 27.03.2002 +1100, Geoff Soutter wrote: >Hi Ceki, > > > For reasons you can understand I am not particularly fond of > > parsing lines. The existing code of VectorWriter would not > > win a beauty contest, I'll admit that. > >It's not a question of "beauty". There are two logic issues here: > >1) If VectorWriter doesn't form a complete PrintWriter, it is clearly >broken. There are other applications apart from Orion out there that >implement printStackTrace, and they may legally use _any_ method of >PrintWriter. We are in danger of standing by while the house burns down >if we ignore this fact. ;-) Hmmm. If you documented that log4j does not >support applications which override printStackTrace(), this may be OK. >But, are you willing to do this?
Interesting and thought provoking argument. Since it is based on logic, I would have preferred it slightly dryer, less figurative. Never mind, it's just a stylistic side note. VectorWriter is broken not because it does not implement a complete PrintWriter. This is actually apparent from your next example. Read on. >2) If VectorWriter simply adds anything passed to a print(*) method to >the Vector, it is clearly broken. For example, Orion passes multiple >lines delimited by /r/n into print(String). If you add that to the >vector as a single entry, it will break the (implied, since there is no >Javadoc) contract of ThrowableInformation.getThrowableStrRep() which >says that each String in the Array contains a single line of stack >trace. And, this will then cause formatting problems for any Appenders >which rely on this when they are trying to format the stack trace. As your example so clearly demonstrates, VectorWriter is broken because there is no formal specification on the format of stack traces as generated by Exceptions, at least not until JDK 1.4. Since there is no such spec, there cannot be a specification on how the Exception.ptintStackTrace method should be implemented. So although there is no good reason for Orion to generate two lines per print(String) call, it could certainly do that. That has nothing to do with VectorWriter not being a complete PrintWriter but it has everything to do with the imprecise definition (or lack thereof) of how the VectorWriter will be invoked by the Exception. Agree so far? > > Can you please let me > > know if my recent commit solves the problem? > >Doesn't seem like theres much point testing the current solution given >the above. > >Also, I'd like to point out that I don't need an immediate fix - I'd >prefer you take your time and do it properly. The "slow but steady" >solution I provided in my email is working fine for what I need. And, as >I am sure you are aware, JDK1.4 provides access to structured stace >trace information via java.lang.StackTraceElement. So, at some stage >you'll probably need to refactor the way that ThrowableInformation works >to be compatible with 1.4. Why not just save this problem up and and fix >it properly at the same time as you refactor for 1.4? Log4j still supports JDK 1.1. There is no intention to jump to or require 1.4 in the near future. As for the slow but steady solution, it seems to circumvent the problem of the Exception.ptintStackTrace implementation (i.e. it's interaction with VectorWriter ). Are we sure it will work on Mac OS? On ThisOrThat OS? We could modify the StringTokenizer tok = new StringTokenizer(trace, "\r\n"); to StringTokenizer tok = new StringTokenizer(trace, System.getProperty("line.separator")); That should do it, right? Maybe not. We have *no* assurance that a given platform will output the stack trace separated by line separators such as \r, \n or \r\n. The platform could output <br/> tags between elements of the stack. It won't but it could. I'll spare you the description about the burning house. Thanks to you, we have identified a problem with log4j interacting with Orion. We have a fix. Can you please verify that it works? I would greatly appreciate that. Ceki ps: In the above discussion, I conveniently substituted Exception for Throwable which I find a pain to write. -- Ceki My link of the month: http://java.sun.com/aboutJava/standardization/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>