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 ca...@apache.org on 2010/02/15 02:45:20 UTC

svn commit: r910151 - in /logging/log4j/trunk: src/changes/ src/main/java/org/apache/log4j/ src/main/java/org/apache/log4j/helpers/ tests/src/java/org/apache/log4j/ tests/witness/

Author: carnold
Date: Mon Feb 15 01:45:20 2010
New Revision: 910151

URL: http://svn.apache.org/viewvc?rev=910151&view=rev
Log:
Bug 48704: Reverting commits 909868,909918 to defer issue post 1.2.16

Modified:
    logging/log4j/trunk/src/changes/changes.xml
    logging/log4j/trunk/src/main/java/org/apache/log4j/FileAppender.java
    logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java
    logging/log4j/trunk/tests/src/java/org/apache/log4j/FileAppenderTest.java
    logging/log4j/trunk/tests/src/java/org/apache/log4j/MinimumTestCase.java
    logging/log4j/trunk/tests/witness/prudent

Modified: logging/log4j/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Mon Feb 15 01:45:20 2010
@@ -94,7 +94,6 @@
        <action action="add" issue="48187">Typo ("two three goals") in log4j FAQ</action>
        <action action="fix" issue="48531">Unit tests fail for system dates after 2009-12-31</action>
        <action action="fix" issue="48604">Download page does not have link to KEYS file</action>
-       <action action="add" issue="48704">Add purient mode to FileAppender.</action>
     </release>
 
   

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/FileAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/FileAppender.java?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/FileAppender.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/FileAppender.java Mon Feb 15 01:45:20 2010
@@ -65,12 +65,6 @@
    * Determines the size of IO buffer be. Default is 8K. 
    */
   protected int bufferSize = 8*1024;
-  
-  /**
-   * Determines whether "prudent" mode used.
-   * @since 1.2.16
-   */
-  private boolean prudent = false;
 
 
   /**
@@ -265,44 +259,6 @@
   void setBufferSize(int bufferSize) {
     this.bufferSize = bufferSize;
   }
-  
-  /**
-   * Determines if the FileAppender should attempt to use
-   * java.nio.FileChannel.lock to gain exclusive access
-   * to the file during write operations.  The effectiveness
-   * and performance impact is JVM and operating system dependent.
-   * Avoiding concurrent writes to the same file by appenders
-   * and streams either within or outside a single JVM 
-   * is recommended.
-   * 
-   * Prudent mode requires JDK 1.4 or later.
-   * 
-   * @return true if prudent mode is enabled.
-   * @since 1.2.16
-   */
-  public final boolean isPrudent() {
-	  return prudent;
-  }
-  
-  /**
-   * Sets if the FileAppender should attempt to use
-   * java.nio.FileChannel.lock to gain exclusive access
-   * to the file during write operations.  The effectiveness
-   * and performance impact is JVM and operating system dependent.
-   * Avoiding concurrent writes to the same file by appenders
-   * and streams either within or outside a single JVM 
-   * is recommended.
-   * 
-   * Prudent mode requires JDK 1.4 or later.
-   * 
-   * @param value true to enable prudent mode on next call to
-   * activateOptions or setFile.
-   *
-   * @since 1.2.16
-   */
-  public void setPrudent(final boolean value) {
-	  prudent = value;
-  }
 
   /**
     <p>Sets and <i>opens</i> the file where the log output will
@@ -355,9 +311,7 @@
           }
     }
     Writer fw = createWriter(ostream);
-    if (prudent) {
-      fw = new org.apache.log4j.helpers.PrudentWriter(fw, ostream);
-    } else if(bufferedIO) {
+    if(bufferedIO) {
       fw = new BufferedWriter(fw, bufferSize);
     }
     this.setQWForFiles(fw);

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java Mon Feb 15 01:45:20 2010
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.io.FileOutputStream;
-import java.io.FilterWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-
-/**
- * An implementation of the "prudent" mode where file locking and
- * repositioning are used to minimize the consequences of 
- * concurrent writes to a log file multiple appenders or
- * programs.  The effectiveness is operating system and
- * Java platform dependent.  Avoiding concurrent writing
- * of log files is recommended.
- * 
- * @since 1.2.16
- */
-public final class PrudentWriter extends FilterWriter {
-	/**
-	 * File channel associated with encapsulated writer.
-	 */
-	private final FileChannel channel;
-
-	/**
-	 * Constructs a new instance.
-	 * @param out writer to encapsulate, may not be null.
-	 * @param ostream file stream corresponding to writer, may not be null.
-	 */
-	public PrudentWriter(final Writer out, final FileOutputStream ostream) {
-		super(out);
-		channel = ostream.getChannel();
-	}
-	
-	/**
-	 * Write string to encapsulated writer within a lock
-	 * on the associated FileChannel.  Channel will be 
-	 * repositioned to the end of the file if necessary. 
-	 */
-	public void write(final String str) throws IOException {
-		FileLock lock = null;
-		try {
-			lock = channel.lock();
-			long size = channel.size();
-			if (size != channel.position()) {
-				channel.position(size);
-			}
-			super.write(str);
-			super.flush();
-		} finally {
-			if (lock != null) {
-				lock.release();
-			}
-		}
-	}
-	
-}

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/FileAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/FileAppenderTest.java?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/FileAppenderTest.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/FileAppenderTest.java Mon Feb 15 01:45:20 2010
@@ -84,17 +84,4 @@
     Priority debug = Level.DEBUG;
     assertTrue(appender.isAsSevereAsThreshold(debug));
   }
