Exposes headerFilter on SimpAnnotationMethodMessageHandler

Closes gh-36179
This commit is contained in:
rstoyanchev
2026-02-06 17:08:50 +00:00
parent 7fc619acdc
commit 1d470fc375
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import org.apache.commons.logging.Log;
import org.jspecify.annotations.Nullable;
@@ -118,6 +119,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
private @Nullable MessageHeaderInitializer headerInitializer;
private @Nullable Predicate<String> headerFilter;
private @Nullable Integer phase;
private volatile boolean running;
@@ -268,6 +271,22 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
return this.headerInitializer;
}
/**
* Add a filter to determine which headers from the input message should be
* propagated to the output message. Applies to return value handling of
* {@code @SendTo}, {@code @SendToUser}, and {@code @SubscribeMapping}
* controller methods. Multiple filters are combined with
* {@link Predicate#or(Predicate)}.
* <p>By default, no headers are propagated if this is not set.
* @since 7.0.4
* @see SendToMethodReturnValueHandler#addHeaderFilter(Predicate)
* @see SubscriptionMethodReturnValueHandler#addHeaderFilter(Predicate)
*/
public void addHeaderFilter(Predicate<String> filter) {
Assert.notNull(filter, "'headerFilter' predicate must not be null");
this.headerFilter = (this.headerFilter != null ? this.headerFilter.or(filter) : filter);
}
/**
* Set the phase that this handler should run in.
* <p>By default, this is {@link SmartLifecycle#DEFAULT_PHASE}, but with