Skip to content

8360575: java.util.Properties.list() methods trim each value to 37 characters in the listed output #26018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/java.base/share/classes/java/util/Properties.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1211,10 +1211,22 @@ public Set<String> stringPropertyNames() {
}

/**
* Prints this property list out to the specified output stream.
* Prints this property list out to the specified {@link PrintStream}.
* This method is useful for debugging.
*
* @param out an output stream.
* @implNote The implementation of this method truncates the output for very long
* property values.
* <p>
* An alternative for listing the {@code Properties} to a {@code PrintStream}
* without truncation is:
* {@snippet lang=java :
* Properties p = ...
* PrintStream out = ...
* // list the properties to PrintStream
* p.forEach((k, v) -> out.println(k + "=" + v));
* }
*
* @param out the output PrintStream
* @throws ClassCastException if any key in this property list
* is not a string.
*/
Expand All @@ -1233,10 +1245,22 @@ public void list(PrintStream out) {
}

/**
* Prints this property list out to the specified output stream.
* Prints this property list out to the specified {@link PrintWriter}.
* This method is useful for debugging.
*
* @param out an output stream.
* @implNote The implementation of this method truncates the output for very long
* property values.
* <p>
* An alternative for listing the {@code Properties} to a {@code PrintWriter}
* without truncation is:
* {@snippet lang=java :
* Properties p = ...
* PrintWriter out = ...
* // list the properties to PrintWriter
* p.forEach((k, v) -> out.println(k + "=" + v));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should our example recommend using toString as a utility to obtain a debug string instead, as it performs no truncation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using toString() will be harder to read; as proposed each property is on a separate line.

* }
*
* @param out the output PrintWriter
* @throws ClassCastException if any key in this property list
* is not a string.
* @since 1.1
Expand Down