Skip to content

Commit 74b77ee

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

7 files changed

Lines changed: 104 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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025-2026 The Problem4J Authors
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all
11+
* copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
package io.github.problem4j.spring.webflux.app.problem;
23+
24+
import io.github.problem4j.core.ProblemMapping;
25+
import org.springframework.http.HttpStatus;
26+
import org.springframework.web.bind.annotation.ResponseStatus;
27+
28+
@ResponseStatus(HttpStatus.FORBIDDEN)
29+
@ProblemMapping(status = 418, title = "Both Annotated Exception")
30+
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025-2026 The Problem4J Authors
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all
11+
* copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
package io.github.problem4j.spring.webmvc.app.problem;
23+
24+
import io.github.problem4j.core.ProblemMapping;
25+
import org.springframework.http.HttpStatus;
26+
import org.springframework.web.bind.annotation.ResponseStatus;
27+
28+
@ResponseStatus(HttpStatus.FORBIDDEN)
29+
@ProblemMapping(status = 418, title = "Both Annotated Exception")
30+
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)