Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'ee.bitweb'
version = '5.0.0'
version = '5.1.0'
java {
sourceCompatibility = '17'
}
Expand All @@ -27,31 +27,31 @@ dependencies {
compileOnly 'org.apache.tomcat:tomcat-catalina:11.0.21'

// https://mvnrepository.com/artifact/org.springframework/spring-webmvc
compileOnly 'org.springframework:spring-webmvc:7.0.7'
compileOnly 'org.springframework:spring-webmvc:7.0.8'

// https://mvnrepository.com/artifact/org.springframework/spring-tx
compileOnly 'org.springframework:spring-tx:7.0.7'
compileOnly 'org.springframework:spring-tx:7.0.8'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security
compileOnly 'org.springframework.boot:spring-boot-starter-security:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-starter-security:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.amqp/spring-amqp
compileOnly 'org.springframework.boot:spring-boot-starter-amqp:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-starter-amqp:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:4.0.6'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator
compileOnly 'org.springframework.boot:spring-boot-starter-actuator:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-starter-actuator:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-health (new in Spring Boot 4)
compileOnly 'org.springframework.boot:spring-boot-health:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-health:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure
compileOnly 'org.springframework.boot:spring-boot-autoconfigure:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-autoconfigure:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-validation
compileOnly 'org.springframework.boot:spring-boot-starter-validation:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-starter-validation:4.1.0'

// Jackson 2.x - required for Retrofit converter-jackson (Retrofit doesn't support Jackson 3 yet)
compileOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.22.0'
Expand All @@ -60,7 +60,7 @@ dependencies {
compileOnly 'tools.jackson.core:jackson-databind:3.1.4'

// Spring Boot Jackson - provides JsonMapperBuilderCustomizer
compileOnly 'org.springframework.boot:spring-boot-jackson:4.0.6'
compileOnly 'org.springframework.boot:spring-boot-jackson:4.1.0'

// https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api
compileOnly 'jakarta.validation:jakarta.validation-api:3.1.1'
Expand All @@ -78,19 +78,19 @@ dependencies {
compileOnly 'de.siegmar:logback-gelf:6.1.2'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
testImplementation 'org.springframework.boot:spring-boot-starter-web:4.0.6'
testImplementation 'org.springframework.boot:spring-boot-starter-web:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test
testImplementation 'org.springframework.boot:spring-boot-starter-test:4.0.6'
testImplementation 'org.springframework.boot:spring-boot-starter-test:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-webmvc-test (new in Spring Boot 4 for MockMvc testing)
testImplementation 'org.springframework.boot:spring-boot-webmvc-test:4.0.6'
testImplementation 'org.springframework.boot:spring-boot-webmvc-test:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security
testImplementation 'org.springframework.boot:spring-boot-starter-security:4.0.6'
testImplementation 'org.springframework.boot:spring-boot-starter-security:4.1.0'

// https://mvnrepository.com/artifact/org.springframework.amqp/spring-amqp
testImplementation 'org.springframework.boot:spring-boot-starter-amqp:4.0.6'
testImplementation 'org.springframework.boot:spring-boot-starter-amqp:4.1.0'

// https://mvnrepository.com/artifact/org.json/json
testImplementation 'org.json:json:20260522'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.support.converter.JacksonJsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.amqp.autoconfigure.SimpleRabbitListenerContainerFactoryConfigurer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;

@Slf4j
@RequiredArgsConstructor
Expand Down
30 changes: 11 additions & 19 deletions src/main/java/ee/bitweb/core/api/FieldNameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import jakarta.validation.Path;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.hibernate.validator.internal.engine.ConstraintViolationImpl;
import org.hibernate.validator.internal.engine.path.NodeImpl;
import org.hibernate.validator.internal.engine.path.PathImpl;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class FieldNameResolver {
Expand All @@ -16,50 +13,45 @@ public class FieldNameResolver {
private static final String FIELD_NAME_DELIMITER = ".";

public static String resolve(ConstraintViolation<?> error) {
if (error instanceof ConstraintViolationImpl<?> violationImpl
&& violationImpl.getPropertyPath() instanceof PathImpl pathImpl) {
Path path = error.getPropertyPath();

return resolveFieldName(pathImpl);
if (path == null) {
return resolveWithRegex(error);
}

return resolveWithRegex(error);
return resolveFieldName(path);
}

private static String resolveFieldName(PathImpl path) {
private static String resolveFieldName(Path path) {
StringBuilder builder = new StringBuilder();
String parameterName = null;

for (Path.Node node : path) {
if (!(node instanceof NodeImpl nodeImpl)) {
continue;
}

switch (node.getKind()) {
case PARAMETER -> parameterName = nodeImpl.getName();
case PARAMETER -> parameterName = node.getName();
case METHOD -> {
// Skip methods
}
default -> appendNode(builder, nodeImpl);
default -> appendNode(builder, node);
}
}

return builder.isEmpty() && parameterName != null ? parameterName : builder.toString();
}

private static void appendNode(StringBuilder builder, NodeImpl nodeImpl) {
if (nodeImpl.isInIterable()) {
builder.append(INDEX_OPEN).append(nodeImpl.getIndex()).append(INDEX_CLOSE);
private static void appendNode(StringBuilder builder, Path.Node node) {
if (node.isInIterable()) {
builder.append(INDEX_OPEN).append(node.getIndex()).append(INDEX_CLOSE);
}
if (!builder.isEmpty()) {
builder.append(FIELD_NAME_DELIMITER);
}
builder.append(nodeImpl.getName());
builder.append(node.getName());
}

public static String resolveWithRegex(ConstraintViolation<?> error) {
String[] parts = error.getPropertyPath().toString().split("\\.");

return parts[parts.length - 1];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import ee.bitweb.core.trace.context.TraceIdContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.FatalExceptionStrategy;

@Slf4j
public class AmqpTraceAwareExceptionHandler extends ConditionalRejectingErrorHandler {
Expand Down
Loading