-
Bug
-
Resolution: Unresolved
-
P4
-
7
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.7.0_03"
Java (TM) SE Runtime Environment (build 1.7.0_0s-b05)
Java HotSpot (TM) Client VM (build 22.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
N/A - documentation error
A DESCRIPTION OF THE PROBLEM :
The Javadoc for java.util.logging.SimpleFormatter has superfluous quotes in the examples of the java.util.logging.SimpleFormatter.format in the writeup for the format() method. Specifically, it gives the following examples at http://docs.oracle.com/javase/7/docs/api/java/util/logging/SimpleFormatter.html:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"
java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n"
In each case, the quotes do not belong there. If used, unwanted quotes appear in the log records being written. If the quotes are omitted, the actual output matches the predicted output.
In short, those quotes shouldn't be in the Javadoc for SimpleFormatter.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Add or revise the java.util.logging.SimpleFormatter.format property in a new or existing logging.properties file so that it includes a pattern that is surrounded by quotes, as per the examples in the Javadoc. For example, use:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
Execute a program that writes a log record which uses the aforementioned logging.properties file.
Look at the log records, either on the console or in a physical log file. Notice the unexpected and unnecessary quotes in the text of the log record.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using this:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
the expected result is:
INFO: Entering [Sat Mar 10 14:06:58 EST 2012]
ACTUAL -
The actual result is:
"INFO: Entering [Sat Mar 10 14:08:11 EST 2012]
"
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* URGENT: You MUST use a Java 1.7 JDK is used to compile this program */
package org.sscce.foo;
import java.util.logging.Level;
import java.util.logging.Logger;
public class TestSimpleFormatter {
public static void main(String[] args) {
TestSimpleFormatter testSimpleFormatter = new TestSimpleFormatter();
}
public TestSimpleFormatter() {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.INFO, "Entering");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Omit the quotes when writing the value of the java.util.logging.SimpleFormatter.format property.
java version "1.7.0_03"
Java (TM) SE Runtime Environment (build 1.7.0_0s-b05)
Java HotSpot (TM) Client VM (build 22.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
N/A - documentation error
A DESCRIPTION OF THE PROBLEM :
The Javadoc for java.util.logging.SimpleFormatter has superfluous quotes in the examples of the java.util.logging.SimpleFormatter.format in the writeup for the format() method. Specifically, it gives the following examples at http://docs.oracle.com/javase/7/docs/api/java/util/logging/SimpleFormatter.html:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"
java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n"
In each case, the quotes do not belong there. If used, unwanted quotes appear in the log records being written. If the quotes are omitted, the actual output matches the predicted output.
In short, those quotes shouldn't be in the Javadoc for SimpleFormatter.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Add or revise the java.util.logging.SimpleFormatter.format property in a new or existing logging.properties file so that it includes a pattern that is surrounded by quotes, as per the examples in the Javadoc. For example, use:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
Execute a program that writes a log record which uses the aforementioned logging.properties file.
Look at the log records, either on the console or in a physical log file. Notice the unexpected and unnecessary quotes in the text of the log record.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using this:
java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
the expected result is:
INFO: Entering [Sat Mar 10 14:06:58 EST 2012]
ACTUAL -
The actual result is:
"INFO: Entering [Sat Mar 10 14:08:11 EST 2012]
"
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* URGENT: You MUST use a Java 1.7 JDK is used to compile this program */
package org.sscce.foo;
import java.util.logging.Level;
import java.util.logging.Logger;
public class TestSimpleFormatter {
public static void main(String[] args) {
TestSimpleFormatter testSimpleFormatter = new TestSimpleFormatter();
}
public TestSimpleFormatter() {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.INFO, "Entering");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Omit the quotes when writing the value of the java.util.logging.SimpleFormatter.format property.