Skip to content

Commit 1f873e5

Browse files
Drop ResponseSupport
1 parent 3cbb1e1 commit 1f873e5

10 files changed

Lines changed: 28 additions & 129 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ The format is based on [Keep a Changelog][keepachangelog], and this project adhe
1919
- Bump `problem4j-jackson3` to `2.0.0-RC1`.
2020
- Change `ProblemResolver` to contain just `resolve` method, returning `Problem`.
2121
- Hide `IdentityProblemFormat` and make it available via `ProblemFormat.identity()`.
22-
- Split `ProblemSupport` into `ViolationSupport` and `ResponseSupport` to separate concerns and mitigate conflicts with
23-
`ProblemSupport` in `problem4j-core`.
22+
- Hide `IdentityProblemPostProcessor` and make it available via `ProblemPostProcessor.identity()`.
23+
- Move `ProblemSupport` into `ViolationSupport` to mitigate conflicts with `ProblemSupport` in `problem4j-core`.
2424

2525
### Removed
2626

2727
- Remove `problem4j.resolver-caching.max-cache-size` and evicting cache for `ProblemResolver`-s (non-evicting cache is
2828
still present).
2929
- Remove `ProblemSupport.resolveStatus(HttpStatusCode)`.
30+
- Remove `ProblemSupport.resolveStatus(Problem)`.
3031

3132
## [2.2.4] - 2026-03-29
3233

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,15 @@ public class ExampleExceptionResolver implements ProblemResolver {
124124
}
125125

