riptide icon indicating copy to clipboard operation
riptide copied to clipboard

UnsupportedOperationException when using RestOperations + UriTemplate via RequestEntity

Open i8r opened this issue 4 years ago • 0 comments

I get a UnsupportedOperationException when I use the RestOperations#exchange for the RestOperations provided by riptide in combination with a uri template that created via the request entity builders.

Expected Behavior

RestOperations#exchangeshould honor the uri template.

Actual Behavior

java.lang.UnsupportedOperationException: null
	at org.springframework.http.RequestEntity.getUrl(RequestEntity.java:165) ~[spring-web-5.3.4.jar:5.3.4]
	at org.zalando.riptide.compatibility.HttpOperations.exchange(HttpOperations.java:304) ~[riptide-compatibility-3.0.0-RC.16.jar:na]
	at org.zalando.riptide.compatibility.HttpOperations.exchange(HttpOperations.java:294) ~[riptide-compatibility-3.0.0-RC.16.jar:na]

Possible Fix

Check for subtype UriTemplateRequestEntity before calling RequestEntity#getUrl()?

Steps to Reproduce

@Autowired
private RestOperations rest;

// …

        RequestEntity<EventTypeSpec> requestEntity = RequestEntity.put("/event-types/{}", eventTypeSpec.getName()).body(eventTypeSpec);
        rest.exchange(requestEntity, Map.class);

Your Environment

  • spring-web: 5.3.4
  • riptide: 3.0.0-RC.16

i8r avatar Mar 15 '21 10:03 i8r