logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r418432 - in /logging/log4j/trunk/src/java/org/apache/log4j: HTMLLayout.java SimpleLayout.java config/PropertySetter.java pattern/DatePatternConverter.java
Date Sat, 01 Jul 2006 03:48:10 GMT
Author: carnold
Date: Fri Jun 30 20:48:09 2006
New Revision: 418432

URL: http://svn.apache.org/viewvc?rev=418432&view=rev
Log:
Bug 24159: Concurrency issues

Modified:
    logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java
    logging/log4j/trunk/src/java/org/apache/log4j/SimpleLayout.java
    logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java
    logging/log4j/trunk/src/java/org/apache/log4j/pattern/DatePatternConverter.java

Modified: logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java?rev=418432&r1=418431&r2=418432&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java Fri Jun 30 20:48:09 2006
@@ -103,7 +103,7 @@
   
   
   // counter keeping track of the rows output
-  private long counter = 0;
+  private boolean odd = true;
   
   /**
    * Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.
@@ -367,11 +367,9 @@
   /**
    * {@inheritDoc}
    */
-  public String format(LoggingEvent event) {
-    
-    boolean odd = true;
-    if(((counter++) & 1) == 0) {
-      odd = false;
+  public String format(final LoggingEvent event) {
+    synchronized(this) {
+       odd = !odd;
     }
     
     String level = event.getLevel().toString().toLowerCase();

Modified: logging/log4j/trunk/src/java/org/apache/log4j/SimpleLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/SimpleLayout.java?rev=418432&r1=418431&r2=418432&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/SimpleLayout.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/SimpleLayout.java Fri Jun 30 20:48:09 2006
@@ -32,10 +32,16 @@
    <p>
    @author Ceki G&uuml;lc&uuml;
    @since version 0.7.0
+   @deprecated since 1.3
 
    <p>{@link PatternLayout} offers a much more powerful alternative.
 */
 public class SimpleLayout extends Layout {
+  /**
+   *   Result of previous format request.  Not reliable if not
+   *       layout is not externally synchronized.
+   *   @deprecated since 1.3
+   */
   StringBuffer sbuf = new StringBuffer(128);
 
   public SimpleLayout() {
@@ -55,10 +61,13 @@
 	 @param event The LoggingEvent to format and write
 	*/
   public String format(final LoggingEvent event) {
-    StringBuffer sbuf = new StringBuffer(event.getLevel().toString());
-    sbuf.append(" - ");
-    sbuf.append(event.getRenderedMessage());
-    sbuf.append(LINE_SEP);
-    return sbuf.toString();
+    StringBuffer sb = new StringBuffer(event.getLevel().toString());
+    sb.append(" - ");
+    sb.append(event.getRenderedMessage());
+    sb.append(LINE_SEP);
+    String s = sb.toString();
+    sbuf.setLength(0);
+    sbuf.append(s);
+    return s;
    }
 }

Modified: logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java?rev=418432&r1=418431&r2=418432&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java Fri Jun 30 20:48:09
2006
@@ -60,7 +60,6 @@
   public static final int NOT_FOUND = 0;
   public static final int AS_PROPERTY = 1;
   public static final int AS_COLLECTION = 2;
-  Logger logger;
   protected Object obj;
   protected Class objClass;
   protected PropertyDescriptor[] props;

Modified: logging/log4j/trunk/src/java/org/apache/log4j/pattern/DatePatternConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/pattern/DatePatternConverter.java?rev=418432&r1=418431&r2=418432&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/pattern/DatePatternConverter.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/pattern/DatePatternConverter.java Fri Jun
30 20:48:09 2006
@@ -111,7 +111,9 @@
    * {@inheritDoc}
    */
   public void format(final LoggingEvent event, final StringBuffer output) {
-    df.format(event.getTimeStamp(), output);
+    synchronized(this) {
+    	df.format(event.getTimeStamp(), output);
+    }
   }
 
   /**
@@ -131,6 +133,8 @@
    * @param toAppendTo buffer to which formatted date is appended.
    */
   public void format(final Date date, final StringBuffer toAppendTo) {
-    df.format(date.getTime(), toAppendTo);
+    synchronized(this) {
+    	df.format(date.getTime(), toAppendTo);
+    }
   }
 }



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


Mime
View raw message