File tree 1 file changed +15
-2
lines changed
spring-web/src/main/java/org/springframework/http
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 28
28
import org .springframework .lang .Nullable ;
29
29
import org .springframework .util .MultiValueMap ;
30
30
import org .springframework .util .ObjectUtils ;
31
+ import org .springframework .web .util .UriTemplateHandler ;
31
32
32
33
/**
33
34
* Extension of {@link HttpEntity} that also exposes the HTTP method and the
@@ -158,11 +159,23 @@ public HttpMethod getMethod() {
158
159
}
159
160
160
161
/**
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.
162
171
*/
163
172
public URI getUrl () {
164
173
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." );
166
179
}
167
180
return this .url ;
168
181
}
You can’t perform that action at this time.
0 commit comments