jon         00/11/07 19:22:43

  Modified:    src/java/org/apache/velocity/runtime Runtime.java
  Log:
  fixed MT sync issue on the parse method
  
  fixed issue where an object was being passed in and it was an exception
  if it is an exception, then we will attempt to get a stack trace from it
  instead of just printing the toString() of the exception. this should
  give us more debugging information.
  
  Revision  Changes    Path
  1.37      +27 -10    
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
  
  Index: Runtime.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Runtime.java      2000/11/08 02:59:15     1.36
  +++ Runtime.java      2000/11/08 03:22:41     1.37
  @@ -145,7 +145,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Jeff Bowden</a>
  - * @version $Id: Runtime.java,v 1.36 2000/11/08 02:59:15 jon Exp $
  + * @version $Id: Runtime.java,v 1.37 2000/11/08 03:22:41 jon Exp $
    */
   public class Runtime
   {
  @@ -426,13 +426,15 @@
       public static SimpleNode parse(InputStream inputStream)
           throws ParseException
       {
  -        synchronized(parser)
  +        if (parser == null)
           {
  -            if (parser == null)
  -                parser = createNewParser();
  -
  -            return parser.parse(inputStream);            
  -        } 
  +            synchronized(Runtime.class)
  +            {
  +                if (parser == null)
  +                    parser = createNewParser();
  +            }
  +        }
  +        return parser.parse(inputStream);            
       }
       
       /**
  @@ -486,19 +488,34 @@
       /** Log a warning message */
       public static void warn(Object message)
       {
  -        log(WARN + message.toString());
  +        String out = null;
  +        if (message instanceof Throwable || message instanceof Exception)
  +            out = StringUtils.stackTrace((Throwable)message);
  +        else
  +            out = message.toString();    
  +        log(WARN + out);
       }
       
       /** Log an info message */
       public static void info(Object message)
       {
  -        log(INFO + message.toString());
  +        String out = null;
  +        if (message instanceof Throwable || message instanceof Exception)
  +            out = StringUtils.stackTrace((Throwable)message);
  +        else
  +            out = message.toString();    
  +        log(INFO + out);
       }
       
       /** Log an error message */
       public static void error(Object message)
       {
  -        log(ERROR + message.toString());
  +        String out = null;
  +        if (message instanceof Throwable || message instanceof Exception)
  +            out = StringUtils.stackTrace((Throwable)message);
  +        else
  +            out = message.toString();    
  +        log(ERROR + out);
       }
       
       /** Log a debug message */
  
  
  

Reply via email to