Skip to content

Commit 26f136d

Browse files
dependency: Update dependency org.hibernate.validator:hibernate-validator to v9.1.0.Final (#622)
* dependency: Update dependency org.hibernate.validator:hibernate-validator to v9.1.0.Final * fix(core): Java 8 compilation error in TemporalAmountParser * fix(jakarta): replace Hibernate internal API with standard Jakarta Validation API --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Rollczi <ndejlich5@gmail.com>
1 parent 1845a6f commit 26f136d

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object Versions {
5353
const val ADVENTURE_PLATFORM_API = "4.4.1"
5454

5555
// Jakarta
56-
const val HIBERNATE_VALIDATOR = "9.0.1.Final"
56+
const val HIBERNATE_VALIDATOR = "9.1.0.Final"
5757
const val EXPRESSLY = "6.0.0"
5858

5959
// LuckPerms

litecommands-core/src/dev/rollczi/litecommands/time/TemporalAmountParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected TemporalAmountParser(ChronoUnit defaultZero, LocalDateTimeProvider bas
7878
.filter(entry -> entry.getValue() == defaultZero)
7979
.map(entry -> entry.getKey())
8080
.findFirst()
81-
.orElseThrow(() -> new IllegalStateException("Can not find default zero symbol for " + defaultZero))
81+
.orElseGet(() -> { throw new IllegalStateException("Can not find default zero symbol for " + defaultZero); })
8282
);
8383
}
8484

litecommands-jakarta/src/dev/rollczi/litecommands/jakarta/JakartaMethodValidator.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import jakarta.validation.ElementKind;
88
import jakarta.validation.Validator;
99
import jakarta.validation.executable.ExecutableValidator;
10-
import org.hibernate.validator.internal.engine.path.NodeImpl;
11-
import org.hibernate.validator.internal.engine.path.PathImpl;
10+
import jakarta.validation.Path;
1211

12+
import java.util.Iterator;
1313
import java.util.List;
1414
import java.util.Set;
1515
import java.util.stream.Collectors;
@@ -33,18 +33,20 @@ public ValidatorResult validate(MethodValidatorContext<SENDER> context) {
3333

3434
List<JakartaRawResult.Entry> violationsList = violations.stream()
3535
.map(objectConstraintViolation -> {
36-
if (!(objectConstraintViolation.getPropertyPath() instanceof PathImpl)) {
37-
throw new IllegalStateException("Invalid property path type: " + objectConstraintViolation.getPropertyPath().getClass());
38-
}
36+
Path propertyPath = objectConstraintViolation.getPropertyPath();
37+
Path.Node leafNode = null;
3938

40-
PathImpl path = (PathImpl) objectConstraintViolation.getPropertyPath();
41-
NodeImpl leafNode = path.getLeafNode();
39+
for (Path.Node node : propertyPath) {
40+
leafNode = node;
41+
}
4242

43-
if (leafNode.getKind() != ElementKind.PARAMETER) {
44-
throw new IllegalStateException("Invalid leaf node kind: " + leafNode.getKind());
43+
if (leafNode == null || leafNode.getKind() != ElementKind.PARAMETER) {
44+
throw new IllegalStateException("Invalid leaf node: " + (leafNode == null ? "null" : leafNode.getKind()));
4545
}
4646

47-
return new JakartaRawResult.Entry(objectConstraintViolation, context.getDefinition().getRequirement(leafNode.getParameterIndex()));
47+
Path.ParameterNode parameterNode = leafNode.as(Path.ParameterNode.class);
48+
49+
return new JakartaRawResult.Entry(objectConstraintViolation, context.getDefinition().getRequirement(parameterNode.getParameterIndex()));
4850
}).collect(Collectors.toList());
4951

5052
return ValidatorResult.invalid(new JakartaRawResult(violationsList));

0 commit comments

Comments
 (0)