diff --git a/http/src/main/java/io/micronaut/http/filter/InternalHttpFilter.java b/http/src/main/java/io/micronaut/http/filter/InternalHttpFilter.java index c263a1a1127..b653481464e 100644 --- a/http/src/main/java/io/micronaut/http/filter/InternalHttpFilter.java +++ b/http/src/main/java/io/micronaut/http/filter/InternalHttpFilter.java @@ -31,7 +31,7 @@ * @since 4.2.0 */ @Internal -sealed interface InternalHttpFilter extends GenericHttpFilter, Ordered permits AroundLegacyFilter, AsyncFilter, MethodFilter, TerminalFilter, TerminalReactiveFilter { +sealed interface InternalHttpFilter extends GenericHttpFilter, Ordered permits AroundLegacyFilter, AsyncFilter, MethodFilter { /** * If the filter supports filtering a request. diff --git a/http/src/main/java/io/micronaut/http/filter/TerminalFilter.java b/http/src/main/java/io/micronaut/http/filter/TerminalFilter.java deleted file mode 100644 index 1e1411bc328..00000000000 --- a/http/src/main/java/io/micronaut/http/filter/TerminalFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2017-2023 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.http.filter; - -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.execution.ExecutionFlow; -import io.micronaut.core.propagation.PropagatedContext; -import io.micronaut.http.HttpRequest; -import io.micronaut.http.MutableHttpResponse; - -import java.util.function.Function; - -/** - * Last item in a filter chain, called when all other filters are done. Basically, this runs - * the actual request. - * - * @author Jonas Konrad - * @author Denis Stepanov - * @since 4.2.0 - */ -@Internal -final class TerminalFilter implements InternalHttpFilter { - - private final Function, ExecutionFlow>> fn; - - TerminalFilter(Function, ExecutionFlow>> fn) { - this.fn = fn; - } - - @Override - public boolean isFiltersRequest() { - return true; - } - - @Override - public boolean isFiltersResponse() { - return false; - } - - @Override - public boolean hasContinuation() { - return false; - } - - @Override - public ExecutionFlow processRequestFilter(FilterContext context) { - try { - try (PropagatedContext.Scope ignore = context.propagatedContext().propagate()) { - return fn.apply(context.request()).map(context::withResponse); - } - } catch (Throwable e) { - return ExecutionFlow.error(e); - } - } - - @Override - public ExecutionFlow processRequestFilter(FilterContext context, - Function> downstream) { - try { - try (PropagatedContext.Scope ignore = context.propagatedContext().propagate()) { - return fn.apply(context.request()).map(context::withResponse).flatMap(downstream); - } - } catch (Throwable e) { - return ExecutionFlow.error(e); - } - } -} diff --git a/http/src/main/java/io/micronaut/http/filter/TerminalReactiveFilter.java b/http/src/main/java/io/micronaut/http/filter/TerminalReactiveFilter.java deleted file mode 100644 index b92026a5690..00000000000 --- a/http/src/main/java/io/micronaut/http/filter/TerminalReactiveFilter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2017-2023 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.http.filter; - -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.execution.ExecutionFlow; -import io.micronaut.core.propagation.PropagatedContext; -import io.micronaut.http.HttpResponse; -import io.micronaut.http.reactive.execution.ReactiveExecutionFlow; -import org.reactivestreams.Publisher; - -import java.util.function.Function; - -/** - * Terminal filter that accepts a reactive type. Used as a temporary solution for the http - * client, until that is un-reactified. - * - * @author Jonas Konrad - * @author Denis Stepanov - * @since 4.2.0 - */ -@Internal -final class TerminalReactiveFilter implements InternalHttpFilter { - - private final Publisher> responsePublisher; - - /** - * @param responsePublisher The response publisher - */ - public TerminalReactiveFilter(Publisher> responsePublisher) { - this.responsePublisher = responsePublisher; - } - - @Override - public boolean isFiltersRequest() { - return true; - } - - @Override - public boolean isFiltersResponse() { - return false; - } - - @Override - public boolean hasContinuation() { - return false; - } - - @Override - public ExecutionFlow processRequestFilter(FilterContext context) { - try { - try (PropagatedContext.Scope ignore = context.propagatedContext().propagate()) { - return ReactiveExecutionFlow.fromPublisher(responsePublisher).map(context::withResponse); - } - } catch (Throwable e) { - return ExecutionFlow.error(e); - } - } - - @Override - public ExecutionFlow processRequestFilter(FilterContext context, - Function> downstream) { - try { - try (PropagatedContext.Scope ignore = context.propagatedContext().propagate()) { - return ReactiveExecutionFlow.fromPublisher(responsePublisher).map(context::withResponse).flatMap(downstream); - } - } catch (Throwable e) { - return ExecutionFlow.error(e); - } - } - -}