Reputation: 3881
I am using this Feign client
@FeignClient(name = "acme-service", url = "http://the-url", path = "/acme/", dismiss404 = true)
public interface AcmeServiceClient {
@GetMapping("/{article}")
Optional<AcmeDto> getArticle(@PathVariable final String article);
}
If the acme-service returns null
, the getArticle
method also returns null
.
Is it possible to use an Optional<AcmeDto>
as return type in this case?
Update with 13.5: no error, but null
is returned instead of an empty Optional
. (Previous: When I use it like this, I get an error that the result could not be converted into an Optional
.)
Can I configure OpenFeign to support Optionals as return types?
Upvotes: 3
Views: 409