java.util.Properties.list(PrintStream) and java.util.Properties.list(PrintWriter) methods state that these methods list the Properties' key/value pair to the PrintStream/PrintWriter.
The current implementation of these methods only writes out 37 characters of a value. If any value exceeds that length then an additional 3 dots are appended to the value that gets written out.
Consider the following trivial example:
import java.util.Properties;
public class Test {
public static void main(final String[] args) throws Exception {
System.out.println("running on java version " + System.getProperty("java.vm.version"));
final Properties p = new Properties();
p.put("somekey", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
// list the properties
p.list(System.out);
}
}
When this code is run, it prints:
running on java version 24+36-3646
-- listing properties --
somekey=abcdefghijklmnopqrstuvwxyzABCDEFGHIJK...
Notice how the value got trimmed to 37 characters followed by the 3 dots. This current implementation isn't specified by either of these methods.
This behaviour is especially surprising because these methods state:
> This method is useful for debugging.
The current implementation however is long standing since several decades, including Java 8. So changing this behaviour could lead to compatibility concerns in applications that might be relying or used to this current implementation. Instead, the documentation of these methods should be updated to clarify this current behaviour.
The current implementation of these methods only writes out 37 characters of a value. If any value exceeds that length then an additional 3 dots are appended to the value that gets written out.
Consider the following trivial example:
import java.util.Properties;
public class Test {
public static void main(final String[] args) throws Exception {
System.out.println("running on java version " + System.getProperty("java.vm.version"));
final Properties p = new Properties();
p.put("somekey", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
// list the properties
p.list(System.out);
}
}
When this code is run, it prints:
running on java version 24+36-3646
-- listing properties --
somekey=abcdefghijklmnopqrstuvwxyzABCDEFGHIJK...
Notice how the value got trimmed to 37 characters followed by the 3 dots. This current implementation isn't specified by either of these methods.
This behaviour is especially surprising because these methods state:
> This method is useful for debugging.
The current implementation however is long standing since several decades, including Java 8. So changing this behaviour could lead to compatibility concerns in applications that might be relying or used to this current implementation. Instead, the documentation of these methods should be updated to clarify this current behaviour.
- duplicates
-
JDK-4622226 (prop) spec: Improve javadoc for java.util.Property.list() to mention truncation
-
- Closed
-
- relates to
-
JDK-4622226 (prop) spec: Improve javadoc for java.util.Property.list() to mention truncation
-
- Closed
-
- links to
-
Review(master) openjdk/jdk/26018