Skip to content

UnsupportedOperationException when using RestOperations + UriTemplate via RequestEntity  #1062

@i8r

Description

@i8r

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions