|
174 | 174 | import java.util.List;
|
175 | 175 | import java.util.Map;
|
176 | 176 | import java.util.Objects;
|
| 177 | +import java.util.Optional; |
177 | 178 | import java.util.ServiceLoader;
|
178 | 179 | import java.util.Set;
|
179 | 180 | import java.util.function.Function;
|
@@ -1334,9 +1335,9 @@ protected final <Req extends Validatable, Resp> Resp performRequest(Req request,
|
1334 | 1335 | RequestOptions options,
|
1335 | 1336 | CheckedFunction<Response, Resp, IOException> responseConverter,
|
1336 | 1337 | Set<Integer> ignores) throws IOException {
|
1337 |
| - ValidationException validationException = request.validate(); |
1338 |
| - if (validationException != null && validationException.validationErrors().isEmpty() == false) { |
1339 |
| - throw validationException; |
| 1338 | + Optional<ValidationException> validationException = request.validate(); |
| 1339 | + if (validationException != null && validationException.isPresent()) { |
| 1340 | + throw validationException.get(); |
1340 | 1341 | }
|
1341 | 1342 | return internalPerformRequest(request, requestConverter, options, responseConverter, ignores);
|
1342 | 1343 | }
|
@@ -1445,9 +1446,9 @@ protected final <Req extends Validatable, Resp> void performRequestAsync(Req req
|
1445 | 1446 | RequestOptions options,
|
1446 | 1447 | CheckedFunction<Response, Resp, IOException> responseConverter,
|
1447 | 1448 | ActionListener<Resp> listener, Set<Integer> ignores) {
|
1448 |
| - ValidationException validationException = request.validate(); |
1449 |
| - if (validationException != null && validationException.validationErrors().isEmpty() == false) { |
1450 |
| - listener.onFailure(validationException); |
| 1449 | + Optional<ValidationException> validationException = request.validate(); |
| 1450 | + if (validationException != null && validationException.isPresent()) { |
| 1451 | + listener.onFailure(validationException.get()); |
1451 | 1452 | return;
|
1452 | 1453 | }
|
1453 | 1454 | internalPerformRequestAsync(request, requestConverter, options, responseConverter, listener, ignores);
|
|
0 commit comments