Correctly detect Optional return type for @HttpExchange methods
Prior to this commit, a ClassCastException was thrown for an Optional return type for an @HttpExchange method. This is because the check for an Optional return type was based on the type contained in the Optional instead of the Optional itself. Closes gh-28493
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.web.service.invoker;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
@@ -131,6 +133,9 @@ public class HttpServiceMethodTests {
|
||||
String body = service.getBody();
|
||||
assertThat(body).isEqualTo("requestToBody");
|
||||
|
||||
Optional<String> optional = service.getBodyOptional();
|
||||
assertThat(optional).isEqualTo(Optional.of("requestToBody"));
|
||||
|
||||
ResponseEntity<String> entity = service.getEntity();
|
||||
assertThat(entity.getBody()).isEqualTo("requestToEntity");
|
||||
|
||||
@@ -252,6 +257,9 @@ public class HttpServiceMethodTests {
|
||||
@GetExchange
|
||||
String getBody();
|
||||
|
||||
@GetExchange
|
||||
Optional<String> getBodyOptional();
|
||||
|
||||
@GetExchange
|
||||
ResponseEntity<Void> getVoidEntity();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user