Skip to content

Commit d875b03

Browse files
Merge branch 'release-v2.2.x'
2 parents 4cccf09 + d42483d commit d875b03

7 files changed

Lines changed: 94 additions & 1 deletion

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
44
networkTimeout=10000
5+
retries=0
6+
retryBackOffMs=500
57
validateDistributionUrl=true
68
zipStoreBase=GRADLE_USER_HOME
79
zipStorePath=wrapper/dists
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2025-2026 The Problem4J Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.github.problem4j.spring.webflux.app.problem;
18+
19+
import io.github.problem4j.core.ProblemMapping;
20+
import org.springframework.http.HttpStatus;
21+
import org.springframework.web.bind.annotation.ResponseStatus;
22+
23+
@ResponseStatus(HttpStatus.FORBIDDEN)
24+
@ProblemMapping(status = 418, title = "Both Annotated Exception")
25+
public class BothAnnotatedException extends RuntimeException {}

problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/app/rest/ResponseStatusAnnotatedController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.github.problem4j.spring.webflux.app.rest;
1818

19+
import io.github.problem4j.spring.webflux.app.problem.BothAnnotatedException;
1920
import io.github.problem4j.spring.webflux.app.problem.ForbiddenAnnotatedException;
2021
import io.github.problem4j.spring.webflux.app.problem.ReasonAnnotatedException;
2122
import org.springframework.web.bind.annotation.GetMapping;
@@ -35,4 +36,9 @@ public String responseStatusAnnotated() {
3536
public String reasonAnnotated() {
3637
throw new ReasonAnnotatedException();
3738
}
39+
40+
@GetMapping("/both-annotated")
41+
public String bothAnnotated() {
42+
throw new BothAnnotatedException();
43+
}
3844
}

problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusAnnotatedExceptionWebFluxTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,19 @@ void givenSpringNativeResponseStatusAnnotationWithReason_shouldReturnProblem() {
6565
.value(v -> assertThat(v).isNotNull())
6666
.isEqualTo(Problem.of(HttpStatus.FORBIDDEN.value(), "this is reason"));
6767
}
68+
69+
@Test
70+
void givenBothResponseStatusAndProblemMappingAnnotations_shouldPreferProblemMapping() {
71+
webTestClient
72+
.get()
73+
.uri("/response-status-annotated/both-annotated")
74+
.exchange()
75+
.expectStatus()
76+
.isEqualTo(HttpStatus.valueOf(418))
77+
.expectHeader()
78+
.contentType(Problem.CONTENT_TYPE)
79+
.expectBody(Problem.class)
80+
.value(v -> assertThat(v).isNotNull())
81+
.isEqualTo(Problem.builder().status(418).title("Both Annotated Exception").build());
82+
}
6883
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2025-2026 The Problem4J Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.github.problem4j.spring.webmvc.app.problem;
18+
19+
import io.github.problem4j.core.ProblemMapping;
20+
import org.springframework.http.HttpStatus;
21+
import org.springframework.web.bind.annotation.ResponseStatus;
22+
23+
@ResponseStatus(HttpStatus.FORBIDDEN)
24+
@ProblemMapping(status = 418, title = "Both Annotated Exception")
25+
public class BothAnnotatedException extends RuntimeException {}

problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/app/rest/ResponseStatusAnnotatedController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.github.problem4j.spring.webmvc.app.rest;
1818

19+
import io.github.problem4j.spring.webmvc.app.problem.BothAnnotatedException;
1920
import io.github.problem4j.spring.webmvc.app.problem.ForbiddenAnnotatedException;
2021
import io.github.problem4j.spring.webmvc.app.problem.ReasonAnnotatedException;
2122
import org.springframework.web.bind.annotation.GetMapping;
@@ -35,4 +36,9 @@ public String responseStatusAnnotated() {
3536
public String reasonAnnotated() {
3637
throw new ReasonAnnotatedException();
3738
}
39+
40+
@GetMapping("/both-annotated")
41+
public String bothAnnotated() {
42+
throw new BothAnnotatedException();
43+
}
3844
}

problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusAnnotatedExceptionWebMvcTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,18 @@ void givenSpringNativeResponseStatusAnnotationWithReason_shouldReturnProblem() {
6565

6666
assertThat(problem).isEqualTo(Problem.of(HttpStatus.FORBIDDEN.value(), "this is reason"));
6767
}
68+
69+
@Test
70+
void givenBothResponseStatusAndProblemMappingAnnotations_shouldPreferProblemMapping() {
71+
ResponseEntity<String> response =
72+
restTemplate.getForEntity("/response-status-annotated/both-annotated", String.class);
73+
74+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.valueOf(418));
75+
assertThat(response.getHeaders().getContentType()).hasToString(Problem.CONTENT_TYPE);
76+
77+
Problem problem = jsonMapper.readValue(response.getBody(), Problem.class);
78+
79+
assertThat(problem)
80+
.isEqualTo(Problem.builder().status(418).title("Both Annotated Exception").build());
81+
}
6882
}

0 commit comments

Comments
 (0)