Skip to content

Commit a6f8d9d

Browse files
committed
Fix AMQP autoconfig on Spring Boot 4.1 / Spring AMQP 4.1 (#112)
1 parent 3cf1b18 commit a6f8d9d

6 files changed

Lines changed: 32 additions & 40 deletions

File tree

‎build.gradle‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'ee.bitweb'
8-
version = '5.0.0'
8+
version = '5.1.0'
99
java {
1010
sourceCompatibility = '17'
1111
}
@@ -27,31 +27,31 @@ dependencies {
2727
compileOnly 'org.apache.tomcat:tomcat-catalina:11.0.21'
2828

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9595
// https://mvnrepository.com/artifact/org.json/json
9696
testImplementation 'org.json:json:20260522'

‎src/main/java/ee/bitweb/core/amqp/AmqpAutoConfiguration.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
99
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
1010
import org.springframework.amqp.rabbit.core.RabbitTemplate;
11-
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
11+
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
1212
import org.springframework.amqp.support.converter.JacksonJsonMessageConverter;
1313
import org.springframework.amqp.support.converter.MessageConverter;
1414
import org.springframework.boot.amqp.autoconfigure.SimpleRabbitListenerContainerFactoryConfigurer;

‎src/main/java/ee/bitweb/core/amqp/CoreExceptionStrategy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import lombok.RequiredArgsConstructor;
44
import lombok.extern.slf4j.Slf4j;
5-
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
5+
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
66

77
@Slf4j
88
@RequiredArgsConstructor

‎src/main/java/ee/bitweb/core/api/FieldNameResolver.java‎

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import jakarta.validation.Path;
55
import lombok.AccessLevel;
66
import lombok.NoArgsConstructor;
7-
import org.hibernate.validator.internal.engine.ConstraintViolationImpl;
8-
import org.hibernate.validator.internal.engine.path.NodeImpl;
9-
import org.hibernate.validator.internal.engine.path.PathImpl;
107

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

1815
public static String resolve(ConstraintViolation<?> error) {
19-
if (error instanceof ConstraintViolationImpl<?> violationImpl
20-
&& violationImpl.getPropertyPath() instanceof PathImpl pathImpl) {
16+
Path path = error.getPropertyPath();
2117

22-
return resolveFieldName(pathImpl);
18+
if (path == null) {
19+
return resolveWithRegex(error);
2320
}
2421

25-
return resolveWithRegex(error);
22+
return resolveFieldName(path);
2623
}
2724

28-
private static String resolveFieldName(PathImpl path) {
25+
private static String resolveFieldName(Path path) {
2926
StringBuilder builder = new StringBuilder();
3027
String parameterName = null;
3128

3229
for (Path.Node node : path) {
33-
if (!(node instanceof NodeImpl nodeImpl)) {
34-
continue;
35-
}
36-
3730
switch (node.getKind()) {
38-
case PARAMETER -> parameterName = nodeImpl.getName();
31+
case PARAMETER -> parameterName = node.getName();
3932
case METHOD -> {
4033
// Skip methods
4134
}
42-
default -> appendNode(builder, nodeImpl);
35+
default -> appendNode(builder, node);
4336
}
4437
}
4538

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

49-
private static void appendNode(StringBuilder builder, NodeImpl nodeImpl) {
50-
if (nodeImpl.isInIterable()) {
51-
builder.append(INDEX_OPEN).append(nodeImpl.getIndex()).append(INDEX_CLOSE);
42+
private static void appendNode(StringBuilder builder, Path.Node node) {
43+
if (node.isInIterable()) {
44+
builder.append(INDEX_OPEN).append(node.getIndex()).append(INDEX_CLOSE);
5245
}
5346
if (!builder.isEmpty()) {
5447
builder.append(FIELD_NAME_DELIMITER);
5548
}
56-
builder.append(nodeImpl.getName());
49+
builder.append(node.getName());
5750
}
5851

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

6255
return parts[parts.length - 1];
6356
}
64-
6557
}

‎src/main/java/ee/bitweb/core/trace/TraceIdAmqpAutoConfiguration.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import lombok.RequiredArgsConstructor;
88
import lombok.extern.slf4j.Slf4j;
99
import org.springframework.amqp.core.MessagePostProcessor;
10-
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
10+
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
1111
import org.springframework.beans.factory.annotation.Qualifier;
1212
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
1313
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;

‎src/main/java/ee/bitweb/core/trace/invoker/amqp/AmqpTraceAwareExceptionHandler.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import ee.bitweb.core.trace.context.TraceIdContext;
44
import lombok.extern.slf4j.Slf4j;
5-
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
6-
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
5+
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
6+
import org.springframework.amqp.listener.FatalExceptionStrategy;
77

88
@Slf4j
99
public class AmqpTraceAwareExceptionHandler extends ConditionalRejectingErrorHandler {

0 commit comments

Comments
 (0)