Skip to content

Commit b1d8406

Browse files
committed
UriComponentsBuilder Javadoc update
Closes gh-25604
1 parent c19fc9d commit b1d8406

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ public static UriComponentsBuilder fromPath(String path) {
186186
}
187187

188188
/**
189-
* Create a builder that is initialized with the given {@code URI}.
189+
* Create a builder that is initialized from the given {@code URI}.
190+
* <p><strong>Note:</strong> the components in the resulting builder will be
191+
* in fully encoded (raw) form and further changes must also supply values
192+
* that are fully encoded, for example via methods in {@link UriUtils}.
193+
* In addition please use {@link #build(boolean)} with a value of "true" to
194+
* build the {@link UriComponents} instance in order to indicate that the
195+
* components are encoded.
190196
* @param uri the URI to initialize with
191197
* @return the new {@code UriComponentsBuilder}
192198
*/
@@ -387,11 +393,13 @@ public UriComponents build() {
387393
}
388394

389395
/**
390-
* Build a {@code UriComponents} instance from the various components
391-
* contained in this builder.
392-
* @param encoded whether all the components set in this builder are
393-
* encoded ({@code true}) or not ({@code false})
396+
* Variant of {@link #build()} to create a {@link UriComponents} instance
397+
* when components are already fully encoded. This is useful for example if
398+
* the builder was created via {@link UriComponentsBuilder#fromUri(URI)}.
399+
* @param encoded whether the components in this builder are already encoded
394400
* @return the URI components
401+
* @throws IllegalArgumentException if any of the components contain illegal
402+
* characters that should have been encoded.
395403
*/
396404
public UriComponents build(boolean encoded) {
397405
return buildInternal(encoded ?

0 commit comments

Comments
 (0)