From bb798af9075071ad2821da341aea3b031f628f73 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 7 Sep 2020 17:28:20 +0100 Subject: [PATCH] UriComponentsBuilder Javadoc update Closes gh-25604 --- .../web/util/UriComponentsBuilder.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index fa57ad2f794c..8384be15cf3b 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -182,7 +182,13 @@ public static UriComponentsBuilder fromPath(String path) { } /** - * Create a builder that is initialized with the given {@code URI}. + * Create a builder that is initialized from the given {@code URI}. + *

Note: the components in the resulting builder will be + * in fully encoded (raw) form and further changes must also supply values + * that are fully encoded, for example via methods in {@link UriUtils}. + * In addition please use {@link #build(boolean)} with a value of "true" to + * build the {@link UriComponents} instance in order to indicate that the + * components are encoded. * @param uri the URI to initialize with * @return the new {@code UriComponentsBuilder} */ @@ -379,11 +385,13 @@ public UriComponents build() { } /** - * Build a {@code UriComponents} instance from the various components - * contained in this builder. - * @param encoded whether all the components set in this builder are - * encoded ({@code true}) or not ({@code false}) + * Variant of {@link #build()} to create a {@link UriComponents} instance + * when components are already fully encoded. This is useful for example if + * the builder was created via {@link UriComponentsBuilder#fromUri(URI)}. + * @param encoded whether the components in this builder are already encoded * @return the URI components + * @throws IllegalArgumentException if any of the components contain illegal + * characters that should have been encoded. */ public UriComponents build(boolean encoded) { return buildInternal(encoded ?