File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
spring-web/src/main/java/org/springframework/http Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 2828import org .springframework .lang .Nullable ;
2929import org .springframework .util .MultiValueMap ;
3030import org .springframework .util .ObjectUtils ;
31+ import org .springframework .web .util .UriTemplateHandler ;
3132
3233/**
3334 * Extension of {@link HttpEntity} that also exposes the HTTP method and the
@@ -158,11 +159,23 @@ public HttpMethod getMethod() {
158159 }
159160
160161 /**
161- * Return the URL of the request.
162+ * Return the {@link URI} for the target HTTP endpoint.
163+ * <p><strong>Note:</strong> This method raises
164+ * {@link UnsupportedOperationException} if the {@code RequestEntity} was
165+ * created with a URI template and variables rather than with a {@link URI}
166+ * instance. This is because a URI cannot be created without further input
167+ * on how to expand template and encode the URI. In such cases, the
168+ * {@code URI} is prepared by the
169+ * {@link org.springframework.web.client.RestTemplate} with the help of the
170+ * {@link UriTemplateHandler} it is configured with.
162171 */
163172 public URI getUrl () {
164173 if (this .url == null ) {
165- throw new UnsupportedOperationException ();
174+ throw new UnsupportedOperationException (
175+ "The RequestEntity was created with a URI template and variables, " +
176+ "and there is not enough information on how to correctly expand and " +
177+ "encode the URI template. This will be done by the RestTemplate instead " +
178+ "with help from the UriTemplateHandler it is configured with." );
166179 }
167180 return this .url ;
168181 }
You can’t perform that action at this time.
0 commit comments