126126
@Override
127-
public ProblemBuilder resolveBuilder(
127+
public Problem resolve(
128128
ProblemContext context, Exception ex, HttpHeaders headers, HttpStatusCode status) {
129129
return Problem.builder()
130130
.type("errors/invalid-request")
131131
.title("Invalid Request")
132132
.status(400)
133133
.detail("bad input for user " + ((ExampleException) ex).getUserId())
134-
.extension("userId", ((ExampleException) ex).getUserId());
134+
.extension("userId", ((ExampleException) ex).getUserId())
135+
.build();
135136
}
136137
}
137138
```

problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/ResponseSupport.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

problem4j-spring-web/src/test/java/io/github/problem4j/spring/web/ResponseSupportTest.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

problem4j-spring-webflux/src/main/java/io/github/problem4j/spring/webflux/ExceptionWebFluxAdvice.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.github.problem4j.spring.webflux;
1818

1919
import static io.github.problem4j.spring.web.AttributeSupport.PROBLEM_CONTEXT_ATTRIBUTE;
20-
import static io.github.problem4j.spring.web.ResponseSupport.resolveStatus;
2120
import static io.github.problem4j.spring.webflux.WebFluxAdviceSupport.logAdviceException;
2221

2322
import io.github.problem4j.core.Problem;
@@ -119,7 +118,9 @@ public Mono<ResponseEntity<Problem>> handleException(Exception ex, ServerWebExch
119118
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
120119
}
121120

122-
HttpStatus status = resolveStatus(problem);
121+
HttpStatus status =
122+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
123+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
123124

124125
for (AdviceWebFluxInspector inspector : adviceWebFluxInspectors) {
125126
inspector.inspect(context, problem, ex, headers, status, exchange);

problem4j-spring-webflux/src/main/java/io/github/problem4j/spring/webflux/ProblemEnhancedWebFluxHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
package io.github.problem4j.spring.webflux;
1818

1919
import static io.github.problem4j.spring.web.AttributeSupport.PROBLEM_CONTEXT_ATTRIBUTE;
20-
import static io.github.problem4j.spring.web.ResponseSupport.resolveStatus;
2120
import static io.github.problem4j.spring.webflux.WebFluxAdviceSupport.logAdviceException;
2221

2322
import io.github.problem4j.core.Problem;
2423
import io.github.problem4j.core.ProblemContext;
2524
import io.github.problem4j.spring.web.ProblemPostProcessor;
2625
import io.github.problem4j.spring.web.ProblemResolverStore;
2726
import java.util.List;
27+
import java.util.Optional;
2828
import org.jspecify.annotations.Nullable;
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
@@ -119,7 +119,9 @@ protected Mono<ResponseEntity<Object>> handleExceptionInternal(
119119
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
120120
}
121121

122-
status = resolveStatus(problem);
122+
status =
123+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
124+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
123125

124126
for (AdviceWebFluxInspector inspector : adviceWebFluxInspectors) {
125127
inspector.inspect(context, problem, ex, headers, status, exchange);

problem4j-spring-webflux/src/main/java/io/github/problem4j/spring/webflux/ProblemExceptionWebFluxAdvice.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import io.github.problem4j.core.ProblemContext;
2424
import io.github.problem4j.core.ProblemException;
2525
import io.github.problem4j.spring.web.ProblemPostProcessor;
26-
import io.github.problem4j.spring.web.ResponseSupport;
2726
import java.util.List;
27+
import java.util.Optional;
2828
import org.slf4j.Logger;
2929
import org.slf4j.LoggerFactory;
3030
import org.springframework.http.HttpHeaders;
@@ -96,7 +96,9 @@ public Mono<ResponseEntity<Problem>> handleProblemException(
9696
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
9797
}
9898

99-
HttpStatus status = ResponseSupport.resolveStatus(problem);
99+
HttpStatus status =
100+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
101+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
100102

101103
for (AdviceWebFluxInspector inspector : adviceWebFluxInspectors) {
102104
inspector.inspect(context, problem, ex, headers, status, exchange);

problem4j-spring-webmvc/src/main/java/io/github/problem4j/spring/webmvc/ExceptionWebMvcAdvice.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import io.github.problem4j.core.ProblemMapper;
2727
import io.github.problem4j.spring.web.ProblemPostProcessor;
2828
import io.github.problem4j.spring.web.ProblemResolverStore;
29-
import io.github.problem4j.spring.web.ResponseSupport;
3029
import io.github.problem4j.spring.web.resolver.ProblemResolver;
3130
import java.util.List;
3231
import java.util.Optional;
@@ -122,7 +121,9 @@ public ResponseEntity<Object> handleException(Exception ex, WebRequest request)
122121
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
123122
}
124123

125-
HttpStatus status = ResponseSupport.resolveStatus(problem);
124+
HttpStatus status =
125+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
126+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
126127

127128
for (AdviceWebMvcInspector inspector : adviceWebMvcInspectors) {
128129
inspector.inspect(context, problem, ex, headers, status, request);

problem4j-spring-webmvc/src/main/java/io/github/problem4j/spring/webmvc/ProblemEnhancedWebMvcHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.github.problem4j.spring.webmvc;
1818

1919
import static io.github.problem4j.spring.web.AttributeSupport.PROBLEM_CONTEXT_ATTRIBUTE;
20-
import static io.github.problem4j.spring.web.ResponseSupport.resolveStatus;
2120
import static io.github.problem4j.spring.webmvc.WebMvcAdviceSupport.logAdviceException;
2221
import static org.springframework.web.context.request.RequestAttributes.SCOPE_REQUEST;
2322

@@ -26,6 +25,7 @@
2625
import io.github.problem4j.spring.web.ProblemPostProcessor;
2726
import io.github.problem4j.spring.web.ProblemResolverStore;
2827
import java.util.List;
28+
import java.util.Optional;
2929
import org.jspecify.annotations.Nullable;
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
@@ -120,7 +120,9 @@ public ProblemEnhancedWebMvcHandler(
120120
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
121121
}
122122

123-
status = resolveStatus(problem);
123+
status =
124+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
125+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
124126

125127
for (AdviceWebMvcInspector inspector : adviceWebMvcInspectors) {
126128
inspector.inspect(context, problem, ex, headers, status, request);

problem4j-spring-webmvc/src/main/java/io/github/problem4j/spring/webmvc/ProblemExceptionWebMvcAdvice.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import io.github.problem4j.core.ProblemContext;
2525
import io.github.problem4j.core.ProblemException;
2626
import io.github.problem4j.spring.web.ProblemPostProcessor;
27-
import io.github.problem4j.spring.web.ResponseSupport;
2827
import java.util.List;
28+
import java.util.Optional;
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
3131
import org.springframework.http.HttpHeaders;
@@ -99,7 +99,9 @@ public ResponseEntity<Problem> handleProblemException(ProblemException ex, WebRe
9999
problem = Problem.of(HttpStatus.INTERNAL_SERVER_ERROR.value());
100100
}
101101

102-
HttpStatus status = ResponseSupport.resolveStatus(problem);
102+
HttpStatus status =
103+
Optional.ofNullable(HttpStatus.resolve(problem.getStatus()))
104+
.orElse(HttpStatus.INTERNAL_SERVER_ERROR);
103105

104106
for (AdviceWebMvcInspector inspector : adviceWebMvcInspectors) {
105107
inspector.inspect(context, problem, ex, headers, status, request);

0 commit comments

Comments
 (0)