Skip to content

Commit bd0deec

Browse files
Add comment to XContentBuilder.toString() (#13809) (#13932)
* Add comment to XContentBuilder.toString * Fix typo --------- (cherry picked from commit bf43678) Signed-off-by: Liyun Xiu <xiliyun@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a6c86e7 commit bd0deec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libs/core/src/main/java/org/opensearch/core/xcontent/XContentBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public static XContentBuilder builder(XContent xContent, Set<String> includes, S
157157

158158
/**
159159
* Returns a string representation of the builder (only applicable for text based xcontent).
160+
* Note: explicitly or implicitly (from debugger) calling toString() could cause XContentBuilder
161+
* to close which is a side effect done by @see BytesReference#bytes().
162+
* Trying to write more contents after toString() will cause NPE. Use it with caution.
160163
*/
161164
@Override
162165
public String toString() {

0 commit comments

Comments
 (0)