Skip to content

Commit

Permalink
Revert RoutingFilter use of try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Nov 26, 2024
1 parent 7050aa3 commit aa9af57
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions avaje-jex/src/main/java/io/avaje/jex/jdk/RoutingFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void doFilter(HttpExchange exchange, Filter.Chain chain) {
if (route == null) {
var ctx = new JdkContext(mgr, exchange, uri, Set.of());
routes.inc();
try (exchange) {
try {
processNoRoute(ctx, uri, routeType);
exchange.setAttribute("JdkContext", ctx);
chain.doFilter(exchange);
Expand All @@ -46,10 +46,11 @@ public void doFilter(HttpExchange exchange, Filter.Chain chain) {
handleException(ctx, e);
} finally {
routes.dec();
exchange.close();
}
} else {
route.inc();
try (exchange) {
try {
final Map<String, String> params = route.pathParams(uri);
JdkContext ctx = new JdkContext(mgr, exchange, route.matchPath(), params, route.roles());
try {
Expand All @@ -64,6 +65,7 @@ public void doFilter(HttpExchange exchange, Filter.Chain chain) {
}
} finally {
route.dec();
exchange.close();
}
}
}
Expand Down

0 comments on commit aa9af57

Please sign in to comment.