Skip to content

Commit 89cce56

Browse files
committed
Empty validation exception
pls note I had to remove final in order to facilitate overriding in the ifc and allowing me to not add anything to the list of msgs
1 parent 2582d02 commit 89cce56

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/Validatable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
* Defines a validation layer for Requests.
2323
*/
2424
public interface Validatable {
25+
ValidationException EMPTY_VALIDATION = new ValidationException() {
26+
@Override
27+
public void addValidationError(String error) { }
28+
};
2529

2630
/**
2731
* Perform validation. This method does not have to be overridden in the event that no validation needs to be done.
@@ -30,6 +34,6 @@ public interface Validatable {
3034
* {@link ValidationException} that contains a list of all failed validation.
3135
*/
3236
default ValidationException validate() {
33-
return new ValidationException();
37+
return EMPTY_VALIDATION;
3438
}
3539
}

client/rest-high-level/src/main/java/org/elasticsearch/client/ValidationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ValidationException extends IllegalArgumentException {
3131
* Add a new validation error to the accumulating validation errors
3232
* @param error the error to add
3333
*/
34-
public final void addValidationError(String error) {
34+
public void addValidationError(String error) {
3535
validationErrors.add(error);
3636
}
3737

0 commit comments

Comments
 (0)