allthingssecurity commented on code in PR #28377:
URL: https://github.com/apache/camel/pull/28377#discussion_r4366110288
##########
components/camel-undertow/src/main/java/org/apache/camel/component/undertow/handlers/CamelPathTemplateHandler.java:
##########
@@ -36,7 +36,18 @@ public class CamelPathTemplateHandler implements HttpHandler
{
private String handlerString;
public CamelPathTemplateHandler(CamelMethodHandler defaultHandler) {
+ this(defaultHandler, null);
+ }
+
+ /**
+ * @param defaultHandler the handler of the static base path, for a
request that no template matches
+ * @param fallbackHandler the handler for a request that no template
matches while no static base path is set (the
+ * handler of the requests that no path of the
server matches), or null to let the empty
+ * default handler answer 405
+ */
+ public CamelPathTemplateHandler(CamelMethodHandler defaultHandler,
HttpHandler fallbackHandler) {
defaultHandlerWrapper.set(defaultHandler);
+ defaultHandlerWrapper.fallback = fallbackHandler;
Review Comment:
Fair point. `fallback` is set once from the outer class at construction and
never changed afterwards, so I kept it as a plain field; I can add a setter if
you want the same pattern as `handler`.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-undertow/src/main/java/org/apache/camel/component/undertow/handlers/CamelMethodHandler.java:
##########
@@ -67,6 +67,18 @@ public void handleRequest(HttpServerExchange exchange)
throws Exception {
}
}
+ /**
+ * Whether no handler is set for any method, such as the default handler
of a template path that has no static path.
+ */
+ public boolean isEmpty() {
Review Comment:
Yes, lock-free on purpose, like `handleRequest()`: `ConcurrentHashMap`
iteration is weakly consistent, and `isEmpty()` is only used to decide whether
the handler can be removed, under the outer registration lock.
_Claude Code on behalf of allthingssecurity_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]