mirror of
https://github.com/jlengrand/helidon.git
synced 2026-03-10 08:21:17 +00:00
Remove deprecations 1 (#1884)
* Deprecated Span injection removed from Jersey integration. * Deprecated methods and uses in HealthChecks removed (where possible). * Removed deprecated ContextualRegistry Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.helidon.common.http;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
|
||||
/**
|
||||
* A registry for context objects. Enables instance localization between several <i>services / components / ...</i> integrated in
|
||||
* a particular known scope. ContextualRegistry instance is intended to be associated with a scope aware object such as
|
||||
* WebServer, ServerRequest or ClientRequest.
|
||||
*
|
||||
* <p>Context contains also a notion of <i>classifiers</i>. Classifier is any object defining additional <i>key</i> for registered
|
||||
* objects. To obtain such registered object, the same classifier (precisely, any equal object) has to be used.
|
||||
*
|
||||
* <p>Classifiers can be used as follows:<ol>
|
||||
* <li>As an additional identifier for registered objects of common types, like a {@link String}, ...<br>
|
||||
* <pre>{@code
|
||||
* // User detail provider service
|
||||
* registry.register("NAME_PARAM_ID", "Smith");
|
||||
* registry.register("GENDER_PARAM_ID", "male");
|
||||
* ...
|
||||
* // User consumer service
|
||||
* String name = registry.get("name", String.class);
|
||||
* }</pre></li>
|
||||
* <li>As an access control mechanism where only owners of the classifier can retrieve such contextual instance.<br>
|
||||
* <pre>{@code
|
||||
* // In some central security service.
|
||||
* registry.register(securityFrameworkInternalInstance, new AuthenticatedInternalIdentity(...));
|
||||
* ...
|
||||
* // In some authorization filter known by a central security service
|
||||
* AuthenticatedInternalIdentity auth = registry.get(securityFrameworkInternalInstance, AuthenticatedInternalIdentity.class);
|
||||
* }</pre></li>
|
||||
* </ol>
|
||||
*
|
||||
* @deprecated This class will be replaced with {@link io.helidon.common.context.Context} in future Helidon versions
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ContextualRegistry extends Context {
|
||||
|
||||
/**
|
||||
* Creates a new empty instance.
|
||||
*
|
||||
* @return new instance
|
||||
* @deprecated use {@link io.helidon.common.context.Context#create()}
|
||||
*/
|
||||
@Deprecated
|
||||
static ContextualRegistry create() {
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty instance backed by its parent read-through {@link ContextualRegistry}.
|
||||
*
|
||||
* <p>Parent {@code registry} is used only for get methods and only if this registry doesn't have registered required type.
|
||||
*
|
||||
* @param parent a parent registry
|
||||
* @return new instance
|
||||
* @deprecated use {@link io.helidon.common.context.Context#create(io.helidon.common.context.Context)}
|
||||
*/
|
||||
@Deprecated
|
||||
static ContextualRegistry create(Context parent) {
|
||||
return builder().parent(parent).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fluent API builder for advanced configuration.
|
||||
*
|
||||
* @return a new builder
|
||||
* @deprecated used for backward compatibility only
|
||||
*/
|
||||
@Deprecated
|
||||
static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fluent API builder for {@link io.helidon.common.http.ContextualRegistry}.
|
||||
*/
|
||||
class Builder implements io.helidon.common.Builder<ContextualRegistry> {
|
||||
private Context parent;
|
||||
private String id;
|
||||
|
||||
@Override
|
||||
public ContextualRegistry build() {
|
||||
return new ListContextualRegistry(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent of the new context.
|
||||
* @param parent parent context
|
||||
*
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder parent(Context parent) {
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identification of the new context, should be unique within this runtime.
|
||||
*
|
||||
* @param id context identification
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
Context parent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
String id() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.helidon.common.http;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
|
||||
/**
|
||||
* A {@link ContextualRegistry} implementation with deque registry.
|
||||
*/
|
||||
class ListContextualRegistry implements ContextualRegistry {
|
||||
private final Context delegate;
|
||||
|
||||
ListContextualRegistry(ContextualRegistry.Builder builder) {
|
||||
String configuredId = builder.id();
|
||||
Context parent = builder.parent();
|
||||
|
||||
Context.Builder delegateBuilder = Context.builder();
|
||||
|
||||
if (null != parent) {
|
||||
if (parent instanceof ListContextualRegistry) {
|
||||
delegateBuilder.parent(((ListContextualRegistry) parent).delegate);
|
||||
} else {
|
||||
delegateBuilder.parent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != configuredId) {
|
||||
delegateBuilder.id(configuredId);
|
||||
}
|
||||
|
||||
this.delegate = delegateBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return delegate.id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void register(T instance) {
|
||||
delegate.register(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void supply(Class<T> type, Supplier<T> supplier) {
|
||||
delegate.supply(type, supplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> get(Class<T> type) {
|
||||
return delegate.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void register(Object classifier, T instance) {
|
||||
delegate.register(classifier, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void supply(Object classifier, Class<T> type, Supplier<T> supplier) {
|
||||
delegate.supply(classifier, type, supplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> get(Object classifier, Class<T> type) {
|
||||
return delegate.get(classifier, type);
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.helidon.common.http;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests {@link ListContextualRegistry} and {@link ContextualRegistry}.
|
||||
*/
|
||||
public class ListContextTest {
|
||||
|
||||
@Test
|
||||
public void create() {
|
||||
assertThat(ContextualRegistry.create(), notNullValue());
|
||||
assertThat(ContextualRegistry.create(null), notNullValue());
|
||||
assertThat(ContextualRegistry.create(ContextualRegistry.create()), notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerAndGetLast() {
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
assertThat(context.get(Integer.class), is(Optional.empty()));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(Integer.class), is(Optional.empty()));
|
||||
context.register(1);
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(Integer.class), is(Optional.of(1)));
|
||||
assertThat(context.get(Object.class), is(Optional.of(1)));
|
||||
context.register("bbb");
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(Object.class), is(Optional.of("bbb")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerAndGetLastClassifier() {
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
String classifier = "classifier";
|
||||
assertThat(context.get(classifier, String.class), is(Optional.empty()));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.empty()));
|
||||
context.register(classifier, "aaa");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.empty()));
|
||||
context.register(classifier, 1);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.of(1)));
|
||||
assertThat(context.get(classifier, Object.class), is(Optional.of(1)));
|
||||
context.register(classifier, "bbb");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
context.register("ccc");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(classifier, Object.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(String.class), is(Optional.of("ccc")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyParent() {
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() {
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
parent.register("ppp");
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(String.class), is(Optional.of("ppp")));
|
||||
context.register(1);
|
||||
assertThat(context.get(String.class), is(Optional.of("ppp")));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(parent.get(String.class), is(Optional.of("ppp")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentWithClassifier() {
|
||||
String classifier = "classifier";
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
parent.register(classifier, "ppp");
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
context.register(classifier, 1);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
context.register(classifier, "aaa");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(parent.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupply() {
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
context.register(1);
|
||||
Date date = new Date();
|
||||
context.register(date);
|
||||
context.register("aaa");
|
||||
context.supply(String.class, () -> {
|
||||
counter.incrementAndGet();
|
||||
return "bbb";
|
||||
});
|
||||
context.register(2);
|
||||
assertThat(context.get(Date.class), is(Optional.of(date)));
|
||||
assertThat(counter.get(), is(0));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(Date.class), is(Optional.of(date)));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupplyClassifier() {
|
||||
String classifier = "classifier";
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
context.register(classifier, 1);
|
||||
Date date = new Date();
|
||||
context.register(classifier, date);
|
||||
context.register(classifier, "aaa");
|
||||
context.supply(classifier, String.class, () -> {
|
||||
counter.incrementAndGet();
|
||||
return "bbb";
|
||||
});
|
||||
context.register(classifier, 2);
|
||||
assertThat(context.get(classifier, Date.class), is(Optional.of(date)));
|
||||
assertThat(counter.get(), is(0));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(classifier, Date.class), is(Optional.of(date)));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.helidon.common.http;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests {@link ListContextualRegistry} and {@link ContextualRegistry}.
|
||||
*/
|
||||
public class ListContextualRegistryTest {
|
||||
|
||||
@Test
|
||||
public void create() {
|
||||
assertThat(ContextualRegistry.create(), notNullValue());
|
||||
assertThat(ContextualRegistry.create(null), notNullValue());
|
||||
assertThat(ContextualRegistry.create(ContextualRegistry.create()), notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerAndGetLast() {
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
assertThat(context.get(Integer.class), is(Optional.empty()));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(Integer.class), is(Optional.empty()));
|
||||
context.register(1);
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(Integer.class), is(Optional.of(1)));
|
||||
assertThat(context.get(Object.class), is(Optional.of(1)));
|
||||
context.register("bbb");
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(Object.class), is(Optional.of("bbb")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerAndGetLastClassifier() {
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
String classifier = "classifier";
|
||||
assertThat(context.get(classifier, String.class), is(Optional.empty()));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.empty()));
|
||||
context.register(classifier, "aaa");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.empty()));
|
||||
context.register(classifier, 1);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(context.get(classifier, Integer.class), is(Optional.of(1)));
|
||||
assertThat(context.get(classifier, Object.class), is(Optional.of(1)));
|
||||
context.register(classifier, "bbb");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
context.register("ccc");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(classifier, Object.class), is(Optional.of("bbb")));
|
||||
assertThat(context.get(String.class), is(Optional.of("ccc")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyParent() {
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(String.class), is(Optional.empty()));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() {
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
parent.register("ppp");
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(String.class), is(Optional.of("ppp")));
|
||||
context.register(1);
|
||||
assertThat(context.get(String.class), is(Optional.of("ppp")));
|
||||
context.register("aaa");
|
||||
assertThat(context.get(String.class), is(Optional.of("aaa")));
|
||||
assertThat(parent.get(String.class), is(Optional.of("ppp")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentWithClassifier() {
|
||||
String classifier = "classifier";
|
||||
ContextualRegistry parent = ContextualRegistry.create();
|
||||
parent.register(classifier, "ppp");
|
||||
ContextualRegistry context = ContextualRegistry.create(parent);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
context.register(classifier, 1);
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
context.register(classifier, "aaa");
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("aaa")));
|
||||
assertThat(parent.get(classifier, String.class), is(Optional.of("ppp")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupply() {
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
context.register(1);
|
||||
Date date = new Date();
|
||||
context.register(date);
|
||||
context.register("aaa");
|
||||
context.supply(String.class, () -> {
|
||||
counter.incrementAndGet();
|
||||
return "bbb";
|
||||
});
|
||||
context.register(2);
|
||||
assertThat(context.get(Date.class), is(Optional.of(date)));
|
||||
assertThat(counter.get(), is(0));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(Date.class), is(Optional.of(date)));
|
||||
assertThat(context.get(String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupplyClassifier() {
|
||||
String classifier = "classifier";
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
context.register(classifier, 1);
|
||||
Date date = new Date();
|
||||
context.register(classifier, date);
|
||||
context.register(classifier, "aaa");
|
||||
context.supply(classifier, String.class, () -> {
|
||||
counter.incrementAndGet();
|
||||
return "bbb";
|
||||
});
|
||||
context.register(classifier, 2);
|
||||
assertThat(context.get(classifier, Date.class), is(Optional.of(date)));
|
||||
assertThat(counter.get(), is(0));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
assertThat(context.get(classifier, Date.class), is(Optional.of(date)));
|
||||
assertThat(context.get(classifier, String.class), is(Optional.of("bbb")));
|
||||
assertThat(counter.get(), is(1));
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,8 @@ public final class DbClientHealthCheck implements HealthCheck {
|
||||
*
|
||||
* @param dbClient A database that implements {@link io.helidon.dbclient.DbClient#ping()}
|
||||
* @return health check that can be used with
|
||||
* {@link io.helidon.health.HealthSupport.Builder#add(org.eclipse.microprofile.health.HealthCheck...)}
|
||||
* {@link io.helidon.health.HealthSupport.Builder#addReadiness(org.eclipse.microprofile.health.HealthCheck...)}
|
||||
* or {@link io.helidon.health.HealthSupport.Builder#addLiveness(org.eclipse.microprofile.health.HealthCheck...)}
|
||||
*/
|
||||
public static DbClientHealthCheck create(DbClient dbClient) {
|
||||
return builder(dbClient).build();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package io.helidon.webserver.examples.tutorial.user;
|
||||
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.webserver.Handler;
|
||||
import io.helidon.webserver.Routing;
|
||||
import io.helidon.webserver.ServerRequest;
|
||||
@@ -24,7 +23,7 @@ import io.helidon.webserver.ServerResponse;
|
||||
|
||||
/**
|
||||
* If used as a {@link Routing Routing} {@link Handler} then assign valid {@link User} instance on the request
|
||||
* {@link ContextualRegistry context}.
|
||||
* {@link io.helidon.common.context.Context context}.
|
||||
*/
|
||||
public class UserFilter implements Handler {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -120,7 +120,7 @@ public class ContextIT {
|
||||
|
||||
|
||||
/**
|
||||
* A test gRPC service that obtains a value from the {@link io.helidon.common.http.ContextualRegistry}.
|
||||
* A test gRPC service that obtains a value from the {@link io.helidon.common.context.Context}.
|
||||
*/
|
||||
public static class ContextService
|
||||
implements GrpcService {
|
||||
@@ -156,7 +156,7 @@ public class ContextIT {
|
||||
|
||||
|
||||
/**
|
||||
* A test value to register with the {@link io.helidon.common.http.ContextualRegistry}.
|
||||
* A test value to register with the {@link io.helidon.common.context.Context}.
|
||||
*/
|
||||
private static class TestValue {
|
||||
private final String value;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -151,7 +151,7 @@ public final class DiskSpaceHealthCheck implements HealthCheck {
|
||||
* Create a new disk space health check to use, using defaults for all configurable values.
|
||||
*
|
||||
* @return a new health check to register with
|
||||
* {@link io.helidon.health.HealthSupport.Builder#add(org.eclipse.microprofile.health.HealthCheck...)}
|
||||
* {@link io.helidon.health.HealthSupport.Builder#addLiveness(org.eclipse.microprofile.health.HealthCheck...)}
|
||||
* @see #DEFAULT_PATH
|
||||
* @see #DEFAULT_THRESHOLD
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.media.jsonp</groupId>
|
||||
<artifactId>helidon-media-jsonp-server</artifactId>
|
||||
<artifactId>helidon-media-jsonp-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.health</groupId>
|
||||
|
||||
@@ -36,11 +36,14 @@ import javax.json.JsonBuilderFactory;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
|
||||
import io.helidon.common.GenericType;
|
||||
import io.helidon.common.HelidonFeatures;
|
||||
import io.helidon.common.HelidonFlavor;
|
||||
import io.helidon.common.http.Http;
|
||||
import io.helidon.common.reactive.Single;
|
||||
import io.helidon.config.Config;
|
||||
import io.helidon.media.jsonp.server.JsonSupport;
|
||||
import io.helidon.media.jsonp.common.JsonpBodyWriter;
|
||||
import io.helidon.media.jsonp.common.JsonpSupport;
|
||||
import io.helidon.webserver.Routing;
|
||||
import io.helidon.webserver.ServerRequest;
|
||||
import io.helidon.webserver.ServerResponse;
|
||||
@@ -69,6 +72,8 @@ public final class HealthSupport implements Service {
|
||||
|
||||
private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Collections.emptyMap());
|
||||
|
||||
private static final GenericType<JsonObject> JSON_TYPE = GenericType.create(JsonObject.class);
|
||||
|
||||
static {
|
||||
HelidonFeatures.register(HelidonFlavor.SE, FEATURE_NAME);
|
||||
}
|
||||
@@ -83,6 +88,7 @@ public final class HealthSupport implements Service {
|
||||
private final Set<String> excludedHealthChecks;
|
||||
private final boolean backwardCompatible;
|
||||
private final CorsEnabledServiceHelper corsEnabledServiceHelper;
|
||||
private final JsonpBodyWriter jsonpWriter = JsonpSupport.writer();
|
||||
|
||||
private HealthSupport(Builder builder) {
|
||||
this.enabled = builder.enabled;
|
||||
@@ -123,32 +129,28 @@ public final class HealthSupport implements Service {
|
||||
// do not register anything if health check is disabled
|
||||
return;
|
||||
}
|
||||
rules.get(webContext + "[/{*}]", JsonSupport.create())
|
||||
.any(webContext, corsEnabledServiceHelper.processor())
|
||||
rules.any(webContext, corsEnabledServiceHelper.processor())
|
||||
.get(webContext, this::callAll)
|
||||
.get(webContext + "/live", this::callLiveness)
|
||||
.get(webContext + "/ready", this::callReadiness);
|
||||
}
|
||||
|
||||
private void callAll(ServerRequest req, ServerResponse res) {
|
||||
HealthResponse hres = callHealthChecks(allChecks);
|
||||
|
||||
res.status(hres.status());
|
||||
res.send(hres.json);
|
||||
send(res, callHealthChecks(allChecks));
|
||||
}
|
||||
|
||||
private void callLiveness(ServerRequest req, ServerResponse res) {
|
||||
HealthResponse hres = callHealthChecks(livenessChecks);
|
||||
|
||||
res.status(hres.status());
|
||||
res.send(hres.json);
|
||||
send(res, callHealthChecks(livenessChecks));
|
||||
}
|
||||
|
||||
private void callReadiness(ServerRequest req, ServerResponse res) {
|
||||
HealthResponse hres = callHealthChecks(readinessChecks);
|
||||
send(res, callHealthChecks(readinessChecks));
|
||||
}
|
||||
|
||||
private void send(ServerResponse res, HealthResponse hres) {
|
||||
res.status(hres.status());
|
||||
res.send(hres.json);
|
||||
// skip selection process and an additional route configuration by using the writer directly
|
||||
res.send(jsonpWriter.write(Single.just(hres.json), JSON_TYPE, res.writerContext()));
|
||||
}
|
||||
|
||||
HealthResponse callHealthChecks(List<HealthCheck> healthChecks) {
|
||||
@@ -302,7 +304,9 @@ public final class HealthSupport implements Service {
|
||||
* @param healthChecks health check(s) to add
|
||||
* @return updated builder instance
|
||||
* @deprecated use {@link #addReadiness(org.eclipse.microprofile.health.HealthCheck...)} or
|
||||
* {@link #addLiveness(org.eclipse.microprofile.health.HealthCheck...)} instead
|
||||
* {@link #addLiveness(org.eclipse.microprofile.health.HealthCheck...)} instead.
|
||||
* This method is needed until the microprofile specification removes support for generic HealthChecks (which are
|
||||
* already deprecated).
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder add(HealthCheck... healthChecks) {
|
||||
@@ -310,22 +314,6 @@ public final class HealthSupport implements Service {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add health checks to the list.
|
||||
* All health checks would get invoked when this endpoint is called (even when
|
||||
* the result is excluded).
|
||||
*
|
||||
* @param healthChecks health checks to add
|
||||
* @return updated builder instance
|
||||
* @deprecated use {@link #addReadiness(org.eclipse.microprofile.health.HealthCheck...)} or
|
||||
* {@link #addLiveness(org.eclipse.microprofile.health.HealthCheck...)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder add(Collection<HealthCheck> healthChecks) {
|
||||
this.allChecks.addAll(healthChecks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a health check to a white list (in case {@link #includeAll} is set to {@code false}.
|
||||
*
|
||||
@@ -389,15 +377,9 @@ public final class HealthSupport implements Service {
|
||||
public Builder config(Config config) {
|
||||
config.get("enabled").asBoolean().ifPresent(this::enabled);
|
||||
config.get("web-context").asString().ifPresent(this::webContext);
|
||||
config.get("include").asList(String.class).ifPresent(list -> {
|
||||
list.forEach(this::addIncluded);
|
||||
});
|
||||
config.get("exclude").asList(String.class).ifPresent(list -> {
|
||||
list.forEach(this::addExcluded);
|
||||
});
|
||||
config.get("exclude-classes").asList(Class.class).ifPresent(list -> {
|
||||
list.forEach(this::addExcludedClass);
|
||||
});
|
||||
config.get("include").asList(String.class).ifPresent(list -> list.forEach(this::addIncluded));
|
||||
config.get("exclude").asList(String.class).ifPresent(list -> list.forEach(this::addExcluded));
|
||||
config.get("exclude-classes").asList(Class.class).ifPresent(list -> list.forEach(this::addExcludedClass));
|
||||
config.get("backward-compatible").asBoolean().ifPresent(this::backwardCompatible);
|
||||
config.get(CORS_CONFIG_KEY)
|
||||
.as(CrossOriginConfig::create)
|
||||
@@ -420,14 +402,22 @@ public final class HealthSupport implements Service {
|
||||
/**
|
||||
* Add liveness health check(s).
|
||||
*
|
||||
* @param healthCheck a health check to add
|
||||
* @param healthChecks health check(s) to add
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder addLiveness(HealthCheck... healthCheck) {
|
||||
for (HealthCheck check : healthCheck) {
|
||||
this.allChecks.add(check);
|
||||
this.livenessChecks.add(check);
|
||||
}
|
||||
public Builder addLiveness(HealthCheck... healthChecks) {
|
||||
return addLiveness(List.of(healthChecks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add liveness health check(s).
|
||||
*
|
||||
* @param healthChecks health checks to add
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder addLiveness(Collection<HealthCheck> healthChecks) {
|
||||
this.allChecks.addAll(healthChecks);
|
||||
this.livenessChecks.addAll(healthChecks);
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -435,14 +425,22 @@ public final class HealthSupport implements Service {
|
||||
/**
|
||||
* Add readiness health check(s).
|
||||
*
|
||||
* @param healthCheck a health check to add
|
||||
* @param healthChecks health checks to add
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder addReadiness(HealthCheck... healthCheck) {
|
||||
for (HealthCheck check : healthCheck) {
|
||||
this.allChecks.add(check);
|
||||
this.readinessChecks.add(check);
|
||||
}
|
||||
public Builder addReadiness(HealthCheck... healthChecks) {
|
||||
return addReadiness(List.of(healthChecks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add readiness health check(s).
|
||||
*
|
||||
* @param healthChecks health checks to add
|
||||
* @return updated builder instance
|
||||
*/
|
||||
public Builder addReadiness(Collection<HealthCheck> healthChecks) {
|
||||
this.allChecks.addAll(healthChecks);
|
||||
this.readinessChecks.addAll(healthChecks);
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -514,8 +512,8 @@ public final class HealthSupport implements Service {
|
||||
}
|
||||
|
||||
static final class HealthResponse {
|
||||
private Http.ResponseStatus status;
|
||||
private JsonObject json;
|
||||
private final Http.ResponseStatus status;
|
||||
private final JsonObject json;
|
||||
|
||||
private HealthResponse(Http.ResponseStatus status, JsonObject json) {
|
||||
this.status = status;
|
||||
|
||||
@@ -24,7 +24,7 @@ module io.helidon.health {
|
||||
requires transitive microprofile.health.api;
|
||||
requires io.helidon.webserver;
|
||||
requires io.helidon.webserver.cors;
|
||||
requires io.helidon.media.jsonp.server;
|
||||
requires io.helidon.media.jsonp.common;
|
||||
requires java.json;
|
||||
|
||||
exports io.helidon.health;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,7 +96,7 @@ class HealthSupportTest {
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
private void disableJDKLogging() {
|
||||
void disableJDKLogging() {
|
||||
// Disable this logger so that we don't get a bunch of "SEVERE" logs in our test output, which are
|
||||
// a normal thing to happen according to some tests we run. Since this is a global setting in the JVM,
|
||||
// and we are good citizens, we restore it to the WARNING level after the test is done even though
|
||||
@@ -116,7 +116,7 @@ class HealthSupportTest {
|
||||
List<HealthCheck> allChecks,
|
||||
List<String> finalCheckNames) {
|
||||
HealthSupport support = HealthSupport.builder()
|
||||
.add(allChecks)
|
||||
.addLiveness(allChecks)
|
||||
.addExcluded(excludedHealthChecks)
|
||||
.addIncluded(includedHealthChecks)
|
||||
.build();
|
||||
@@ -154,7 +154,7 @@ class HealthSupportTest {
|
||||
new GoodHealthCheck("a"),
|
||||
new GoodHealthCheck("v"));
|
||||
HealthSupport support = HealthSupport.builder()
|
||||
.add(checks)
|
||||
.addLiveness(checks)
|
||||
.build();
|
||||
|
||||
HealthSupport.HealthResponse response = support.callHealthChecks(checks);
|
||||
@@ -170,7 +170,7 @@ class HealthSupportTest {
|
||||
@MethodSource(value = {"goodChecks"})
|
||||
void passingHealthChecksResultInSuccess(List<HealthCheck> goodChecks) {
|
||||
HealthSupport support = HealthSupport.builder()
|
||||
.add(goodChecks)
|
||||
.addLiveness(goodChecks)
|
||||
.build();
|
||||
|
||||
HealthSupport.HealthResponse response = support.callHealthChecks(goodChecks);
|
||||
@@ -188,7 +188,7 @@ class HealthSupportTest {
|
||||
@MethodSource(value = {"badChecks"})
|
||||
void failingHealthChecksResultInFailure(List<HealthCheck> badChecks) {
|
||||
HealthSupport support = HealthSupport.builder()
|
||||
.add(badChecks)
|
||||
.addLiveness(badChecks)
|
||||
.build();
|
||||
|
||||
HealthSupport.HealthResponse response = support.callHealthChecks(badChecks);
|
||||
@@ -206,7 +206,7 @@ class HealthSupportTest {
|
||||
@MethodSource(value = {"brokenChecks"})
|
||||
void brokenHealthChecksResultInFailure(List<HealthCheck> brokenChecks) {
|
||||
HealthSupport support = HealthSupport.builder()
|
||||
.add(brokenChecks)
|
||||
.addLiveness(brokenChecks)
|
||||
.build();
|
||||
|
||||
HealthSupport.HealthResponse response = support.callHealthChecks(brokenChecks);
|
||||
@@ -221,7 +221,7 @@ class HealthSupportTest {
|
||||
}
|
||||
|
||||
private static final class GoodHealthCheck implements HealthCheck {
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private GoodHealthCheck(String name) {
|
||||
this.name = name;
|
||||
@@ -239,7 +239,7 @@ class HealthSupportTest {
|
||||
}
|
||||
|
||||
private static final class BadHealthCheck implements HealthCheck {
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private BadHealthCheck(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.stream.Collectors;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
import javax.enterprise.inject.spi.BeanManager;
|
||||
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
|
||||
import javax.enterprise.inject.spi.CDI;
|
||||
import javax.enterprise.inject.spi.Extension;
|
||||
@@ -50,6 +49,8 @@ import org.eclipse.microprofile.health.Readiness;
|
||||
* Health extension.
|
||||
*/
|
||||
public class HealthCdiExtension implements Extension {
|
||||
// must be used until removed from MP specification
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final Health HEALTH_LITERAL = new Health() {
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
@@ -89,7 +90,7 @@ public class HealthCdiExtension implements Extension {
|
||||
.add(ApplicationScoped.Literal.INSTANCE);
|
||||
}
|
||||
|
||||
void registerHealth(@Observes @Initialized(ApplicationScoped.class) Object adv, BeanManager bm) {
|
||||
void registerHealth(@Observes @Initialized(ApplicationScoped.class) Object adv) {
|
||||
org.eclipse.microprofile.config.Config config = ConfigProvider.getConfig();
|
||||
Config helidonConfig = MpConfig.toHelidonConfig(config).get("health");
|
||||
|
||||
@@ -113,6 +114,8 @@ public class HealthCdiExtension implements Extension {
|
||||
.collect(Collectors.toList()) : Collections.<HealthCheck>emptyList())
|
||||
.orElse(Collections.emptyList());
|
||||
|
||||
// we must use builder.add(HealthCheck) as long as HEALTH_LITERAL can be used
|
||||
//noinspection deprecation
|
||||
cdi.select(HealthCheck.class, HEALTH_LITERAL)
|
||||
.stream()
|
||||
.filter(hc -> !builtInHealthChecks.contains(hc))
|
||||
@@ -130,7 +133,6 @@ public class HealthCdiExtension implements Extension {
|
||||
|
||||
HelidonServiceLoader.create(ServiceLoader.load(HealthCheckProvider.class))
|
||||
.forEach(healthCheckProvider -> {
|
||||
builder.add(healthCheckProvider.healthChecks());
|
||||
healthCheckProvider.livenessChecks().forEach(builder::addLiveness);
|
||||
healthCheckProvider.readinessChecks().forEach(builder::addReadiness);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,15 +29,6 @@ import org.eclipse.microprofile.health.HealthCheck;
|
||||
* {@link HealthCheck} instances are added to the health endpoint.
|
||||
*/
|
||||
public interface HealthCheckProvider {
|
||||
/**
|
||||
* Return the provided {@link org.eclipse.microprofile.health.HealthCheck}s.
|
||||
*
|
||||
* @return the {@link org.eclipse.microprofile.health.HealthCheck}s
|
||||
* @deprecated in the new versions of MP Health, we use either {@link #readinessChecks()} or {@link #livenessChecks()}
|
||||
*/
|
||||
@Deprecated
|
||||
List<HealthCheck> healthChecks();
|
||||
|
||||
/**
|
||||
* Return the provided readiness {@link org.eclipse.microprofile.health.HealthCheck}s.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -184,7 +184,7 @@ public class HealthMpServiceIT {
|
||||
public static class HealthCheckProviderOne
|
||||
implements HealthCheckProvider {
|
||||
@Override
|
||||
public List<HealthCheck> healthChecks() {
|
||||
public List<HealthCheck> livenessChecks() {
|
||||
return Arrays.asList(
|
||||
new HealthCheckStub("Three"),
|
||||
new HealthCheckStub("Four"));
|
||||
@@ -199,7 +199,7 @@ public class HealthMpServiceIT {
|
||||
public static class HealthCheckProviderTwo
|
||||
implements HealthCheckProvider {
|
||||
@Override
|
||||
public List<HealthCheck> healthChecks() {
|
||||
public List<HealthCheck> livenessChecks() {
|
||||
return Arrays.asList(
|
||||
new HealthCheckStub("Five"),
|
||||
new HealthCheckStub("Six"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,7 @@ package io.helidon.webserver.accesslog;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.DataChunk;
|
||||
import io.helidon.webserver.ServerRequest;
|
||||
import io.helidon.webserver.ServerResponse;
|
||||
@@ -52,7 +52,7 @@ public final class SizeLogEntry extends AbstractLogEntry {
|
||||
|
||||
@Override
|
||||
public void accept(ServerRequest req, ServerResponse res) {
|
||||
ContextualRegistry context = req.context();
|
||||
Context context = req.context();
|
||||
res.registerFilter(originalPublisher -> new ByteCountingPublisher(originalPublisher, context));
|
||||
}
|
||||
|
||||
@@ -84,9 +84,9 @@ public final class SizeLogEntry extends AbstractLogEntry {
|
||||
|
||||
private static final class ByteCountingPublisher implements Flow.Publisher<DataChunk> {
|
||||
private final Flow.Publisher<DataChunk> originalPublisher;
|
||||
private final ContextualRegistry context;
|
||||
private final Context context;
|
||||
|
||||
private ByteCountingPublisher(Flow.Publisher<DataChunk> originalPublisher, ContextualRegistry context) {
|
||||
private ByteCountingPublisher(Flow.Publisher<DataChunk> originalPublisher, Context context) {
|
||||
this.originalPublisher = originalPublisher;
|
||||
this.context = context;
|
||||
}
|
||||
@@ -99,10 +99,10 @@ public final class SizeLogEntry extends AbstractLogEntry {
|
||||
|
||||
private static final class ByteCountingSubscriber implements Flow.Subscriber<DataChunk> {
|
||||
private final Flow.Subscriber<? super DataChunk> subscriber;
|
||||
private final ContextualRegistry context;
|
||||
private final Context context;
|
||||
private final LongAdder sizeAdder = new LongAdder();
|
||||
|
||||
private ByteCountingSubscriber(Flow.Subscriber<? super DataChunk> subscriber, ContextualRegistry context) {
|
||||
private ByteCountingSubscriber(Flow.Subscriber<? super DataChunk> subscriber, Context context) {
|
||||
this.subscriber = subscriber;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.Http;
|
||||
import io.helidon.common.http.HttpRequest;
|
||||
import io.helidon.webserver.RequestHeaders;
|
||||
@@ -55,7 +55,7 @@ class AccessLogSupportTest {
|
||||
AccessLogSupport accessLog = AccessLogSupport.create();
|
||||
|
||||
ServerRequest request = mock(ServerRequest.class);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
Context context = Context.create();
|
||||
when(request.remoteAddress()).thenReturn(REMOTE_IP);
|
||||
when(request.context()).thenReturn(context);
|
||||
when(request.method()).thenReturn(Http.Method.PUT);
|
||||
@@ -93,7 +93,7 @@ class AccessLogSupportTest {
|
||||
.build();
|
||||
|
||||
ServerRequest request = mock(ServerRequest.class);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
Context context = Context.create();
|
||||
when(request.remoteAddress()).thenReturn(REMOTE_IP);
|
||||
when(request.context()).thenReturn(context);
|
||||
when(request.method()).thenReturn(Http.Method.PUT);
|
||||
@@ -132,7 +132,7 @@ class AccessLogSupportTest {
|
||||
.build();
|
||||
|
||||
ServerRequest request = mock(ServerRequest.class);
|
||||
ContextualRegistry context = ContextualRegistry.create();
|
||||
Context context = Context.create();
|
||||
when(request.remoteAddress()).thenReturn(REMOTE_IP);
|
||||
when(request.context()).thenReturn(context);
|
||||
when(request.method()).thenReturn(Http.Method.PUT);
|
||||
|
||||
@@ -85,18 +85,6 @@ public class JerseySupport implements Service {
|
||||
|
||||
private static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
|
||||
|
||||
/**
|
||||
* The request scoped span qualifier that can be injected into a Jersey resource.
|
||||
* <pre><code>
|
||||
* {@literal @}Inject{@literal @}Named(JerseySupport.REQUEST_SPAN_QUALIFIER)
|
||||
* private Span span;
|
||||
* </code></pre>
|
||||
*
|
||||
* @deprecated Use span context ({@link #REQUEST_SPAN_CONTEXT}) instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String REQUEST_SPAN_QUALIFIER = "request-parent-span";
|
||||
|
||||
/**
|
||||
* The request scoped span context qualifier that can be injected into a Jersey resource.
|
||||
* <pre><code>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,28 +42,24 @@ class WebServerBinder extends AbstractBinder {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindFactory(WebServerRequestReferencingFactory.class).to(ServerRequest.class)
|
||||
.proxy(false)
|
||||
.in(RequestScoped.class);
|
||||
.proxy(false)
|
||||
.in(RequestScoped.class);
|
||||
bindFactory(ReferencingFactory.<ServerRequest>referenceFactory()).to(new GenericType<Ref<ServerRequest>>() { })
|
||||
.in(RequestScoped.class);
|
||||
.in(RequestScoped.class);
|
||||
|
||||
bindFactory(WebServerResponseReferencingFactory.class).to(ServerResponse.class)
|
||||
.proxy(true).proxyForSameScope(false)
|
||||
.in(RequestScoped.class);
|
||||
.proxy(true).proxyForSameScope(false)
|
||||
.in(RequestScoped.class);
|
||||
bindFactory(ReferencingFactory.<ServerResponse>referenceFactory()).to(new GenericType<Ref<ServerResponse>>() { })
|
||||
.in(RequestScoped.class);
|
||||
|
||||
bindFactory(SpanReferencingFactory.class).to(Span.class)
|
||||
.proxy(false)
|
||||
.in(RequestScoped.class).named(JerseySupport.REQUEST_SPAN_QUALIFIER);
|
||||
.in(RequestScoped.class);
|
||||
bindFactory(SpanContextReferencingFactory.class).to(SpanContext.class)
|
||||
.proxy(false)
|
||||
.in(RequestScoped.class).named(JerseySupport.REQUEST_SPAN_CONTEXT);
|
||||
.proxy(false)
|
||||
.in(RequestScoped.class).named(JerseySupport.REQUEST_SPAN_CONTEXT);
|
||||
|
||||
bindFactory(ReferencingFactory.<Span>referenceFactory()).to(new GenericType<Ref<Span>>() { })
|
||||
.in(RequestScoped.class);
|
||||
.in(RequestScoped.class);
|
||||
bindFactory(ReferencingFactory.<SpanContext>referenceFactory()).to(new GenericType<Ref<SpanContext>>() { })
|
||||
.in(RequestScoped.class);
|
||||
.in(RequestScoped.class);
|
||||
}
|
||||
|
||||
private static class WebServerRequestReferencingFactory extends ReferencingFactory<ServerRequest> {
|
||||
@@ -82,15 +78,6 @@ class WebServerBinder extends AbstractBinder {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static class SpanReferencingFactory extends ReferencingFactory<Span> {
|
||||
|
||||
@Inject
|
||||
SpanReferencingFactory(final Provider<Ref<Span>> referenceFactory) {
|
||||
super(referenceFactory);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SpanContextReferencingFactory extends ReferencingFactory<SpanContext> {
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.helidon.webserver.testsupport;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.reactive.Single;
|
||||
import io.helidon.media.common.MediaContext;
|
||||
import io.helidon.media.common.MessageBodyReaderContext;
|
||||
@@ -35,7 +35,7 @@ class TestWebServer implements WebServer {
|
||||
|
||||
private final CompletableFuture<WebServer> startFuture = new CompletableFuture<>();
|
||||
private final CompletableFuture<WebServer> shutdownFuture = new CompletableFuture<>();
|
||||
private final ContextualRegistry context = ContextualRegistry.create();
|
||||
private final Context context = Context.create();
|
||||
private final ServerConfiguration configuration = ServerConfiguration.builder().build();
|
||||
private final MediaContext mediaContext;
|
||||
|
||||
@@ -82,7 +82,7 @@ class TestWebServer implements WebServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextualRegistry context() {
|
||||
public Context context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class NettyWebServer implements WebServer {
|
||||
private final CompletableFuture<WebServer> channelsUpFuture = new CompletableFuture<>();
|
||||
private final CompletableFuture<WebServer> channelsCloseFuture = new CompletableFuture<>();
|
||||
private final CompletableFuture<WebServer> threadGroupsShutdownFuture = new CompletableFuture<>();
|
||||
private final io.helidon.common.http.ContextualRegistry contextualRegistry;
|
||||
private final Context contextualRegistry;
|
||||
private final ConcurrentMap<String, Channel> channels = new ConcurrentHashMap<>();
|
||||
private final List<HttpInitializer> initializers = new LinkedList<>();
|
||||
private final MessageBodyWriterContext writerContext;
|
||||
@@ -105,14 +105,7 @@ class NettyWebServer implements WebServer {
|
||||
HelidonFeatures.print(HelidonFlavor.SE, config.printFeatureDetails());
|
||||
this.bossGroup = new NioEventLoopGroup(sockets.size());
|
||||
this.workerGroup = config.workersCount() <= 0 ? new NioEventLoopGroup() : new NioEventLoopGroup(config.workersCount());
|
||||
// the contextual registry needs to be created as a different type is expected. Once we remove ContextualRegistry
|
||||
// we can simply use the one from config
|
||||
Context context = config.context();
|
||||
if (context instanceof io.helidon.common.http.ContextualRegistry) {
|
||||
this.contextualRegistry = (io.helidon.common.http.ContextualRegistry) context;
|
||||
} else {
|
||||
this.contextualRegistry = io.helidon.common.http.ContextualRegistry.create(config.context());
|
||||
}
|
||||
this.contextualRegistry = config.context();
|
||||
this.configuration = config;
|
||||
this.readerContext = MessageBodyReaderContext.create(readerContext);
|
||||
this.writerContext = MessageBodyWriterContext.create(writerContext);
|
||||
@@ -220,7 +213,7 @@ class NettyWebServer implements WebServer {
|
||||
throw new IllegalStateException(
|
||||
"no socket configuration found for name: " + name);
|
||||
}
|
||||
int port = socketConfig.port() <= 0 ? 0 : socketConfig.port();
|
||||
int port = Math.max(socketConfig.port(), 0);
|
||||
if (channelsUpFuture.isCompletedExceptionally()) {
|
||||
// break because one of the previous channels already failed
|
||||
break;
|
||||
@@ -397,7 +390,7 @@ class NettyWebServer implements WebServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public io.helidon.common.http.ContextualRegistry context() {
|
||||
public Context context() {
|
||||
return contextualRegistry;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import io.helidon.common.GenericType;
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.Http;
|
||||
import io.helidon.common.http.MediaType;
|
||||
import io.helidon.common.http.Parameters;
|
||||
@@ -57,7 +58,7 @@ abstract class Request implements ServerRequest {
|
||||
|
||||
private final BareRequest bareRequest;
|
||||
private final WebServer webServer;
|
||||
private final io.helidon.common.http.ContextualRegistry context;
|
||||
private final Context context;
|
||||
private final Parameters queryParams;
|
||||
private final HashRequestHeaders headers;
|
||||
private final MessageBodyReadableContent content;
|
||||
@@ -73,7 +74,7 @@ abstract class Request implements ServerRequest {
|
||||
this.bareRequest = req;
|
||||
this.webServer = webServer;
|
||||
this.headers = headers;
|
||||
this.context = io.helidon.common.http.ContextualRegistry.create(webServer.context());
|
||||
this.context = Context.create(webServer.context());
|
||||
this.queryParams = UriComponent.decodeQuery(req.uri().getRawQuery(), true);
|
||||
this.eventListener = new MessageBodyEventListener();
|
||||
MessageBodyReaderContext readerContext = MessageBodyReaderContext
|
||||
@@ -104,10 +105,10 @@ abstract class Request implements ServerRequest {
|
||||
*/
|
||||
static Charset contentCharset(ServerRequest request) {
|
||||
return request.headers()
|
||||
.contentType()
|
||||
.flatMap(MediaType::charset)
|
||||
.map(Charset::forName)
|
||||
.orElse(DEFAULT_CHARSET);
|
||||
.contentType()
|
||||
.flatMap(MediaType::charset)
|
||||
.map(Charset::forName)
|
||||
.orElse(DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,8 +117,7 @@ abstract class Request implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public io.helidon.common.http.ContextualRegistry context() {
|
||||
public Context context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ abstract class Request implements ServerRequest {
|
||||
|
||||
private Span readSpan;
|
||||
|
||||
private <T> Span createReadSpan(GenericType<?> type) {
|
||||
private Span createReadSpan(GenericType<?> type) {
|
||||
// only create this span if we have a parent span
|
||||
SpanContext parentSpan = spanContext();
|
||||
if (null == parentSpan) {
|
||||
@@ -226,29 +226,29 @@ abstract class Request implements ServerRequest {
|
||||
@Override
|
||||
public void onEvent(MessageBodyContext.Event event) {
|
||||
switch (event.eventType()) {
|
||||
case BEFORE_ONSUBSCRIBE:
|
||||
GenericType<?> type = event.entityType().orElse(null);
|
||||
readSpan = createReadSpan(type);
|
||||
break;
|
||||
case BEFORE_ONSUBSCRIBE:
|
||||
GenericType<?> type = event.entityType().orElse(null);
|
||||
readSpan = createReadSpan(type);
|
||||
break;
|
||||
|
||||
case AFTER_ONERROR:
|
||||
if (readSpan != null) {
|
||||
Tags.ERROR.set(readSpan, Boolean.TRUE);
|
||||
Throwable ex = event.asErrorEvent().error();
|
||||
readSpan.log(Map.of("event", "error",
|
||||
"error.kind", "Exception",
|
||||
"error.object", ex,
|
||||
"message", ex.toString()));
|
||||
readSpan.finish();
|
||||
}
|
||||
break;
|
||||
case AFTER_ONCOMPLETE:
|
||||
if (readSpan != null) {
|
||||
readSpan.finish();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
case AFTER_ONERROR:
|
||||
if (readSpan != null) {
|
||||
Tags.ERROR.set(readSpan, Boolean.TRUE);
|
||||
Throwable ex = event.asErrorEvent().error();
|
||||
readSpan.log(Map.of("event", "error",
|
||||
"error.kind", "Exception",
|
||||
"error.object", ex,
|
||||
"message", ex.toString()));
|
||||
readSpan.finish();
|
||||
}
|
||||
break;
|
||||
case AFTER_ONCOMPLETE:
|
||||
if (readSpan != null) {
|
||||
readSpan.finish();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,7 @@ abstract class Request implements ServerRequest {
|
||||
return absolutePath == null ? this : absolutePath;
|
||||
}
|
||||
|
||||
static Path create(Path contextual, String path, Map<String, String> params) {
|
||||
static Path create(Path contextual, String path, Map<String, String> params) {
|
||||
return create(contextual, path, path, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,6 @@ import java.util.Set;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
|
||||
import io.opentracing.Tracer;
|
||||
|
||||
@@ -39,7 +38,7 @@ class ServerBasicConfig implements ServerConfiguration {
|
||||
private final Tracer tracer;
|
||||
private final Map<String, SocketConfiguration> socketConfigs;
|
||||
private final ExperimentalConfiguration experimental;
|
||||
private final ContextualRegistry context;
|
||||
private final Context context;
|
||||
private final boolean printFeatureDetails;
|
||||
|
||||
/**
|
||||
@@ -56,7 +55,7 @@ class ServerBasicConfig implements ServerConfiguration {
|
||||
this.printFeatureDetails = builder.printFeatureDetails();
|
||||
|
||||
HashMap<String, SocketConfiguration> map = new HashMap<>(builder.sockets());
|
||||
map.put(ServerConfiguration.DEFAULT_SOCKET_NAME, this.socketConfig);
|
||||
map.put(WebServer.DEFAULT_SOCKET_NAME, this.socketConfig);
|
||||
this.socketConfigs = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.logging.Logger;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.config.Config;
|
||||
import io.helidon.config.ConfigException;
|
||||
import io.helidon.config.DeprecatedConfig;
|
||||
@@ -48,7 +47,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
* The default server socket configuration name. All the default server socket
|
||||
* configuration (e.g., {@link #port()} or {@link #backlog()}) is accessible through
|
||||
* {@link #socket(String)} or {@link #sockets()} with this
|
||||
* {@link #DEFAULT_SOCKET_NAME default socket name}.
|
||||
* {@link io.helidon.webserver.WebServer#DEFAULT_SOCKET_NAME default socket name}.
|
||||
*
|
||||
* @deprecated since 2.0.0, please use {@link WebServer#DEFAULT_SOCKET_NAME}
|
||||
*/
|
||||
@@ -269,7 +268,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
private int workers;
|
||||
private Tracer tracer;
|
||||
private ExperimentalConfiguration experimental;
|
||||
private ContextualRegistry context;
|
||||
private Context context;
|
||||
private boolean printFeatureDetails;
|
||||
|
||||
private Builder() {
|
||||
@@ -505,11 +504,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
* @return an updated builder
|
||||
*/
|
||||
public Builder context(Context context) {
|
||||
// backward compatibility only - in 2.0 we should use the context given to us
|
||||
this.context = ContextualRegistry.builder()
|
||||
.id(context.id() + ":web-" + WEBSERVER_COUNTER.getAndIncrement())
|
||||
.parent(context)
|
||||
.build();
|
||||
this.context = context;
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -610,7 +605,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
// I do not expect "unlimited" number of webservers
|
||||
// in case somebody spins a huge number up, the counter will cycle to negative numbers once
|
||||
// Integer.MAX_VALUE is reached.
|
||||
context = ContextualRegistry.builder()
|
||||
context = Context.builder()
|
||||
.id("web-" + WEBSERVER_COUNTER.getAndIncrement())
|
||||
.build();
|
||||
}
|
||||
@@ -656,7 +651,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
return experimental;
|
||||
}
|
||||
|
||||
ContextualRegistry context() {
|
||||
Context context() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.helidon.webserver;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.HttpRequest;
|
||||
import io.helidon.media.common.MessageBodyReadableContent;
|
||||
|
||||
@@ -60,8 +61,7 @@ public interface ServerRequest extends HttpRequest {
|
||||
*
|
||||
* @return a request context
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
io.helidon.common.http.ContextualRegistry context();
|
||||
Context context();
|
||||
|
||||
/**
|
||||
* Returns the Internet Protocol (IP) address of the interface on which the request was received.
|
||||
|
||||
@@ -106,8 +106,7 @@ public interface WebServer {
|
||||
*
|
||||
* @return a server context
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
io.helidon.common.http.ContextualRegistry context();
|
||||
Context context();
|
||||
|
||||
/**
|
||||
* Get the parent {@link MessageBodyReaderContext} context.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package io.helidon.webserver;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.helidon.common.http.ContextualRegistry;
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.Http;
|
||||
import io.helidon.common.reactive.Single;
|
||||
|
||||
@@ -128,7 +128,7 @@ public class RoutingTest {
|
||||
doReturn(method).when(bareRequestMock).method();
|
||||
doReturn(Single.empty()).when(bareRequestMock).bodyPublisher();
|
||||
WebServer webServerMock = mock(WebServer.class);
|
||||
when(webServerMock.context()).thenReturn(ContextualRegistry.create());
|
||||
when(webServerMock.context()).thenReturn(Context.create());
|
||||
doReturn(webServerMock).when(bareRequestMock).webServer();
|
||||
return bareRequestMock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user