-  
-  /**
-   * Tests prudent mutator and accessor.
-   * See bug 48704.
-   */
-  public void testIsPrudent() {
-	  FileAppender appender = new FileAppender();
-	  assertFalse(appender.isPrudent());
-	  appender.setPrudent(true);
-	  assertTrue(appender.isPrudent());
-	  appender.setPrudent(false);
-	  assertFalse(appender.isPrudent());
-  }
 }

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/MinimumTestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/MinimumTestCase.java?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/MinimumTestCase.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/MinimumTestCase.java Mon Feb 15 01:45:20 2010
@@ -79,32 +79,6 @@
     assertTrue(Compare.compare(FILTERED, "witness/simple"));
   }
 
-  public void prudent() throws Exception {
-	    try {
-	    	java.io.FileOutputStream.class.getMethod("getChannel", (Class[]) null);
-	    } catch(NoSuchMethodException ex) {
-	    	//  earlier than JDK 1.4
-	    	return;
-	    }
-	    Layout layout = new SimpleLayout();
-	    FileAppender appender = new FileAppender();
-	    
-	    appender.setPrudent(true);
-	    appender.setFile("output/prudent");
-	    appender.setLayout(layout);
-	    appender.activateOptions();
-	    root.addAppender(appender);    
-	    common();
-
-	    Transformer.transform(
-	      "output/prudent", FILTERED,
-	      new Filter[] { new LineNumberFilter(), 
-	                     new SunReflectFilter(), 
-	                     new JunitTestRunnerFilter() });
-	    assertTrue(Compare.compare(FILTERED, "witness/prudent"));
-	  }
-  
-  
   public void ttcc() throws Exception {
     
     Layout layout = new TTCCLayout(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT);
@@ -226,7 +200,6 @@
     TestSuite suite = new TestSuite();
     suite.addTest(new MinimumTestCase("simple"));
     suite.addTest(new MinimumTestCase("ttcc"));
-    suite.addTest(new MinimumTestCase("prudent"));
     return suite;
   }
 

Modified: logging/log4j/trunk/tests/witness/prudent
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/witness/prudent?rev=910151&r1=910150&r2=910151&view=diff
==============================================================================
--- logging/log4j/trunk/tests/witness/prudent (original)
+++ logging/log4j/trunk/tests/witness/prudent Mon Feb 15 01:45:20 2010
@@ -1,42 +0,0 @@
-FATAL - Message 0
-ERROR - Message 1
-FATAL - Message 2
-ERROR - Message 3
-WARN - Message 4
-INFO - Message 5
-FATAL - Message 6
-ERROR - Message 7
-WARN - Message 8
-INFO - Message 9
-FATAL - Message 10
-ERROR - Message 11
-FATAL - Message 12
-ERROR - Message 13
-FATAL - Message 14
-ERROR - Message 15
-WARN - Message 16
-INFO - Message 17
-DEBUG - Message 18
-FATAL - Message 19
-ERROR - Message 20
-WARN - Message 21
-INFO - Message 22
-DEBUG - Message 23
-TRACE - Message 24
-FATAL - Message 25
-ERROR - Message 26
-WARN - Message 27
-INFO - Message 28
-DEBUG - Message 29
-java.lang.Exception: Just testing.
-	at org.apache.log4j.MinimumTestCase.common(MinimumTestCase.java:XXX)
-	at org.apache.log4j.MinimumTestCase.prudent(MinimumTestCase.java:XXX)
-	at junit.framework.TestCase.runTest(TestCase.java:XXX)
-	at junit.framework.TestCase.runBare(TestCase.java:XXX)
-	at junit.framework.TestResult$1.protect(TestResult.java:XXX)
-	at junit.framework.TestResult.runProtected(TestResult.java:XXX)
-	at junit.framework.TestResult.run(TestResult.java:XXX)
-	at junit.framework.TestCase.run(TestCase.java:XXX)
-	at junit.framework.TestSuite.runTest(TestSuite.java:XXX)
-	at junit.framework.TestSuite.run(TestSuite.java:XXX)
-INFO - Messages should bear numbers 0 through 29.



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