You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2017/07/12 07:53:08 UTC
svn commit: r1801686 - in /tomcat/trunk: build.xml
java/org/apache/juli/FileHandler.java
test/org/apache/juli/TestFileHandlerNonRotatable.java
test/org/apache/juli/logging-non-rotatable.properties
webapps/docs/changelog.xml
Author: violetagg
Date: Wed Jul 12 07:53:07 2017
New Revision: 1801686
URL: http://svn.apache.org/viewvc?rev=1801686&view=rev
Log:
When log rotation is disabled only one separator will be used when generating the log file name.
Patch provided by Katya Todorova via GitHub.
This closes #69
Added:
tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java (with props)
tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties (with props)
Modified:
tomcat/trunk/build.xml
tomcat/trunk/java/org/apache/juli/FileHandler.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/build.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1801686&r1=1801685&r2=1801686&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Wed Jul 12 07:53:07 2017
@@ -1328,6 +1328,7 @@
<fileset dir="test">
<include name="META-INF/**"/>
<include name="**/service-config.txt"/>
+ <include name="**/logging-non-rotatable.properties"/>
</fileset>
</copy>
</target>
Modified: tomcat/trunk/java/org/apache/juli/FileHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/FileHandler.java?rev=1801686&r1=1801685&r2=1801686&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/juli/FileHandler.java (original)
+++ tomcat/trunk/java/org/apache/juli/FileHandler.java Wed Jul 12 07:53:07 2017
@@ -380,6 +380,17 @@ public class FileHandler extends Handler
if (suffix == null) {
suffix = getProperty(className + ".suffix", ".log");
}
+
+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=61232
+ boolean shouldCheckForRedundantSeparator = !rotatable && !prefix.isEmpty()
+ && !suffix.isEmpty();
+ // assuming separator is just one char, if there are use cases with
+ // more, the notion of separator might be introduced
+ if (shouldCheckForRedundantSeparator
+ && (prefix.charAt(prefix.length() - 1) == suffix.charAt(0))) {
+ suffix = suffix.substring(1);
+ }
+
pattern = Pattern.compile("^(" + Pattern.quote(prefix) + ")\\d{4}-\\d{1,2}-\\d{1,2}("
+ Pattern.quote(suffix) + ")$");
String sMaxDays = getProperty(className + ".maxDays", String.valueOf(DEFAULT_MAX_DAYS));
Added: tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java?rev=1801686&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java (added)
+++ tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java Wed Jul 12 07:53:07 2017
@@ -0,0 +1,77 @@
+/*
+ * 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.juli;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URLDecoder;
+
+import org.apache.catalina.startup.LoggingBaseTest;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestFileHandlerNonRotatable extends LoggingBaseTest {
+ private FileHandler testHandler;
+
+ @BeforeClass
+ public static void setUpPerTestClass() throws Exception {
+ System.setProperty("java.util.logging.manager",
+ "org.apache.juli.ClassLoaderLogManager");
+ String configLoggingPath = TestFileHandlerNonRotatable.class
+ .getResource("logging-non-rotatable.properties")
+ .getFile();
+ System.setProperty("java.util.logging.config.file",
+ URLDecoder.decode(configLoggingPath, java.nio.charset.StandardCharsets.UTF_8.toString()));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (testHandler != null) {
+ testHandler.close();
+ }
+ super.tearDown();
+ }
+
+ @Test
+ public void testBug61232() throws Exception {
+ testHandler = new FileHandler(this.getTemporaryDirectory().toString(),
+ "juli.", ".log");
+
+ File logFile = new File(this.getTemporaryDirectory(), "juli.log");
+ assertTrue(logFile.exists());
+ }
+
+ @Test
+ public void testCustomSuffixWithoutSeparator() throws Exception {
+ testHandler = new FileHandler(this.getTemporaryDirectory().toString(),
+ "juli.", "log");
+
+ File logFile = new File(this.getTemporaryDirectory(), "juli.log");
+ assertTrue(logFile.exists());
+ }
+
+ @Test
+ public void testCustomPrefixWithoutSeparator() throws Exception {
+ testHandler = new FileHandler(this.getTemporaryDirectory().toString(),
+ "juli", ".log");
+
+ File logFile = new File(this.getTemporaryDirectory(), "juli.log");
+ assertTrue(logFile.exists());
+ }
+}
\ No newline at end of file
Propchange: tomcat/trunk/test/org/apache/juli/TestFileHandlerNonRotatable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties?rev=1801686&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties (added)
+++ tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties Wed Jul 12 07:53:07 2017
@@ -0,0 +1 @@
+org.apache.juli.FileHandler.rotatable = false
\ No newline at end of file
Propchange: tomcat/trunk/test/org/apache/juli/logging-non-rotatable.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1801686&r1=1801685&r2=1801686&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jul 12 07:53:07 2017
@@ -56,6 +56,14 @@
(markt)
</add>
<fix>
+ <bug>61232</bug>: When log rotation is disabled only one separator will
+ be used when generating the log file name. For example if the prefix is
+ <code>catalina.</code> and the suffix is <code>.log</code> then the log
+ file name will be <code>catalina.log</code> instead of
+ <code>catalina..log</code>. Patch provided by Katya Todorova.
+ (violetagg)
+ </fix>
+ <fix>
<bug>61264</bug>: Correct a regression in the refactoring to use
<code>Charset</code> rather than <code>String</code> to store request
character encoding that prevented <code>getReader()</code> throwing an
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org