Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.camel.component.undertow.UndertowConstants.EventType;
import org.apache.camel.component.undertow.handlers.CamelWebSocketHandler;
import org.apache.camel.component.undertow.spi.UndertowSecurityProvider;
import org.apache.camel.http.base.HttpHeaderFilterStrategy;
import org.apache.camel.http.base.OAuthHttpSecuritySupport;
import org.apache.camel.http.base.OAuthProfileAwareHttpEndpoint;
import org.apache.camel.http.base.cookie.CookieHandler;
Expand Down Expand Up @@ -85,7 +84,7 @@ public class UndertowEndpoint extends DefaultEndpoint
@UriParam(label = "advanced")
private AccessLogReceiver accessLogReceiver;
@UriParam(label = "advanced")
private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
private HeaderFilterStrategy headerFilterStrategy = new UndertowHeaderFilterStrategy();
@UriParam(label = "security")
private SSLContextParameters sslContextParameters;
@UriParam(label = "consumer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

import java.net.URI;

import org.apache.camel.http.base.HttpHeaderFilterStrategy;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: per project conventions, new test code should prefer AssertJ assertions (assertThat(...)) over JUnit assertions (assertInstanceOf, assertSame, assertTrue).


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class UndertowEndpointTest {

Expand All @@ -47,4 +52,35 @@ public void nonEmptyPathShouldBeKeptSame() {
endpoint.setHttpURI(withSlash);
assertEquals(withSlash, endpoint.getHttpURI());
}

@Test
void defaultHeaderFilterStrategyIsUndertowSpecific() {
assertInstanceOf(UndertowHeaderFilterStrategy.class, endpoint.getHeaderFilterStrategy());
}

@Test
void defaultBindingKeepsUndertowHeaderFilterStrategy() {
// the endpoint pushes its own strategy into the lazily created binding, so the endpoint default
// decides which strategy the binding ends up running
DefaultUndertowHttpBinding binding
= assertInstanceOf(DefaultUndertowHttpBinding.class, endpoint.getUndertowHttpBinding());
HeaderFilterStrategy strategy = binding.getHeaderFilterStrategy();
assertInstanceOf(UndertowHeaderFilterStrategy.class, strategy);

// the undertow-specific prefixes added by CAMEL-23588 must therefore be in effect
assertTrue(strategy.applyFilterToExternalHeaders(UndertowConstants.CONNECTION_KEY, "aValue", null));
assertTrue(strategy.applyFilterToExternalHeaders(UndertowConstants.CONNECTION_KEY_LIST, "aValue", null));
assertTrue(strategy.applyFilterToExternalHeaders(UndertowConstants.SEND_TO_ALL, "aValue", null));
assertTrue(strategy.applyFilterToCamelHeaders(UndertowConstants.CONNECTION_KEY, "aValue", null));
}

@Test
void explicitHeaderFilterStrategyIsHandedToTheBinding() {
HeaderFilterStrategy custom = new HttpHeaderFilterStrategy();
endpoint.setHeaderFilterStrategy(custom);

DefaultUndertowHttpBinding binding
= assertInstanceOf(DefaultUndertowHttpBinding.class, endpoint.getUndertowHttpBinding());
assertSame(custom, binding.getHeaderFilterStrategy());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1619,3 +1619,35 @@ only once.
In a Spring Boot application, Spring AI's auto-configured `ToolCallbackResolver` is built from the
`ToolCallback` and `ToolCallbackProvider` beans in the context. A bare `@Bean Function<...>` is no
longer resolvable by bean name; expose such tools as `ToolCallback` or `ToolCallbackProvider` beans.

=== camel-undertow - UndertowHeaderFilterStrategy is now the endpoint default

`UndertowEndpoint` defaulted its `headerFilterStrategy` to the base
`HttpHeaderFilterStrategy`, and pushed that strategy into the `DefaultUndertowHttpBinding`
it creates lazily, overwriting the `UndertowHeaderFilterStrategy` that the binding installs
in its own constructor. The undertow-specific filtering was therefore not applied on
endpoint-configured routes.

The endpoint now defaults to `UndertowHeaderFilterStrategy`, which makes two already
documented behaviours take effect:

* The legacy `websocket.*` Exchange-header prefix, added to the in and out filters in
4.14.8 / 4.18.3 / 4.21.0 (see the 4.18 upgrade guide), is now filtered at the undertow
transport boundary as described there.
* Header names that undertow does not accept (those for which
`io.undertow.util.HttpString.tryFromString` returns `null`) are skipped when mapping
external headers in, rather than being mapped onto the message.

Ordinary application headers are unaffected, and Rest DSL consumers already used an
undertow-specific strategy (`UndertowRestHeaderFilterStrategy`) so their behaviour does not
change. Routes that relied on `websocket.*` headers crossing the undertow boundary in either
direction, and routes that relied on undertow-invalid header names being mapped, can restore
the previous behaviour by configuring `headerFilterStrategy` explicitly on the endpoint:

[source,java]
----
from("undertow:http://0.0.0.0:8080/foo?headerFilterStrategy=#myStrategy")
----

Routes that already supply a custom `headerFilterStrategy` or a custom `undertowHttpBinding`
are unaffected.