diff --git a/bom/pom.xml b/bom/pom.xml index 0f6589046..abb7ce59b 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -776,11 +776,6 @@ helidon-integrations-cdi-jpa ${helidon.version} - - io.helidon.integrations.cdi - helidon-integrations-cdi-jpa-weld - ${helidon.version} - io.helidon.integrations.cdi helidon-integrations-cdi-jta diff --git a/common/configurable/src/main/java/io/helidon/common/configurable/Resource.java b/common/configurable/src/main/java/io/helidon/common/configurable/Resource.java index 00b61f6f7..f513de6c9 100644 --- a/common/configurable/src/main/java/io/helidon/common/configurable/Resource.java +++ b/common/configurable/src/main/java/io/helidon/common/configurable/Resource.java @@ -167,7 +167,7 @@ public interface Resource { * @param config configuration * @param prefix prefix of the resource * @return resource if configured - * @deprecated use {@link #create(io.helidon.config.Config)} instead (and change the configuration to use + * @deprecated since 2.0.0 use {@link #create(io.helidon.config.Config)} instead (and change the configuration to use * {@code .resource.type} instead of prefixes */ @Deprecated diff --git a/common/http/src/main/java/io/helidon/common/http/Content.java b/common/http/src/main/java/io/helidon/common/http/Content.java index 064f192d4..acc70dc6b 100644 --- a/common/http/src/main/java/io/helidon/common/http/Content.java +++ b/common/http/src/main/java/io/helidon/common/http/Content.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -41,7 +41,7 @@ import io.helidon.common.reactive.Single; * It is possible to register function to convert publisher to {@link io.helidon.common.reactive.Single} of a single entity using * {@link #registerReader(Class, Reader)} or {@link #registerReader(Predicate, Reader)} methods. It * is then possible to use {@link #as(Class)} method to obtain such entity. - * @deprecated use {@code io.helidon.media.common.MessageBodyReadableContent} instead + * @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReadableContent} instead */ @Deprecated public interface Content extends Flow.Publisher { @@ -73,7 +73,7 @@ public interface Content extends Flow.Publisher { * * @param function a function that transforms a given publisher (that is either the original * publisher or the publisher transformed by the last previously registered filter). - * @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerFilter} + * @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerFilter} */ @Deprecated void registerFilter(Function, Flow.Publisher> function); @@ -93,7 +93,7 @@ public interface Content extends Flow.Publisher { * If an exception is thrown, the resulting completion stage of * {@link #as(Class)} method call ends exceptionally. * @param the requested type - * @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader} + * @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader} */ @Deprecated void registerReader(Class type, Reader reader); @@ -116,7 +116,7 @@ public interface Content extends Flow.Publisher { * If an exception is thrown, the resulting completion stage of * {@link #as(Class)} method call ends exceptionally. * @param the requested type - * @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader} + * @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader} */ @Deprecated void registerReader(Predicate> predicate, Reader reader); diff --git a/common/http/src/main/java/io/helidon/common/http/Reader.java b/common/http/src/main/java/io/helidon/common/http/Reader.java index 9e01f4d8f..1932aeb00 100644 --- a/common/http/src/main/java/io/helidon/common/http/Reader.java +++ b/common/http/src/main/java/io/helidon/common/http/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -24,7 +24,7 @@ import java.util.function.BiFunction; * The Reader transforms a {@link DataChunk} publisher into a completion stage of the associated type. * * @param the requested type - * @deprecated use {@code io.helidon.media.common.MessageBodyReader} instead + * @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReader} instead */ @FunctionalInterface @Deprecated diff --git a/dbclient/jdbc/src/main/java/io/helidon/dbclient/jdbc/JdbcStatement.java b/dbclient/jdbc/src/main/java/io/helidon/dbclient/jdbc/JdbcStatement.java index 445a38914..0d0f3f116 100644 --- a/dbclient/jdbc/src/main/java/io/helidon/dbclient/jdbc/JdbcStatement.java +++ b/dbclient/jdbc/src/main/java/io/helidon/dbclient/jdbc/JdbcStatement.java @@ -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. @@ -78,28 +78,6 @@ abstract class JdbcStatement, R> extends AbstractSta } } - /** - * Switch to {@link #build(java.sql.Connection, io.helidon.dbclient.DbClientServiceContext)} and use services. - * - * @param connection connection to use - * @return prepared statement - */ - @Deprecated - protected PreparedStatement build(Connection connection) { - LOGGER.fine(() -> String.format("Building SQL statement: %s", statement())); - switch (paramType()) { - // Statement may not contain any parameters, no conversion is needed. - case UNKNOWN: - return prepareStatement(connection, statementName(), statement()); - case INDEXED: - return prepareIndexedStatement(connection, statementName(), statement(), indexedParams()); - case NAMED: - return prepareNamedStatement(connection, statementName(), statement(), namedParams()); - default: - throw new IllegalStateException("Unknown SQL statement type"); - } - } - @Override protected String dbType() { return dbType; diff --git a/examples/dbclient/jdbc/src/main/resources/logging.properties b/examples/dbclient/jdbc/src/main/resources/logging.properties index 3120aaf00..a3b94c39c 100644 --- a/examples/dbclient/jdbc/src/main/resources/logging.properties +++ b/examples/dbclient/jdbc/src/main/resources/logging.properties @@ -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. @@ -18,15 +18,14 @@ # For more information see $JAVA_HOME/jre/lib/logging.properties # Send messages to the console -handlers=java.util.logging.ConsoleHandler +handlers=io.helidon.common.HelidonConsoleHandler # Global default logging level. Can be overriden by specific handlers and loggers .level=INFO # Helidon Web Server has a custom log formatter that extends SimpleFormatter. # It replaces "!thread!" with the current thread name -java.util.logging.ConsoleHandler.level=INFO -java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter +io.helidon.common.HelidonConsoleHandler.level=ALL java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n #Component specific log levels diff --git a/examples/dbclient/mongodb/src/main/resources/logging.properties b/examples/dbclient/mongodb/src/main/resources/logging.properties index 3120aaf00..a3b94c39c 100644 --- a/examples/dbclient/mongodb/src/main/resources/logging.properties +++ b/examples/dbclient/mongodb/src/main/resources/logging.properties @@ -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. @@ -18,15 +18,14 @@ # For more information see $JAVA_HOME/jre/lib/logging.properties # Send messages to the console -handlers=java.util.logging.ConsoleHandler +handlers=io.helidon.common.HelidonConsoleHandler # Global default logging level. Can be overriden by specific handlers and loggers .level=INFO # Helidon Web Server has a custom log formatter that extends SimpleFormatter. # It replaces "!thread!" with the current thread name -java.util.logging.ConsoleHandler.level=INFO -java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter +io.helidon.common.HelidonConsoleHandler.level=ALL java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n #Component specific log levels diff --git a/examples/dbclient/pokemons/src/main/resources/logging.properties b/examples/dbclient/pokemons/src/main/resources/logging.properties index 3120aaf00..a3b94c39c 100644 --- a/examples/dbclient/pokemons/src/main/resources/logging.properties +++ b/examples/dbclient/pokemons/src/main/resources/logging.properties @@ -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. @@ -18,15 +18,14 @@ # For more information see $JAVA_HOME/jre/lib/logging.properties # Send messages to the console -handlers=java.util.logging.ConsoleHandler +handlers=io.helidon.common.HelidonConsoleHandler # Global default logging level. Can be overriden by specific handlers and loggers .level=INFO # Helidon Web Server has a custom log formatter that extends SimpleFormatter. # It replaces "!thread!" with the current thread name -java.util.logging.ConsoleHandler.level=INFO -java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter +io.helidon.common.HelidonConsoleHandler.level=ALL java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n #Component specific log levels diff --git a/examples/grpc/security-abac/src/main/java/io/helidon/grpc/examples/security/abac/AtnProvider.java b/examples/grpc/security-abac/src/main/java/io/helidon/grpc/examples/security/abac/AtnProvider.java index eada2adea..0b2e8a27e 100644 --- a/examples/grpc/security-abac/src/main/java/io/helidon/grpc/examples/security/abac/AtnProvider.java +++ b/examples/grpc/security-abac/src/main/java/io/helidon/grpc/examples/security/abac/AtnProvider.java @@ -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. @@ -99,12 +99,13 @@ public class AtnProvider extends SynchronousProvider implements AuthenticationPr } private List fromAnnotations(EndpointConfig endpointConfig) { - return endpointConfig.combineAnnotations(Authentications.class, EndpointConfig.AnnotationScope.METHOD) - .stream() - .map(Authentications::value) - .flatMap(Arrays::stream) - .map(Auth::new) - .collect(Collectors.toList()); + return endpointConfig.securityLevels() + .stream() + .flatMap(level -> level.combineAnnotations(Authentications.class, EndpointConfig.AnnotationScope.METHOD).stream()) + .map(Authentications::value) + .flatMap(Arrays::stream) + .map(Auth::new) + .collect(Collectors.toList()); } private Subject buildSubject(Auth authentication) { diff --git a/examples/security/spi-examples/src/test/java/io/helidon/security/examples/spi/AtnProviderSyncTest.java b/examples/security/spi-examples/src/test/java/io/helidon/security/examples/spi/AtnProviderSyncTest.java index d4f7d18d0..7bc45249f 100644 --- a/examples/security/spi-examples/src/test/java/io/helidon/security/examples/spi/AtnProviderSyncTest.java +++ b/examples/security/spi-examples/src/test/java/io/helidon/security/examples/spi/AtnProviderSyncTest.java @@ -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. @@ -30,6 +30,7 @@ import io.helidon.security.ProviderRequest; import io.helidon.security.Security; import io.helidon.security.SecurityContext; import io.helidon.security.SecurityEnvironment; +import io.helidon.security.SecurityLevel; import io.helidon.security.SecurityResponse; import io.helidon.security.Subject; @@ -93,9 +94,13 @@ public class AtnProviderSyncTest { when(context.service()).thenReturn(Optional.empty()); SecurityEnvironment se = SecurityEnvironment.create(); + + SecurityLevel level = SecurityLevel.create("mock") + .withClassAnnotations(Map.of(AtnProviderSync.AtnAnnot.class, List.of(annot))) + .build(); + EndpointConfig ep = EndpointConfig.builder() - .annotations(EndpointConfig.AnnotationScope.CLASS, - Map.of(AtnProviderSync.AtnAnnot.class, List.of(annot))) + .securityLevels(List.of(level)) .build(); ProviderRequest request = mock(ProviderRequest.class); diff --git a/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/BackendServiceClient.java b/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/BackendServiceClient.java index 211fedaff..c5502519c 100644 --- a/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/BackendServiceClient.java +++ b/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/BackendServiceClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 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. @@ -89,7 +89,6 @@ public final class BackendServiceClient { * @return future with all records */ public CompletionStage getAll(final SpanContext spanContext) { - Span span = tracer.buildSpan("todos.get-all") .asChildOf(spanContext) .start(); diff --git a/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/TodosHandler.java b/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/TodosHandler.java index 7f6fd5bbb..81d568dcd 100644 --- a/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/TodosHandler.java +++ b/examples/todo-app/frontend/src/main/java/io/helidon/demo/todos/frontend/TodosHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -17,6 +17,7 @@ package io.helidon.demo.todos.frontend; import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import javax.json.JsonObject; @@ -30,6 +31,8 @@ import io.helidon.webserver.ServerRequest; import io.helidon.webserver.ServerResponse; import io.helidon.webserver.Service; +import io.opentracing.Span; +import io.opentracing.SpanContext; import org.eclipse.microprofile.metrics.Counter; import org.eclipse.microprofile.metrics.Metadata; import org.eclipse.microprofile.metrics.MetricRegistry; @@ -135,10 +138,23 @@ public final class TodosHandler implements Service { * @param res the server response */ private void getAll(final ServerRequest req, final ServerResponse res) { + AtomicReference createdSpan = new AtomicReference<>(); + + SpanContext spanContext = req.spanContext().orElseGet(() -> { + Span mySpan = req.tracer().buildSpan("getAll").start(); + createdSpan.set(mySpan); + return mySpan.context(); + }); secure(req, res, sc -> { - bsc.getAll(req.spanContext()) + bsc.getAll(spanContext) .thenAccept(res::send) - .exceptionally(t -> sendError(t, res)); + .exceptionally(t -> sendError(t, res)) + .whenComplete((noting, throwable) -> { + Span mySpan = createdSpan.get(); + if (null != mySpan) { + mySpan.finish(); + } + }); }); } diff --git a/examples/translator-app/frontend/src/main/java/io/helidon/examples/translator/frontend/TranslatorFrontendService.java b/examples/translator-app/frontend/src/main/java/io/helidon/examples/translator/frontend/TranslatorFrontendService.java index d943652e3..641bb7f77 100644 --- a/examples/translator-app/frontend/src/main/java/io/helidon/examples/translator/frontend/TranslatorFrontendService.java +++ b/examples/translator-app/frontend/src/main/java/io/helidon/examples/translator/frontend/TranslatorFrontendService.java @@ -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. @@ -57,10 +57,11 @@ public final class TranslatorFrontendService implements Service { Response backendResponse = backendTarget .property(ClientTracingFilter.TRACER_PROPERTY_NAME, request.tracer()) - .property(ClientTracingFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, request.spanContext()) + .property(ClientTracingFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, request.spanContext().orElse(null)) .queryParam("q", query) .queryParam("lang", language) - .request().get(); + .request() + .get(); final String result; if (backendResponse.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { diff --git a/grpc/server/src/main/java/io/helidon/grpc/server/TracingConfiguration.java b/grpc/server/src/main/java/io/helidon/grpc/server/TracingConfiguration.java deleted file mode 100644 index 575e827a2..000000000 --- a/grpc/server/src/main/java/io/helidon/grpc/server/TracingConfiguration.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 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.grpc.server; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import io.opentracing.contrib.grpc.OperationNameConstructor; - -/** - * Backward compatibility only. - * @deprecated use {@link io.helidon.grpc.server.GrpcTracingConfig} - */ -@Deprecated -public class TracingConfiguration extends GrpcTracingConfig { - private TracingConfiguration(OperationNameConstructor operationNameConstructor, - Set tracedAttributes, - boolean streaming, - boolean verbose) { - super(operationNameConstructor, tracedAttributes, streaming, verbose); - } - - /** - * Builds the configuration of a tracer. - * @deprecated use {@link GrpcTracingConfig#builder()} instead - */ - @Deprecated - public static class Builder { - /** - * Creates a Builder with default configuration. - */ - Builder() { - operationNameConstructor = OperationNameConstructor.DEFAULT; - streaming = false; - verbose = false; - tracedAttributes = Collections.emptySet(); - } - - /** - * @param operationNameConstructor for all spans - * @return this Builder with configured operation name - */ - public Builder withOperationName(OperationNameConstructor operationNameConstructor) { - this.operationNameConstructor = operationNameConstructor; - return this; - } - - /** - * @param attributes to set as tags on server spans - * @return this Builder configured to trace request - * attributes - */ - public Builder withTracedAttributes(ServerRequestAttribute... attributes) { - tracedAttributes = new HashSet<>(Arrays.asList(attributes)); - return this; - } - - /** - * Logs streaming events to server spans. - * - * @return this Builder configured to log streaming events - */ - public Builder withStreaming() { - streaming = true; - return this; - } - - /** - * Logs all request life-cycle events to server spans. - * - * @return this Builder configured to be verbose - */ - public Builder withVerbosity() { - verbose = true; - return this; - } - - /** - * @return a GrpcTracingConfig with this Builder's configuration - */ - public TracingConfiguration build() { - return new TracingConfiguration(operationNameConstructor, tracedAttributes, streaming, verbose); - } - - /** - * A flag indicating whether to log streaming. - */ - private OperationNameConstructor operationNameConstructor; - - /** - * A flag indicating verbose logging. - */ - private boolean streaming; - - /** - * A flag indicating verbose logging. - */ - private boolean verbose; - - /** - * The set of attributes to log in spans. - */ - private Set tracedAttributes; - } -} diff --git a/grpc/server/src/test/java/io/helidon/grpc/server/GrpcServerConfigurationTest.java b/grpc/server/src/test/java/io/helidon/grpc/server/GrpcServerConfigurationTest.java index 92064e833..a308ec740 100644 --- a/grpc/server/src/test/java/io/helidon/grpc/server/GrpcServerConfigurationTest.java +++ b/grpc/server/src/test/java/io/helidon/grpc/server/GrpcServerConfigurationTest.java @@ -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. @@ -170,16 +170,6 @@ public class GrpcServerConfigurationTest { assertThat(configuration.tracingConfig(), is(sameInstance(tracingConfig))); } - @Test - public void shouldSetTracingConfigurationOldConfig() { - TracingConfiguration tracingConfig = mock(TracingConfiguration.class); - GrpcServerConfiguration configuration = GrpcServerConfiguration.builder() - .tracingConfig(tracingConfig) - .build(); - - assertThat(configuration.tracingConfig(), is(sameInstance(tracingConfig))); - } - @Test public void shouldNotSetNullTracingConfiguration() { GrpcServerConfiguration configuration = GrpcServerConfiguration.builder() diff --git a/integrations/cdi/jpa-cdi/src/main/java/io/helidon/integrations/cdi/jpa/PersistenceUnitInfoBean.java b/integrations/cdi/jpa-cdi/src/main/java/io/helidon/integrations/cdi/jpa/PersistenceUnitInfoBean.java index 13da74d82..6e9fda5af 100644 --- a/integrations/cdi/jpa-cdi/src/main/java/io/helidon/integrations/cdi/jpa/PersistenceUnitInfoBean.java +++ b/integrations/cdi/jpa-cdi/src/main/java/io/helidon/integrations/cdi/jpa/PersistenceUnitInfoBean.java @@ -739,159 +739,6 @@ public class PersistenceUnitInfoBean implements PersistenceUnitInfo { * Static methods. */ - - /** - * Given a {@link Persistence} (a Java object representation of a - * {@code META-INF/persistence.xml} resource), a {@link URL} - * representing the root of all persistence units, a {@link Map} - * of unlisted managed classes (entity classes, mapped - * superclasses and so on) indexed by persistence unit name, and a - * {@link DataSourceProvider} that can provide {@link DataSource} - * instances, returns a {@link Collection} of {@link - * PersistenceUnitInfoBean} instances representing all the - * persistence units in play. - * - *

This method never returns {@code null}.

- * - * @param persistence a {@link Persistence} containing bootstrap - * information from which persistence units and their - * configuration may be deduced; may be {@code null} in which case - * an {@linkplain Collection#isEmpty() empty} {@link Collection} - * will be returned - * - * @param classLoader a {@link ClassLoader} that the resulting - * {@link PersistenceUnitInfoBean} instances will use; may be - * {@code null} - * - * @param tempClassLoaderSupplier a {@link Supplier} of a {@link - * ClassLoader} that will be used to implement the {@link - * PersistenceUnitInfo#getNewTempClassLoader()} method; may be - * {@code null} - * - * @param rootUrl the {@link URL} representing the root of all - * persistence units; must not be {@code null} - * - * @param unlistedClasses a {@link Map} of managed classes indexed - * by persistence unit name whose values might not be explicitly - * listed in a {@link PersistenceUnit}; may be {@code null} - * - * @param dataSourceProvider a {@link DataSourceProvider}; must - * not be {@code null} - * - * @return a non-{@code null} {@link Collection} of {@link - * PersistenceUnitInfoBean} instances - * - * @exception MalformedURLException if a {@link URL} could not be - * constructed - * - * @exception NullPointerException if {@code rootUrl} or {@code - * dataSourceProvider} is {@code null} - * - * @see #fromPersistenceUnit(Persistence.PersistenceUnit, - * ClassLoader, Supplier, URL, Map, DataSourceProvider) - * - * @see PersistenceUnitInfo - * - * @deprecated Please use the {@link - * #fromPersistenceUnit(PersistenceUnit, ClassLoader, Supplier, - * URL, Map, Supplier)} method instead. - */ - @Deprecated - public static final Collection - fromPersistence(final Persistence persistence, - final ClassLoader classLoader, - final Supplier tempClassLoaderSupplier, - final URL rootUrl, - Map>> unlistedClasses, - final DataSourceProvider dataSourceProvider) - throws MalformedURLException { - return fromPersistence(persistence, - classLoader, - tempClassLoaderSupplier, - rootUrl, - unlistedClasses, - () -> dataSourceProvider); - } - - /** - * Creates and returns a {@link Collection} of {@link - * PersistenceUnitInfoBean} instances from a supplied {@link - * Persistence} object. - * - * @param persistence the {@link Persistence} from which {@link - * PersistenceUnitInfoBean} instances should be synthesized; must - * not be {@code null} - * - * @param classLoader classLoader a {@link ClassLoader} that the resulting - * {@link PersistenceUnitInfoBean}s will use; may be {@code null} - * - * @param tempClassLoaderSupplier a {@link Supplier} of a {@link - * ClassLoader} that will be used to implement the {@link - * PersistenceUnitInfo#getNewTempClassLoader()} method; may be - * {@code null} - * - * @param rootUrl the {@link URL} representing the root of the - * persistence units; must not be {@code null} - * - * @param unlistedClasses a {@link Map} of managed classes indexed - * by persistence unit name whose values might not be explicitly - * listed in the supplied {@link PersistenceUnit}s; may be {@code - * null} - * - * @param dataSourceProviderSupplier a {@link Supplier} capable of - * producing {@link DataSourceProvider} instances; must not be - * {@code null} - * - * @return a non-{@code null} {@link Collection} of {@link - * PersistenceUnitInfoBean}s - * - * @exception MalformedURLException if a {@link URL} could not be - * constructed - * - * @exception NullPointerException if {@code persistence}, {@code - * rootUrl} or {@code dataSourceProviderSupplier} is {@code null} - * - * @deprecated Please use the {@link - * #fromPersistenceUnit(PersistenceUnit, ClassLoader, Supplier, - * URL, Map, Supplier)} method instead. - */ - @Deprecated - public static final Collection - fromPersistence(final Persistence persistence, - final ClassLoader classLoader, - final Supplier tempClassLoaderSupplier, - final URL rootUrl, - Map>> unlistedClasses, - final Supplier dataSourceProviderSupplier) - throws MalformedURLException { - - Objects.requireNonNull(rootUrl); - if (unlistedClasses == null) { - unlistedClasses = Collections.emptyMap(); - } - final Collection returnValue; - if (persistence == null) { - returnValue = Collections.emptySet(); - } else { - final Collection persistenceUnits = persistence.getPersistenceUnit(); - if (persistenceUnits == null || persistenceUnits.isEmpty()) { - returnValue = Collections.emptySet(); - } else { - returnValue = new ArrayList<>(); - for (final PersistenceUnit persistenceUnit : persistenceUnits) { - assert persistenceUnit != null; - returnValue.add(fromPersistenceUnit(persistenceUnit, - classLoader, - tempClassLoaderSupplier, - rootUrl, - unlistedClasses, - dataSourceProviderSupplier)); - } - } - } - return returnValue; - } - /** * Given a {@link PersistenceUnit} (a Java object representation * of a {@code } element in a {@code diff --git a/integrations/cdi/jpa-weld/README.md b/integrations/cdi/jpa-weld/README.md deleted file mode 100644 index 9fa0447e6..000000000 --- a/integrations/cdi/jpa-weld/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Helidon JPA Weld Integration - -CAUTION: This project is now superfluous, deprecated and slated for -eventual removal. Please simply use the [`jpa-cdi`](../jpa-cdi) -project instead. diff --git a/integrations/cdi/jpa-weld/pom.xml b/integrations/cdi/jpa-weld/pom.xml deleted file mode 100644 index dcce895a7..000000000 --- a/integrations/cdi/jpa-weld/pom.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - 4.0.0 - - io.helidon.integrations.cdi - helidon-integrations-cdi-project - 2.0.0-SNAPSHOT - - helidon-integrations-cdi-jpa-weld - Helidon CDI Integrations JPA Weld - - - - - package - - - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.hamcrest - hamcrest-all - test - - - io.helidon.microprofile.cdi - helidon-microprofile-cdi - test - - - org.slf4j - slf4j-jdk14 - test - - - com.h2database - h2 - test - - - ${project.groupId} - helidon-integrations-cdi-jta-weld - test - - - ${project.groupId} - helidon-integrations-cdi-datasource-hikaricp - test - - - ${project.groupId} - helidon-integrations-cdi-eclipselink - test - - - io.helidon.microprofile.config - helidon-microprofile-config - test - - - - - ${project.groupId} - helidon-integrations-cdi-jpa - runtime - - - org.jboss - jandex - runtime - - - - - jakarta.annotation - jakarta.annotation-api - provided - - - jakarta.enterprise - jakarta.enterprise.cdi-api - provided - - - jakarta.persistence - jakarta.persistence-api - provided - - - jakarta.transaction - jakarta.transaction-api - provided - - - jakarta.validation - jakarta.validation-api - provided - - - - - org.jboss.weld - weld-spi - compile - - - - - - - maven-surefire-plugin - - - ${basedir}/src/test/java/logging.properties - - - - - org.jboss.jandex - jandex-maven-plugin - - - make-index - - jandex - - process-classes - - - - - - - diff --git a/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/WeldJpaInjectionServices.java b/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/WeldJpaInjectionServices.java deleted file mode 100644 index 571f0f185..000000000 --- a/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/WeldJpaInjectionServices.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 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.integrations.cdi.jpa.weld; - -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.enterprise.inject.spi.InjectionPoint; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -import org.jboss.weld.injection.spi.JpaInjectionServices; -import org.jboss.weld.injection.spi.ResourceReferenceFactory; - -/** - * A {@link JpaInjectionServices} implementation that integrates JPA - * functionality into Weld-based CDI environments. - * - * @see JpaInjectionServices - * - * @deprecated This extension is no longer needed and is slated for - * removal. - */ -@Deprecated -final class WeldJpaInjectionServices implements JpaInjectionServices { - - - /* - * Static fields. - */ - - - /** - * The {@link Logger} for use by all instances of this class. - * - *

This field is never {@code null}.

- */ - private static final Logger LOGGER = Logger.getLogger(WeldJpaInjectionServices.class.getName(), - WeldJpaInjectionServices.class.getPackage().getName() + ".Messages"); - - - /* - * Constructors. - */ - - - /** - * Creates a new {@link WeldJpaInjectionServices}. - * - *

Oddly, the fact that this constructor is {@code private} - * does not prevent Weld from loading it as a service. This is an - * unexpected bonus as nothing about this class should be {@code - * public}.

- */ - WeldJpaInjectionServices() { - super(); - } - - /** - * Throws an {@link IllegalArgumentException} when invoked. - * - * @exception IllegalArgumentException when invoked - * - * @see ResourceReferenceFactory#createResource() - * - * @deprecated This class is deprecated, no longer needed and is - * slated for removal. - */ - @Deprecated - @Override - public ResourceReferenceFactory registerPersistenceContextInjectionPoint(final InjectionPoint injectionPoint) { - final String cn = WeldJpaInjectionServices.class.getName(); - final String mn = "registerPersistenceContextInjectionPoint"; - if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.entering(cn, mn, injectionPoint); - } - final ResourceBundle messages = ResourceBundle.getBundle(this.getClass().getPackage().getName() + ".Messages"); - assert messages != null; - throw new IllegalArgumentException(messages.getString("deprecated")); - } - - /** - * Throws an {@link IllegalArgumentException} when invoked. - * - * @exception IllegalArgumentException when invoked - * - * @see ResourceReferenceFactory#createResource() - * - * @deprecated This class is deprecated, no longer needed and is - * slated for removal. - */ - @Deprecated - @Override - public ResourceReferenceFactory registerPersistenceUnitInjectionPoint(final InjectionPoint ip) { - final String cn = WeldJpaInjectionServices.class.getName(); - final String mn = "registerPersistenceUnitInjectionPoint"; - if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.entering(cn, mn, ip); - } - final ResourceBundle messages = ResourceBundle.getBundle(this.getClass().getPackage().getName() + ".Messages"); - assert messages != null; - throw new IllegalArgumentException(messages.getString("deprecated")); - } - - /** - * Invoked by Weld automatically to clean up any resources held by - * this class. - */ - @Override - public void cleanup() { - - } - - /** - * Throws an {@link IllegalArgumentException} when invoked. - * - * @param injectionPoint ignored - * - * @return nothing - * - * @exception IllegalArgumentException when invoked - * - * @see #registerPersistenceContextInjectionPoint(InjectionPoint)} - * - * @deprecated This class is deprecated, no longer needed and is - * slated for removal. - */ - @Deprecated - public EntityManager resolvePersistenceContext(final InjectionPoint injectionPoint) { - return this.registerPersistenceContextInjectionPoint(injectionPoint).createResource().getInstance(); - } - - /** - * Throws an {@link IllegalArgumentException} when invoked. - * - * @param injectionPoint ignored - * - * @return nothing - * - * @exception IllegalArgumentException when invoked - * - * @see #registerPersistenceContextInjectionPoint(InjectionPoint)} - * - * @deprecated This class is deprecated, no longer needed and is - * slated for removal. - */ - @Deprecated - public EntityManagerFactory resolvePersistenceUnit(final InjectionPoint injectionPoint) { - return this.registerPersistenceUnitInjectionPoint(injectionPoint).createResource().getInstance(); - } - -} diff --git a/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/package-info.java b/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/package-info.java deleted file mode 100644 index b93d33e51..000000000 --- a/integrations/cdi/jpa-weld/src/main/java/io/helidon/integrations/cdi/jpa/weld/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 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. - */ - -/** - * Provides classes and interfaces that help to integrate JPA into Weld-based CDI 2.0 SE environments. - * - * @see - * io.helidon.integrations.cdi.jpa.weld.WeldJpaInjectionServices - */ -package io.helidon.integrations.cdi.jpa.weld; diff --git a/integrations/cdi/jpa-weld/src/main/java/module-info.java b/integrations/cdi/jpa-weld/src/main/java/module-info.java deleted file mode 100644 index a1b9b82e4..000000000 --- a/integrations/cdi/jpa-weld/src/main/java/module-info.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 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. - * 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. - */ - -/** - * Provides classes and interfaces that help to integrate JPA into Weld-based CDI 2.0 SE environments. - * - * @see - * io.helidon.integrations.cdi.jpa.weld.WeldJpaInjectionServices - */ -module io.helidon.integrations.cdi.jpa.weld { - requires java.transaction; - requires java.annotation; - requires java.sql; - requires java.persistence; - requires jakarta.interceptor.api; - requires jakarta.inject.api; - requires jakarta.enterprise.cdi.api; - requires weld.spi; - - exports io.helidon.integrations.cdi.jpa.weld; -} diff --git a/integrations/cdi/jpa-weld/src/main/resources/io/helidon/integrations/cdi/jpa/weld/Messages.properties b/integrations/cdi/jpa-weld/src/main/resources/io/helidon/integrations/cdi/jpa/weld/Messages.properties deleted file mode 100644 index 9627ef27d..000000000 --- a/integrations/cdi/jpa-weld/src/main/resources/io/helidon/integrations/cdi/jpa/weld/Messages.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 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. -# -transactionTypeMismatch=A resource-local EntityManagerFactory was requested for \ - the persistence unit named "{0}", but a JTA \ - EntityManagerFactory, {1}, was previously associated \ - with the persistence unit. -persistenceUnitNameMismatch=The sole PersistenceUnitInfo, {0}, representing \ - the persistence unit with name "{1}", will be used \ - instead of the requested persistence unit named \ - "{2}" -deprecated=This extension is no longer needed and is slated for removal. diff --git a/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestDeprecation.java b/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestDeprecation.java deleted file mode 100644 index 0b7f8e988..000000000 --- a/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestDeprecation.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 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.integrations.cdi.jpa.weld; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -final class TestDeprecation { - - TestDeprecation() { - super(); - } - - @Test - @Deprecated - void testDeprecation() { - assertThrows(IllegalArgumentException.class, - () -> new WeldJpaInjectionServices().registerPersistenceContextInjectionPoint(null)); - } - -} diff --git a/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestIntegration.java b/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestIntegration.java deleted file mode 100644 index e68d93f55..000000000 --- a/integrations/cdi/jpa-weld/src/test/java/io/helidon/integrations/cdi/jpa/weld/TestIntegration.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 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.integrations.cdi.jpa.weld; - -import javax.annotation.sql.DataSourceDefinition; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.ContextNotActiveException; -import javax.enterprise.context.Initialized; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.se.SeContainer; -import javax.enterprise.inject.se.SeContainerInitializer; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.transaction.Status; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.Transactional; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -@ApplicationScoped -@DataSourceDefinition( - name = "test", - className = "org.h2.jdbcx.JdbcDataSource", - url = "jdbc:h2:mem:test", - serverName = "", - properties = { - "user=sa" - } -) -public class TestIntegration { - - private SeContainer cdiContainer; - - @Inject - private Transaction transaction; - - @PersistenceContext - private EntityManager entityManager; - - TestIntegration() { - super(); - } - - @BeforeEach - void startCdiContainer() { - shutDownCdiContainer(); - final SeContainerInitializer initializer = SeContainerInitializer.newInstance() - .addBeanClasses(TestIntegration.class); - assertNotNull(initializer); - this.cdiContainer = initializer.initialize(); - } - - @AfterEach - void shutDownCdiContainer() { - if (this.cdiContainer != null) { - this.cdiContainer.close(); - this.cdiContainer = null; - } - } - - private static void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event, - final TestIntegration self) - throws SystemException { - assertNotNull(event); - assertNotNull(self); - self.doSomethingTransactional(); - self.doSomethingNonTransactional(); - } - - @Transactional(Transactional.TxType.REQUIRED) - void doSomethingTransactional() throws SystemException { - assertNotNull(this.transaction); - assertEquals(Status.STATUS_ACTIVE, this.transaction.getStatus()); - assertNotNull(this.entityManager); - assertTrue(this.entityManager.isOpen()); - assertTrue(this.entityManager.isJoinedToTransaction()); - } - - void doSomethingNonTransactional() { - assertNotNull(this.transaction); // ...but the scope won't be active - try { - this.transaction.toString(); - fail("The TransactionScoped scope was active when it should not have been"); - } catch (final ContextNotActiveException expected) { - - } - assertNotNull(this.entityManager); - assertTrue(this.entityManager.isOpen()); - - } - - @Test - void testIntegration() { - } - -} diff --git a/integrations/cdi/jpa-weld/src/test/java/logging.properties b/integrations/cdi/jpa-weld/src/test/java/logging.properties deleted file mode 100644 index 4b5886c1e..000000000 --- a/integrations/cdi/jpa-weld/src/test/java/logging.properties +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (c) 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. -# -.level=WARNING -com.arjuna.level=WARNING -com.zaxxer.hikari.level=WARNING -handlers=io.helidon.common.HelidonConsoleHandler -io.helidon.integrations.cdi.jpa.level=WARNING -org.eclipse.persistence.level=WARNING -org.jboss.weld.level=WARNING diff --git a/integrations/cdi/jpa-weld/src/test/resources/META-INF/microprofile-config.properties b/integrations/cdi/jpa-weld/src/test/resources/META-INF/microprofile-config.properties deleted file mode 100644 index d24a68810..000000000 --- a/integrations/cdi/jpa-weld/src/test/resources/META-INF/microprofile-config.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c) 2019, 2020 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. -# - -mp.initializer.allow=true -mp.initializer.no-warn=true diff --git a/integrations/cdi/jpa-weld/src/test/resources/META-INF/persistence.xml b/integrations/cdi/jpa-weld/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index afb0d0093..000000000 --- a/integrations/cdi/jpa-weld/src/test/resources/META-INF/persistence.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - test - - - - - - - - - - - - - - - - diff --git a/integrations/cdi/oci-objectstorage-cdi/src/main/java/io/helidon/integrations/cdi/oci/objectstorage/MicroProfileConfigAuthenticationDetailsProvider.java b/integrations/cdi/oci-objectstorage-cdi/src/main/java/io/helidon/integrations/cdi/oci/objectstorage/MicroProfileConfigAuthenticationDetailsProvider.java index bb2d4e318..fa26c2575 100644 --- a/integrations/cdi/oci-objectstorage-cdi/src/main/java/io/helidon/integrations/cdi/oci/objectstorage/MicroProfileConfigAuthenticationDetailsProvider.java +++ b/integrations/cdi/oci-objectstorage-cdi/src/main/java/io/helidon/integrations/cdi/oci/objectstorage/MicroProfileConfigAuthenticationDetailsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -36,6 +36,12 @@ final class MicroProfileConfigAuthenticationDetailsProvider extends CustomerAuth this.config = Objects.requireNonNull(config); } + /** + * This method is implementing an interface of a third party. Until + * that interface removes this method, we need to keep it in Helidon. + * + * @return pass phrase + */ @Deprecated @Override public String getPassPhrase() { diff --git a/integrations/cdi/pom.xml b/integrations/cdi/pom.xml index 84d7fdb63..b6986d7dc 100644 --- a/integrations/cdi/pom.xml +++ b/integrations/cdi/pom.xml @@ -1,7 +1,7 @@ jta-cdi jta-weld oci-objectstorage-cdi diff --git a/media/common/src/main/java/io/helidon/media/common/ContentTypeCharset.java b/media/common/src/main/java/io/helidon/media/common/ContentTypeCharset.java index 9f03ba8d2..feeaeff5d 100644 --- a/media/common/src/main/java/io/helidon/media/common/ContentTypeCharset.java +++ b/media/common/src/main/java/io/helidon/media/common/ContentTypeCharset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 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. @@ -25,13 +25,13 @@ import io.helidon.common.http.Parameters; /** * Accessor for the {@link Charset} specified by a content-type header. - * @deprecated use {@link MessageBodyContext#charset()} instead + * @deprecated since 2.0.0, use {@link MessageBodyContext#charset()} instead */ @Deprecated public class ContentTypeCharset { /** - * Cannot be instanciated. + * Cannot be instantiated. */ private ContentTypeCharset() { } diff --git a/media/common/src/main/java/io/helidon/media/common/MessageBodyContext.java b/media/common/src/main/java/io/helidon/media/common/MessageBodyContext.java index c06a714e0..452c9b42b 100644 --- a/media/common/src/main/java/io/helidon/media/common/MessageBodyContext.java +++ b/media/common/src/main/java/io/helidon/media/common/MessageBodyContext.java @@ -228,7 +228,7 @@ public abstract class MessageBodyContext implements MessageBodyFilters { * Register a function filter. * * @param function filter function - * @deprecated use {@link #registerFilter(MessageBodyFilter)} instead + * @deprecated since 2.0.0 use {@link #registerFilter(MessageBodyFilter)} instead */ @Deprecated public void registerFilter(Function, Publisher> function) { diff --git a/media/common/src/main/java/io/helidon/media/common/MessageBodyReaderContext.java b/media/common/src/main/java/io/helidon/media/common/MessageBodyReaderContext.java index 4fcef1314..2b35716e6 100644 --- a/media/common/src/main/java/io/helidon/media/common/MessageBodyReaderContext.java +++ b/media/common/src/main/java/io/helidon/media/common/MessageBodyReaderContext.java @@ -117,7 +117,7 @@ public final class MessageBodyReaderContext extends MessageBodyContext implement * @param supported type * @param type class representing the supported type * @param reader reader function - * @deprecated use {@link #registerReader(MessageBodyReader) } instead + * @deprecated since 2.0.0 use {@link #registerReader(MessageBodyReader) } instead */ @Deprecated public void registerReader(Class type, io.helidon.common.http.Reader reader) { @@ -129,7 +129,7 @@ public final class MessageBodyReaderContext extends MessageBodyContext implement * @param supported type * @param predicate class predicate * @param reader reader function - * @deprecated use {@link #registerReader(MessageBodyReader) } instead + * @deprecated since 2.0.0 use {@link #registerReader(MessageBodyReader) } instead */ @Deprecated public void registerReader(Predicate> predicate, io.helidon.common.http.Reader reader) { diff --git a/media/common/src/main/java/io/helidon/media/common/MessageBodyWriterContext.java b/media/common/src/main/java/io/helidon/media/common/MessageBodyWriterContext.java index e1d302bbb..47420ae96 100644 --- a/media/common/src/main/java/io/helidon/media/common/MessageBodyWriterContext.java +++ b/media/common/src/main/java/io/helidon/media/common/MessageBodyWriterContext.java @@ -218,7 +218,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement * @param type class representing the type supported by this writer * @param function writer function * @return this {@code MessageBodyWriteableContent} instance - * @deprecated use {@link #registerWriter(MessageBodyWriter) } instead + * @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead */ @Deprecated public MessageBodyWriterContext registerWriter(Class type, Function> function) { @@ -234,7 +234,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement * @param contentType the media type * @param function writer function * @return this {@code MessageBodyWriteableContent} instance - * @deprecated use {@link #registerWriter(MessageBodyWriter) } instead + * @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead */ @Deprecated public MessageBodyWriterContext registerWriter(Class type, MediaType contentType, @@ -251,7 +251,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement * @param accept the object predicate * @param function writer function * @return this {@code MessageBodyWriteableContent} instance - * @deprecated use {@link #registerWriter(MessageBodyWriter) } instead + * @deprecated since 2.0.0 use {@link #registerWriter(MessageBodyWriter) } instead */ @Deprecated public MessageBodyWriterContext registerWriter(Predicate accept, Function> function) { @@ -267,7 +267,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement * @param contentType the media type * @param function writer function * @return this {@code MessageBodyWriteableContent} instance - * @deprecated use {@link #registerWriter(MessageBodyWriter) } instead + * @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead */ @Deprecated public MessageBodyWriterContext registerWriter(Predicate accept, MediaType contentType, diff --git a/metrics/metrics/src/main/java/io/helidon/metrics/MetricsSupport.java b/metrics/metrics/src/main/java/io/helidon/metrics/MetricsSupport.java index 953f8e917..bfd115266 100644 --- a/metrics/metrics/src/main/java/io/helidon/metrics/MetricsSupport.java +++ b/metrics/metrics/src/main/java/io/helidon/metrics/MetricsSupport.java @@ -48,6 +48,7 @@ import io.helidon.common.HelidonFlavor; import io.helidon.common.http.Http; import io.helidon.common.http.MediaType; import io.helidon.config.Config; +import io.helidon.config.DeprecatedConfig; import io.helidon.media.jsonp.server.JsonSupport; import io.helidon.webserver.Handler; import io.helidon.webserver.RequestHeaders; @@ -536,10 +537,12 @@ public final class MetricsSupport implements Service { */ public Builder config(Config config) { this.config = config; + // align with health checks - config.get("web-context").asString().ifPresent(this::context); - // backward compatibility - config.get("context").asString().ifPresent(this::context); + DeprecatedConfig.get(config, "web-context", "context") + .asString() + .ifPresent(this::webContext); + config.get(CORS_CONFIG_KEY) .as(CrossOriginConfig::create) .ifPresent(this::crossOriginConfig); @@ -556,7 +559,7 @@ public final class MetricsSupport implements Service { * {@link RegistryFactory#create(io.helidon.config.Config)} or * {@link RegistryFactory#create()} and create multiple * {@link io.helidon.metrics.MetricsSupport} instances with different - * {@link #context(String) contexts}. + * {@link #webContext(String)} contexts}. *

* If this method is not called, * {@link io.helidon.metrics.MetricsSupport} would use the shared @@ -571,19 +574,6 @@ public final class MetricsSupport implements Service { return this; } - /** - * Set a new root context for REST API of metrics. - * - * @param newContext context to use - * @return updated builder instance - * @deprecated use {@link #webContext(String)} instead, aligned with API - * of heatlh checks - */ - @Deprecated - public Builder context(String newContext) { - return webContext(newContext); - } - /** * Set a new root context for REST API of metrics. * diff --git a/metrics/metrics/src/main/java/io/helidon/metrics/RegistryFactory.java b/metrics/metrics/src/main/java/io/helidon/metrics/RegistryFactory.java index 5530cefdf..9cb6c2bb2 100644 --- a/metrics/metrics/src/main/java/io/helidon/metrics/RegistryFactory.java +++ b/metrics/metrics/src/main/java/io/helidon/metrics/RegistryFactory.java @@ -18,7 +18,6 @@ package io.helidon.metrics; import java.util.EnumMap; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; import io.helidon.config.Config; @@ -85,34 +84,6 @@ public final class RegistryFactory { return new RegistryFactory(config); } - - - /** - * Get a supplier for registry factory. The supplier will return the singleton isntance - * that is created. - * - * @return supplier of registry factory (to bind as late as possible) - * @deprecated use {@link io.helidon.metrics.RegistryFactory#getInstance() RegistryFactory::getInstance} instead. - */ - @Deprecated - public static Supplier getRegistryFactory() { - return RegistryFactory::getInstance; - } - - /** - * Create a registry factory for systems without CDI. - * - * @param config configuration to load the factory config from - * @return a new registry factory to obtain application registry (and other registries) - * @deprecated use {@link #create()} or {@link #create(io.helidon.config.Config)} instead when a new - * registry factory instance is needed. Use {@link #getInstance()} or {@link #getInstance(io.helidon.config.Config)} - * to retrieve the shared (singleton) instance. - */ - @Deprecated - public static RegistryFactory createSeFactory(Config config) { - return create(config); - } - /** * Get a singleton instance of the registry factory. * diff --git a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricUtil.java b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricUtil.java index c6a7d5cc4..cf0657d98 100644 --- a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricUtil.java +++ b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -46,7 +46,7 @@ public final class MetricUtil { } /** - * DO NOT USE THIS METHOD please. + * DO NOT USE THIS METHOD please, it will be removed. * * @param element element * @param annotClass annotation class @@ -54,7 +54,8 @@ public final class MetricUtil { * @param element type * @param annotation type * @return lookup result - * @deprecated This method is made public to migrate from metrics1 to metrics2 for gRPC, this should be refactored + * @deprecated This method is made public to migrate from metrics1 to metrics2 for gRPC, this should be refactored. + * This method will be removed outside of major version of Helidon. */ @SuppressWarnings("unchecked") @Deprecated diff --git a/microprofile/server/src/main/java/io/helidon/microprofile/server/Main.java b/microprofile/server/src/main/java/io/helidon/microprofile/server/Main.java index ba2e089a5..0d49898f6 100644 --- a/microprofile/server/src/main/java/io/helidon/microprofile/server/Main.java +++ b/microprofile/server/src/main/java/io/helidon/microprofile/server/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -25,7 +25,7 @@ import javax.enterprise.inject.spi.CDI; * Uses {@code logging.properties} to configure Java logging unless a configuration is defined through * a Java system property. The file is expected either in the directory the application was started, or on * the classpath. - * @deprecated use {@link io.helidon.microprofile.cdi.Main} instead + * @deprecated since 2.0.0, use {@link io.helidon.microprofile.cdi.Main} instead */ @Deprecated public final class Main { @@ -35,7 +35,7 @@ public final class Main { } /** - * Main method to start server. The server will collection JAX-RS application automatically (through + * Main method to start server. The server will collect JAX-RS application automatically (through * CDI extension - just annotate it with {@link javax.enterprise.context.ApplicationScoped}). * * @param args command line arguments, currently ignored diff --git a/microprofile/tracing/src/main/java/io/helidon/microprofile/tracing/MpTracingContextFilter.java b/microprofile/tracing/src/main/java/io/helidon/microprofile/tracing/MpTracingContextFilter.java index 75538326f..4070a08eb 100644 --- a/microprofile/tracing/src/main/java/io/helidon/microprofile/tracing/MpTracingContextFilter.java +++ b/microprofile/tracing/src/main/java/io/helidon/microprofile/tracing/MpTracingContextFilter.java @@ -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. @@ -15,6 +15,8 @@ */ package io.helidon.microprofile.tracing; +import java.util.Optional; + import javax.annotation.Priority; import javax.enterprise.context.ApplicationScoped; import javax.inject.Provider; @@ -56,11 +58,11 @@ public class MpTracingContextFilter implements ContainerRequestFilter { ServerRequest serverRequest = this.request.get(); Tracer tracer = serverRequest.tracer(); - SpanContext parentSpan = serverRequest.spanContext(); + Optional parentSpan = serverRequest.spanContext(); boolean clientEnabled = config.getOptionalValue("tracing.client.enabled", Boolean.class).orElse(true); TracingContext tracingContext = TracingContext.create(tracer, serverRequest.headers().toMap(), clientEnabled); - tracingContext.parentSpan(parentSpan); + parentSpan.ifPresent(tracingContext::parentSpan); Contexts.context().ifPresent(ctx -> ctx.register(tracingContext)); } diff --git a/security/integration/webserver/src/main/java/io/helidon/security/integration/webserver/WebSecurity.java b/security/integration/webserver/src/main/java/io/helidon/security/integration/webserver/WebSecurity.java index f04912e2f..1a23de1c9 100644 --- a/security/integration/webserver/src/main/java/io/helidon/security/integration/webserver/WebSecurity.java +++ b/security/integration/webserver/src/main/java/io/helidon/security/integration/webserver/WebSecurity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -351,11 +351,14 @@ public final class WebSecurity implements Service { EndpointConfig ec = EndpointConfig.builder() .build(); - SecurityContext context = security.contextBuilder(String.valueOf(SECURITY_COUNTER.incrementAndGet())) - .tracingSpan(req.spanContext()) + SecurityContext.Builder contextBuilder = security.contextBuilder(String.valueOf(SECURITY_COUNTER.incrementAndGet())) .env(env) - .endpointConfig(ec) - .build(); + .endpointConfig(ec); + + // only register if exists + req.spanContext().ifPresent(contextBuilder::tracingSpan); + + SecurityContext context = contextBuilder.build(); req.context().register(context); req.context().register(defaultHandler); diff --git a/security/providers/abac/src/test/java/io/helidon/security/providers/abac/AbacProviderTest.java b/security/providers/abac/src/test/java/io/helidon/security/providers/abac/AbacProviderTest.java index ada6ca88b..3f90fd083 100644 --- a/security/providers/abac/src/test/java/io/helidon/security/providers/abac/AbacProviderTest.java +++ b/security/providers/abac/src/test/java/io/helidon/security/providers/abac/AbacProviderTest.java @@ -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. @@ -25,6 +25,7 @@ import javax.annotation.security.RolesAllowed; import io.helidon.security.AuthorizationResponse; import io.helidon.security.EndpointConfig; import io.helidon.security.ProviderRequest; +import io.helidon.security.SecurityLevel; import io.helidon.security.SecurityResponse; import org.junit.jupiter.api.Test; @@ -47,9 +48,12 @@ public class AbacProviderTest { Attrib1 attrib = Mockito.mock(Attrib1.class); doReturn(Attrib1.class).when(attrib).annotationType(); + SecurityLevel level = SecurityLevel.create("mock") + .withClassAnnotations(Map.of(Attrib1.class, List.of(attrib))) + .build(); + EndpointConfig ec = EndpointConfig.builder() - .annotations(EndpointConfig.AnnotationScope.CLASS, - Map.of(Attrib1.class, List.of(attrib))) + .securityLevels(List.of(level)) .build(); ProviderRequest request = Mockito.mock(ProviderRequest.class); @@ -72,9 +76,12 @@ public class AbacProviderTest { RolesAllowed attrib = Mockito.mock(RolesAllowed.class); doReturn(RolesAllowed.class).when(attrib).annotationType(); + SecurityLevel level = SecurityLevel.create("mock") + .withClassAnnotations(Map.of(RolesAllowed.class, List.of(attrib))) + .build(); + EndpointConfig ec = EndpointConfig.builder() - .annotations(EndpointConfig.AnnotationScope.CLASS, - Map.of(RolesAllowed.class, List.of(attrib))) + .securityLevels(List.of(level)) .build(); ProviderRequest request = Mockito.mock(ProviderRequest.class); @@ -98,9 +105,12 @@ public class AbacProviderTest { when(attrib.value()).thenReturn(false); doReturn(Attrib1.class).when(attrib).annotationType(); + SecurityLevel level = SecurityLevel.create("mock") + .withClassAnnotations(Map.of(Attrib1.class, List.of(attrib))) + .build(); + EndpointConfig ec = EndpointConfig.builder() - .annotations(EndpointConfig.AnnotationScope.CLASS, - Map.of(Attrib1.class, List.of(attrib))) + .securityLevels(List.of(level)) .build(); ProviderRequest request = Mockito.mock(ProviderRequest.class); @@ -124,8 +134,12 @@ public class AbacProviderTest { when(attrib.value()).thenReturn(true); doReturn(Attrib1.class).when(attrib).annotationType(); + SecurityLevel level = SecurityLevel.create("mock") + .withClassAnnotations(Map.of(Attrib1.class, List.of(attrib))) + .build(); + EndpointConfig ec = EndpointConfig.builder() - .annotations(EndpointConfig.AnnotationScope.CLASS, Map.of(Attrib1.class, List.of(attrib))) + .securityLevels(List.of(level)) .build(); ProviderRequest request = Mockito.mock(ProviderRequest.class); diff --git a/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/ConfigUserStore.java b/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/ConfigUserStore.java index 82c133252..8d73686c1 100644 --- a/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/ConfigUserStore.java +++ b/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/ConfigUserStore.java @@ -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. @@ -85,14 +85,6 @@ public class ConfigUserStore implements SecureUserStore { return cu; } - /** - * @deprecated this is needed (for now) for digest authentication. - */ - @Deprecated - char[] password() { - return password; - } - @Override public String login() { return login; @@ -110,7 +102,7 @@ public class ConfigUserStore implements SecureUserStore { @Override public Optional digestHa1(String realm, HttpDigest.Algorithm algorithm) { - return Optional.of(DigestToken.ha1(algorithm, realm, login(), password())); + return Optional.of(DigestToken.ha1(algorithm, realm, login(), password)); } @Override diff --git a/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/UserStore.java b/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/UserStore.java deleted file mode 100644 index 0ce3e095b..000000000 --- a/security/providers/http-auth/src/main/java/io/helidon/security/providers/httpauth/UserStore.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018, 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.security.providers.httpauth; - -import java.util.Arrays; -import java.util.Optional; - -/** - * Store of users for resolving httpauth and digest authentication. - * - * @deprecated This store is designed for POC - e.g. no need for better security. You can use - * {@link io.helidon.security.providers.httpauth.SecureUserStore} instead. - */ -@FunctionalInterface -@Deprecated -public interface UserStore extends SecureUserStore { - /** - * Representation of a single user. - */ - interface User extends SecureUserStore.User { - /** - * Get password of the user. - * The password must be provided in clear text, as we may need to create a digest based on the password - * and other (variable) values for digest authentication. - * - * @return password - */ - char[] password(); - - @Override - default boolean isPasswordValid(char[] password) { - return Arrays.equals(password, password()); - } - - @Override - default Optional digestHa1(String realm, HttpDigest.Algorithm algorithm) { - return Optional.of(DigestToken.ha1(algorithm, realm, login(), password())); - } - } -} diff --git a/security/providers/http-auth/src/test/java/io/helidon/security/providers/httpauth/HttpAuthProviderBuilderLegacyUserStoreTest.java b/security/providers/http-auth/src/test/java/io/helidon/security/providers/httpauth/HttpAuthProviderBuilderLegacyUserStoreTest.java deleted file mode 100644 index cc85fdb1b..000000000 --- a/security/providers/http-auth/src/test/java/io/helidon/security/providers/httpauth/HttpAuthProviderBuilderLegacyUserStoreTest.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (c) 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.security.providers.httpauth; - -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Base64; -import java.util.Optional; -import java.util.Random; -import java.util.Set; - -import io.helidon.common.Builder; -import io.helidon.security.AuthenticationResponse; -import io.helidon.security.Principal; -import io.helidon.security.Security; -import io.helidon.security.SecurityContext; -import io.helidon.security.SecurityResponse; -import io.helidon.security.Subject; -import io.helidon.security.spi.AuthenticationProvider; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * Unit test for {@link io.helidon.security.providers.httpauth.HttpBasicAuthProvider} and - * {@link io.helidon.security.providers.httpauth.HttpDigestAuthProvider}. - * Todo remove this once UserStore is removed. - */ -public class HttpAuthProviderBuilderLegacyUserStoreTest { - private static final String QUOTE = "\""; - private static Security security; - private volatile static int counter = 0; - private final Random random = new Random(); - private SecurityContext context; - - @BeforeAll - public static void initClass() { - UserStore us = userStore(); - - security = Security.builder() - .addAuthenticationProvider(basicAuthProvider(us), "basic") - .addAuthenticationProvider(digestAuthProvider(false, us), "digest") - .addAuthenticationProvider(digestAuthProvider(true, us), "digest_old") - .build(); - } - - private static UserStore userStore() { - return login -> { - if (login.equals("jack")) { - return Optional.of(new UserStore.User() { - @Override - public String login() { - return "jack"; - } - - @Override - public char[] password() { - return "jackIsGreat".toCharArray(); - } - - @Override - public Set roles() { - return Set.of("user", "admin"); - } - }); - } - if (login.equals("jill")) { - return Optional.of(new UserStore.User() { - @Override - public String login() { - return "jill"; - } - - @Override - public char[] password() { - return "password".toCharArray(); - } - - @Override - public Set roles() { - return Set.of("user"); - } - }); - } - - return Optional.empty(); - }; - } - - private static Builder basicAuthProvider(UserStore us) { - return HttpBasicAuthProvider.builder() - .realm("mic") - .userStore(us); - } - - private static Builder digestAuthProvider(boolean old, UserStore us) { - HttpDigestAuthProvider.Builder builder = HttpDigestAuthProvider.builder() - .realm("mic") - .digestServerSecret("pwd".toCharArray()) - .userStore(us); - - if (old) { - builder.noDigestQop(); - } - - return builder; - } - - @BeforeEach - public void init() { - context = security.contextBuilder(String.valueOf(counter++)) - .build(); - } - - @Test - public void basicTestFail() { - AuthenticationResponse response = context.atnClientBuilder().buildAndGet(); - - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0); - assertThat(authHeader, notNullValue()); - assertThat(authHeader.toLowerCase(), is("basic realm=\"mic\"")); - } - - @Test - public void basicTestJack() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "jackIsGreat")); - - AuthenticationResponse response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(context.user().map(sub -> sub.principal().getName()).orElse(null), is("jack")); - assertThat(context.isUserInRole("admin"), is(true)); - assertThat(context.isUserInRole("user"), is(true)); - } - - private void setHeader(SecurityContext context, String name, String value) { - context.env(context.env() - .derive() - .header(name, value) - .build()); - } - - @Test - public void basicTestInvalidUser() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("wrong", "user")); - - AuthenticationResponse response = context.authenticate(); - - assertThat(response.description().orElse(""), is("Invalid username or password")); - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0); - assertThat(authHeader, notNullValue()); - assertThat(authHeader.toLowerCase(), is("basic realm=\"mic\"")); - - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "invalid_passworrd")); - - response = context.authenticate(); - - assertThat(response.description().orElse(""), is("Invalid username or password")); - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void sendInvalidTypeTest() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "bearer token=\"adfasfaf\""); - - AuthenticationResponse response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void sendInvalidBasicTest() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "basic wrong_header_value"); - AuthenticationResponse response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - - // not base64 encoded and invalid - setHeader(context, - HttpBasicAuthProvider.HEADER_AUTHENTICATION, - "basic " + Base64.getEncoder().encodeToString("Hello".getBytes())); - - response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void sendDigestNotBasicTest() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jack", "jackIsGreat")); - AuthenticationResponse response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void basicTestJill() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jill", "password")); - AuthenticationResponse response = context.authenticate(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(getUsername(context), is("jill")); - assertThat(context.isUserInRole("admin"), is(false)); - assertThat(context.isUserInRole("user"), is(true)); - } - - @Test - public void digestTest401() { - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0); - assertThat(authHeader, notNullValue()); - assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\"")); - assertThat(authHeader.toLowerCase(), containsString("qop=")); - } - - @Test - public void digestOldTest401() { - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest_old") - .buildAndGet(); - - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0); - assertThat(authHeader, notNullValue()); - assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\"")); - assertThat(authHeader.toLowerCase(), not(containsString("qop="))); - } - - @Test - public void digestTestJack() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jack", "jackIsGreat")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse("No description"), - response.status(), - is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(getUsername(context), is("jack")); - assertThat(context.isUserInRole("admin"), is(true)); - assertThat(context.isUserInRole("user"), is(true)); - } - - @Test - public void digestTestInvalidUser() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "wrong", "user")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse(""), is("Invalid username or password")); - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0); - assertThat(authHeader, notNullValue()); - assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\"")); - - setHeader(context, - HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, "jack", "wrong password")); - response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse(""), is("Invalid username or password")); - assertThat(response.status().isSuccess(), is(false)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void sendBasicNotDigestTest() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "jackIsGreat")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void sendInvalidDigestTest() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "digest wrong_header_value"); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void digestTestJill() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jill", "password")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse("No description"), - response.status(), - is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(getUsername(context), is("jill")); - assertThat(context.isUserInRole("admin"), is(false)); - assertThat(context.isUserInRole("user"), is(true)); - } - - private String getUsername(SecurityContext context) { - return context.user().map(Subject::principal).map(Principal::getName).orElse(null); - } - - @Test - public void digestOldTestJack() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.NONE, "jack", "jackIsGreat")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest_old") - .buildAndGet(); - - assertThat(response.description().orElse("No description"), - response.status(), - is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(getUsername(context), is("jack")); - assertThat(context.isUserInRole("admin"), is(true)); - assertThat(context.isUserInRole("user"), is(true)); - } - - @Test - public void digestOldTestJill() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.NONE, "jill", "password")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest_old") - .buildAndGet(); - - assertThat(response.description().orElse("No description"), - response.status(), - is(SecurityResponse.SecurityStatus.SUCCESS)); - assertThat(response.statusCode().orElse(200), is(200)); - - assertThat(getUsername(context), is("jill")); - assertThat(context.isUserInRole("admin"), is(false)); - assertThat(context.isUserInRole("user"), is(true)); - } - - @Test - public void digestTestNonceTimeout() { - Instant in = Instant.now().minus(100, ChronoUnit.DAYS); - - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, - "jack", - "jackIsGreat", - HttpDigestAuthProvider.nonce(in.toEpochMilli(), random, "pwd".toCharArray()), - "mic")); - - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse(""), is("Nonce timeout")); - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void digestTestNonceNotB64() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, - "jack", - "jackIsGreat", - "Not a base64 encoded $tring", - "mic")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse(""), is("Nonce must be base64 encoded")); - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void digestTestNonceTooShort() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, - "jack", - "jackIsGreat", - // must be base64 encoded string of less than 17 bytes - "wrongNonce", - "mic")); - - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - assertThat(response.description().orElse(""), is("Invalid nonce length")); - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void digestTestNonceNotEncrypted() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, - "jack", - "jackIsGreat", - Base64.getEncoder() - .encodeToString("4444444444444444444444444444444444444444444444".getBytes()), - "mic")); - - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - assertThat(response.description().orElse(""), is("Invalid nonce value")); - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - @Test - public void digestTestWrongRealm() { - setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, - buildDigest(HttpDigest.Qop.AUTH, - "jack", - "jackIsGreat", - HttpDigestAuthProvider.nonce(System.currentTimeMillis(), random, "pwd".toCharArray()), - "wrongRealm")); - AuthenticationResponse response = context.atnClientBuilder() - .explicitProvider("digest") - .buildAndGet(); - - assertThat(response.description().orElse(""), is("Invalid realm")); - assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE)); - assertThat(response.statusCode().orElse(200), is(401)); - } - - private String buildBasic(String user, String password) { - return "basic " + Base64.getEncoder() - .encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8)); - } - - private String buildDigest(HttpDigest.Qop qop, - String user, - String password, - String nonce, - String realm) { - - StringBuilder result = new StringBuilder(100); - - String opaque = "someString"; - String path = "/digest"; - String cnonce = createCnonce(); - String nc = "00000001"; - - DigestToken token = new DigestToken(); - token.setAlgorithm(HttpDigest.Algorithm.MD5); - token.setQop(qop); - token.setUsername(user); - token.setOpaque(opaque); - token.setRealm(realm); - token.setMethod("GET"); - token.setUri(path); - token.setNonce(nonce); - token.setNc(nc); - token.setCnonce(cnonce); - - String response = token.digest(password.toCharArray()); - - result.append("digest "); - result.append("username=").append(QUOTE).append(user).append(QUOTE); - result.append(", realm=").append(QUOTE).append(realm).append(QUOTE); - result.append(", nonce=").append(QUOTE).append(nonce).append(QUOTE); - result.append(", uri=").append(QUOTE).append(path).append(QUOTE); - result.append(", algorithm=MD5"); - result.append(", response=").append(QUOTE).append(response).append(QUOTE); - result.append(", opaque=").append(QUOTE).append(opaque).append(QUOTE); - if (qop != HttpDigest.Qop.NONE) { - result.append(", qop=").append(qop.getQop()); - } - result.append(", nc=").append(nc); - result.append(", cnonce=").append(QUOTE).append(cnonce).append(QUOTE); - - return result.toString(); - } - - private String buildDigest(HttpDigest.Qop qop, String user, String password) { - return buildDigest(qop, - user, - password, - HttpDigestAuthProvider.nonce(System.currentTimeMillis(), random, "pwd".toCharArray()), - "mic"); - } - - private String createCnonce() { - byte[] cnonce = new byte[8]; - random.nextBytes(cnonce); - - return Base64.getEncoder().encodeToString(cnonce); - } - -} diff --git a/security/security/src/main/java/io/helidon/security/EndpointConfig.java b/security/security/src/main/java/io/helidon/security/EndpointConfig.java index 2d44e5164..c68f184f4 100644 --- a/security/security/src/main/java/io/helidon/security/EndpointConfig.java +++ b/security/security/src/main/java/io/helidon/security/EndpointConfig.java @@ -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. @@ -16,12 +16,10 @@ package io.helidon.security; -import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -120,42 +118,6 @@ public class EndpointConfig implements AbacSupport { return Optional.ofNullable(configMap.get(configKey)); } - /** - * All custom annotations for scopes defined in parameters, in the same order. - * - * @param scopes scopes the caller is interested in - * @return a map of annotation classes to annotation instances - * @see SecurityProvider#supportedAnnotations() - * @deprecated use iteration over security levels instead - */ - @Deprecated - public Map, List> annotations(AnnotationScope... scopes) { - Map, List> result = new HashMap<>(); - - for (AnnotationScope scope : scopes) { - Map, List> map; - switch (scope) { - case APPLICATION: - map = securityLevels.get(0).getClassLevelAnnotations(); - break; - case CLASS: - map = securityLevels.get(securityLevels.size() - 1).getClassLevelAnnotations(); - break; - case METHOD: - map = securityLevels.get(securityLevels.size() - 1).getMethodLevelAnnotations(); - break; - default: - map = null; - } - if (null != map) { - map.forEach((annotClass, annotList) -> result.computeIfAbsent(annotClass, aClass -> new LinkedList<>()) - .addAll(annotList)); - } - } - - return result; - } - /** * Get all security levels endpoint configuration object registered. * The first level represents {@link AnnotationScope#APPLICATION} level annotations. @@ -167,25 +129,6 @@ public class EndpointConfig implements AbacSupport { return securityLevels; } - /** - * Get all annotations of a specific class declared on any level. - * - * @param annotationClass Class of annotation you want - * @param scopes scopes the caller is interested in - * @param type of annotation wanted - * @return list of annotations in order specified by methodFirst parameter - * @deprecated use iteration over security levels instead - */ - @Deprecated - @SuppressWarnings("unchecked") - public List combineAnnotations(Class annotationClass, AnnotationScope... scopes) { - List result = new LinkedList<>(); - - result.addAll((Collection) annotations(scopes).getOrDefault(annotationClass, List.of())); - - return result; - } - /** * Derive a new endpoint configuration builder based on this instance. * @@ -296,62 +239,6 @@ public class EndpointConfig implements AbacSupport { return this; } - /** - * Add annotations of a specific scope to this request builder. - * Only used by frameworks that use annotations. - * - * @param scope Annotation scope to add annotations for - * @param annotations Collected annotations based on security provider requirements. - * @return updated Builder instance - * @deprecated Use the {@link #securityLevels(List) securityLevels} method. - */ - @Deprecated - public Builder annotations(AnnotationScope scope, - Map, List> annotations) { - // here we must switch from a proxy to actual annotation type - Map, List> newAnnots = new HashMap<>(); - - if (securityLevels.isEmpty()) { - securityLevels.add(SecurityLevel.create("APPLICATION").build()); //Security level of Application - securityLevels.add(SecurityLevel.create("CLASS").build()); // Security level of class and method - } - SecurityLevel securityLevel; - int index; - if (scope == AnnotationScope.APPLICATION) { - index = 0; - } else { - index = securityLevels.size() - 1; - } - securityLevel = securityLevels.get(index); - - annotations.forEach((aClass, list) -> { - if (!list.isEmpty()) { - Annotation annotation = list.get(0); - newAnnots.put(annotation.annotationType(), list); - } - }); - - switch (scope) { - case APPLICATION: - case CLASS: - securityLevels.set(index, - SecurityLevel.create(securityLevel) - .withClassAnnotations(newAnnots) - .build()); - break; - case METHOD: - securityLevels.set(index, - SecurityLevel.create(securityLevel) - .withMethodAnnotations(newAnnots) - .build()); - break; - default: - throw new IllegalStateException("Scope FIELD is not supported here."); - } - - return this; - } - /** * Attributes of this endpoint configuration. * diff --git a/security/security/src/main/java/io/helidon/security/spi/SecurityProvider.java b/security/security/src/main/java/io/helidon/security/spi/SecurityProvider.java index a8c3bc12d..f79543aa1 100644 --- a/security/security/src/main/java/io/helidon/security/spi/SecurityProvider.java +++ b/security/security/src/main/java/io/helidon/security/spi/SecurityProvider.java @@ -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. @@ -36,8 +36,6 @@ public interface SecurityProvider { * class and resource methods will be collected. * * @return Collection of annotations this provider expects. - * @see EndpointConfig#annotations(EndpointConfig.AnnotationScope...) - * @see EndpointConfig#combineAnnotations(Class, EndpointConfig.AnnotationScope...) */ default Collection> supportedAnnotations() { return Set.of(); diff --git a/tests/functional/mp-synthetic-app/src/main/resources/logging.properties b/tests/functional/mp-synthetic-app/src/main/resources/logging.properties index de3dd8794..b2f1ba7d8 100644 --- a/tests/functional/mp-synthetic-app/src/main/resources/logging.properties +++ b/tests/functional/mp-synthetic-app/src/main/resources/logging.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 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. @@ -23,7 +23,6 @@ io.helidon.level=INFO # It replaces "!thread!" with the current thread name #java.util.logging.ConsoleHandler.level=ALL io.helidon.common.HelidonConsoleHandler.level=ALL -#java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n AUDIT.level=FINEST io.helidon.webserver.level=WARNING diff --git a/tests/integration/native-image/mp-1/logging.properties b/tests/integration/native-image/mp-1/logging.properties index 1ef5ed81a..8efee87e0 100644 --- a/tests/integration/native-image/mp-1/logging.properties +++ b/tests/integration/native-image/mp-1/logging.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2020 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. @@ -32,7 +32,6 @@ io.helidon.level=INFO # It replaces "!thread!" with the current thread name #java.util.logging.ConsoleHandler.level=ALL io.helidon.common.HelidonConsoleHandler.level=ALL -#java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n AUDIT.level=FINEST io.helidon.webserver.level=WARNING diff --git a/tracing/jaeger/src/main/java/io/helidon/tracing/jaeger/JaegerTracerBuilder.java b/tracing/jaeger/src/main/java/io/helidon/tracing/jaeger/JaegerTracerBuilder.java index ae9f30f0f..a962cf2af 100644 --- a/tracing/jaeger/src/main/java/io/helidon/tracing/jaeger/JaegerTracerBuilder.java +++ b/tracing/jaeger/src/main/java/io/helidon/tracing/jaeger/JaegerTracerBuilder.java @@ -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. @@ -354,19 +354,6 @@ public class JaegerTracerBuilder implements TracerBuilder { return this; } - /** - * The host name and port when using the remote controlled sampler. - * - * @param samplerManagerHostPort host and port of the sampler manager - * @return updated builder instance - * @deprecated typo, please use {@link #samplerManager(String)} - */ - @Deprecated - public JaegerTracerBuilder samplerMananger(String samplerManagerHostPort) { - this.samplerManager = samplerManagerHostPort; - return this; - } - /** * The host name and port when using the remote controlled sampler. * @@ -476,18 +463,6 @@ public class JaegerTracerBuilder implements TracerBuilder { return result; } - @Override - public Tracer buildAndRegister() { - if (global) { - return build(); - } - - Tracer result = build(); - GlobalTracer.register(result); - - return result; - } - Configuration jaegerConfig() { /* * Preload from environment, then override configured values diff --git a/tracing/tracing/src/main/java/io/helidon/tracing/TracerBuilder.java b/tracing/tracing/src/main/java/io/helidon/tracing/TracerBuilder.java index 209f537cf..d6022e8c7 100644 --- a/tracing/tracing/src/main/java/io/helidon/tracing/TracerBuilder.java +++ b/tracing/tracing/src/main/java/io/helidon/tracing/TracerBuilder.java @@ -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. @@ -22,7 +22,6 @@ import io.helidon.common.Builder; import io.helidon.config.Config; import io.opentracing.Tracer; -import io.opentracing.util.GlobalTracer; /** * A builder for tracing {@link Tracer tracer}. @@ -250,7 +249,6 @@ public interface TracerBuilder extends Builder /** * When enabled, the created instance is also registered as a global tracer. - * When set to {@code true} method {@link #build()} will have the same result as {@link #buildAndRegister()}. * * @param global whether to register this tracer as a global tracer once built * @return updated builder instance @@ -266,18 +264,4 @@ public interface TracerBuilder extends Builder // declaration on io.helidon.common.Builder // this class returned an Object instead of Tracer Tracer build(); - - /** - * Build and register as a global tracer. - * - * @return The {@link Tracer} built and registered - * @deprecated Use {@link #registerGlobal(boolean)} to control whether the resulting instance is - * registered as a {@link io.opentracing.util.GlobalTracer}. - */ - @Deprecated - default Tracer buildAndRegister() { - Tracer result = build(); - GlobalTracer.register(result); - return result; - } } diff --git a/tracing/tracing/src/test/java/io/helidon/tracing/TracerBuilderTest.java b/tracing/tracing/src/test/java/io/helidon/tracing/TracerBuilderTest.java index ce01af025..6da417498 100644 --- a/tracing/tracing/src/test/java/io/helidon/tracing/TracerBuilderTest.java +++ b/tracing/tracing/src/test/java/io/helidon/tracing/TracerBuilderTest.java @@ -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. @@ -51,7 +51,8 @@ class TracerBuilderTest { .addTracerTag("key2", 49) .addTracerTag("key3", true) .enabled(true) - .buildAndRegister(); + .registerGlobal(true) + .build(); assertThat(tracer, notNullValue()); assertThat(tracer, instanceOf(NoopTracer.class)); @@ -60,7 +61,7 @@ class TracerBuilderTest { @Test void testNoOpTracerBuilderFromConfig() { Tracer tracer = TracerBuilder.create(Config.create()) - .buildAndRegister(); + .build(); assertThat(tracer, notNullValue()); assertThat(tracer, instanceOf(NoopTracer.class)); @@ -97,7 +98,7 @@ class TracerBuilderTest { // make sure we do not lose the builder type .first("first") .second("second") - .buildAndRegister(); + .build(); assertThat(tracer, notNullValue()); assertThat(tracer, instanceOf(NoopTracer.class)); diff --git a/tracing/zipkin/src/main/java/io/helidon/tracing/zipkin/ZipkinTracerBuilder.java b/tracing/zipkin/src/main/java/io/helidon/tracing/zipkin/ZipkinTracerBuilder.java index 4ef902206..61bc43f74 100644 --- a/tracing/zipkin/src/main/java/io/helidon/tracing/zipkin/ZipkinTracerBuilder.java +++ b/tracing/zipkin/src/main/java/io/helidon/tracing/zipkin/ZipkinTracerBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 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. @@ -326,18 +326,6 @@ public class ZipkinTracerBuilder implements TracerBuilder { return result; } - @Override - public Tracer buildAndRegister() { - if (global) { - return build(); - } - - Tracer result = build(); - GlobalTracer.register(result); - - return result; - } - /** * Version of Zipkin API to use. * Defaults to {@link Version#V2}. diff --git a/webclient/webclient/src/main/java/io/helidon/webclient/WebClient.java b/webclient/webclient/src/main/java/io/helidon/webclient/WebClient.java index 1025ee20a..8f84a5f9b 100644 --- a/webclient/webclient/src/main/java/io/helidon/webclient/WebClient.java +++ b/webclient/webclient/src/main/java/io/helidon/webclient/WebClient.java @@ -283,7 +283,7 @@ public interface WebClient { * * @param amount amount of time * @param unit time unit - * @deprecated see {@link WebClient.Builder#connectTimeout(long, TimeUnit)} + * @deprecated use {@link WebClient.Builder#connectTimeout(long, TimeUnit)}, this method will be removed * @return updated builder instance */ @Deprecated @@ -309,7 +309,7 @@ public interface WebClient { * * @param amount amount of time * @param unit time unit - * @deprecated see {@link WebClient.Builder#readTimeout(long, TimeUnit)} + * @deprecated use {@link WebClient.Builder#readTimeout(long, TimeUnit)}, this method will be removed * @return updated builder instance */ @Deprecated diff --git a/webclient/webclient/src/main/java/io/helidon/webclient/WebClientRequestBuilder.java b/webclient/webclient/src/main/java/io/helidon/webclient/WebClientRequestBuilder.java index 27aa5fea7..b48ff18b7 100644 --- a/webclient/webclient/src/main/java/io/helidon/webclient/WebClientRequestBuilder.java +++ b/webclient/webclient/src/main/java/io/helidon/webclient/WebClientRequestBuilder.java @@ -191,7 +191,7 @@ public interface WebClientRequestBuilder { * * @param amount amount of time * @param unit time unit - * @deprecated see {@link WebClientRequestBuilder#connectTimeout(long, TimeUnit)} + * @deprecated use {@link WebClientRequestBuilder#connectTimeout(long, TimeUnit)}, this method will be removed * @return updated builder instance */ @Deprecated @@ -211,7 +211,7 @@ public interface WebClientRequestBuilder { * * @param amount amount of time * @param unit time unit - * @deprecated see {@link WebClientRequestBuilder#readTimeout(long, TimeUnit)} + * @deprecated use {@link WebClientRequestBuilder#readTimeout(long, TimeUnit)}, this method will be removed * @return updated builder instance */ @Deprecated diff --git a/webserver/jersey/src/main/java/io/helidon/webserver/jersey/JerseySupport.java b/webserver/jersey/src/main/java/io/helidon/webserver/jersey/JerseySupport.java index 4e5a15bda..c47599efa 100644 --- a/webserver/jersey/src/main/java/io/helidon/webserver/jersey/JerseySupport.java +++ b/webserver/jersey/src/main/java/io/helidon/webserver/jersey/JerseySupport.java @@ -274,8 +274,8 @@ public class JerseySupport implements Service { requestContext.setRequestScopedInitializer(injectionManager -> { injectionManager.>getInstance(REQUEST_TYPE).set(req); injectionManager.>getInstance(RESPONSE_TYPE).set(res); - injectionManager.>getInstance(SPAN_TYPE).set(req.span()); - injectionManager.>getInstance(SPAN_CONTEXT_TYPE).set(req.spanContext()); + injectionManager.>getInstance(SPAN_CONTEXT_TYPE) + .set(req.spanContext().orElse(null)); }); appHandler.handle(requestContext); diff --git a/webserver/tyrus/src/test/resources/logging-test.properties b/webserver/tyrus/src/test/resources/logging-test.properties index 0acfb827b..e04b12d16 100644 --- a/webserver/tyrus/src/test/resources/logging-test.properties +++ b/webserver/tyrus/src/test/resources/logging-test.properties @@ -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,9 +16,9 @@ #All attributes details -handlers=java.util.logging.ConsoleHandler -java.util.logging.ConsoleHandler.level=FINEST -java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter +handlers=io.helidon.common.HelidonConsoleHandler + +io.helidon.common.HelidonConsoleHandler.level=ALL java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n #All log level details diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/ExperimentalConfiguration.java b/webserver/webserver/src/main/java/io/helidon/webserver/ExperimentalConfiguration.java index 5f6a3a4cc..69dee4e83 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/ExperimentalConfiguration.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/ExperimentalConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 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. @@ -32,7 +32,6 @@ public interface ExperimentalConfiguration { * * @return a new builder instance. */ - @SuppressWarnings("deprecation") // will be changed to private constructor and deprecation removed static Builder builder() { return new Builder(); } @@ -43,14 +42,7 @@ public interface ExperimentalConfiguration { final class Builder implements io.helidon.common.Builder { private Http2Configuration http2; - /** - * Do not use this constructor. - * Will be changed to {@code private} in next release. - * - * @deprecated use {@link ExperimentalConfiguration#builder()} instead. - */ - @Deprecated - public Builder() { + private Builder() { } /** diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/Request.java b/webserver/webserver/src/main/java/io/helidon/webserver/Request.java index 392b93d34..2cb4d6220 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/Request.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/Request.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.StringTokenizer; import io.helidon.common.GenericType; @@ -197,8 +198,8 @@ abstract class Request implements ServerRequest { private Span createReadSpan(GenericType type) { // only create this span if we have a parent span - SpanContext parentSpan = spanContext(); - if (null == parentSpan) { + Optional parentSpan = spanContext(); + if (parentSpan.isEmpty()) { return null; } @@ -212,7 +213,7 @@ abstract class Request implements ServerRequest { if (spanConfig.enabled()) { // only create a real span if enabled Tracer.SpanBuilder spanBuilder = tracer().buildSpan(spanName); - spanBuilder.asChildOf(parentSpan); + spanBuilder.asChildOf(parentSpan.get()); if (type != null) { spanBuilder.withTag("requested.type", type.getTypeName()); diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/RequestRouting.java b/webserver/webserver/src/main/java/io/helidon/webserver/RequestRouting.java index 77129d7f0..fadc98bf7 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/RequestRouting.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/RequestRouting.java @@ -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. @@ -270,15 +270,13 @@ class RequestRouting implements Routing { this.errorHandlers = new LinkedList<>(errorHandlers); } - @Override - @SuppressWarnings("deprecation") - public Span span() { + Span span() { return context().get(ServerRequest.class, Span.class).orElse(null); } @Override - public SpanContext spanContext() { - return context().get(ServerRequest.class, SpanContext.class).orElse(null); + public Optional spanContext() { + return context().get(ServerRequest.class, SpanContext.class); } /** diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/ServerConfiguration.java b/webserver/webserver/src/main/java/io/helidon/webserver/ServerConfiguration.java index cf829a52d..51b98987e 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/ServerConfiguration.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/ServerConfiguration.java @@ -580,7 +580,7 @@ public interface ServerConfiguration extends SocketConfiguration { // experimental Config experimentalConfig = config.get("experimental"); if (experimentalConfig.exists()) { - ExperimentalConfiguration.Builder experimentalBuilder = new ExperimentalConfiguration.Builder(); + ExperimentalConfiguration.Builder experimentalBuilder = ExperimentalConfiguration.builder(); Config http2Config = experimentalConfig.get("http2"); if (http2Config.exists()) { Http2Configuration.Builder http2Builder = new Http2Configuration.Builder(); diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/ServerRequest.java b/webserver/webserver/src/main/java/io/helidon/webserver/ServerRequest.java index 085871a31..48a95888c 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/ServerRequest.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/ServerRequest.java @@ -16,11 +16,12 @@ package io.helidon.webserver; +import java.util.Optional; + import io.helidon.common.context.Context; import io.helidon.common.http.HttpRequest; import io.helidon.media.common.MessageBodyReadableContent; -import io.opentracing.Span; import io.opentracing.SpanContext; import io.opentracing.Tracer; @@ -120,28 +121,14 @@ public interface ServerRequest extends HttpRequest { */ long requestId(); - /** - * Returns a span connected with current {@link Handler} call. - *

- * {@code Span} is a tracing component from opentracing.io standard. - * - * @return a current span - * @deprecated use {@link #spanContext()} instead - */ - @Deprecated - Span span(); - /** * Returns a span context related to the current request. *

* {@code SpanContext} is a tracing component from opentracing.io standard. * - * @return the related span context, may be null if not enabled - * @deprecated this method will have a different return type in next backward incompatible version - * of Helidon. It will return {@code Optional}. All methods that can return null will use - * {@link java.util.Optional} + * @return the related span context, empty if not enabled */ - SpanContext spanContext(); + Optional spanContext(); /** * Returns the {@link io.opentracing.Tracer} associated with {@link io.helidon.webserver.WebServer}. diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/ServerResponse.java b/webserver/webserver/src/main/java/io/helidon/webserver/ServerResponse.java index ed3f5a783..91922322d 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/ServerResponse.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/ServerResponse.java @@ -184,7 +184,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters { * @param a type of the content * @return this instance of {@link ServerResponse} * @throws NullPointerException if {@code function} parameter is {@code null} - * @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead + * @deprecated Since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead */ @Deprecated ServerResponse registerWriter(Class type, Function> function); @@ -203,7 +203,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters { * @param a type of the content * @return this instance of {@link ServerResponse} * @throws NullPointerException if {@code function} parameter is {@code null} - * @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead + * @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead */ @Deprecated ServerResponse registerWriter(Class type, @@ -221,7 +221,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters { * @param a type of the content * @return this instance of {@link ServerResponse} * @throws NullPointerException if {@code function} parameter is {@code null} - * @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead + * @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead */ @Deprecated ServerResponse registerWriter(Predicate accept, Function> function); @@ -240,7 +240,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters { * @param a type of the content * @return this instance of {@link ServerResponse} * @throws NullPointerException if {@code function} parameter is {@code null} - * @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead + * @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead */ @Deprecated ServerResponse registerWriter(Predicate accept, @@ -264,7 +264,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters { * {@code null} then the result will be ignored. * @return this instance of {@link ServerResponse} * @throws NullPointerException if parameter {@code function} is {@code null} - * @deprecated use {@link #registerFilter(io.helidon.media.common.MessageBodyFilter)} instead + * @deprecated since 2.0.0, use {@link #registerFilter(io.helidon.media.common.MessageBodyFilter)} instead */ @Deprecated ServerResponse registerFilter(Function, Publisher> function); diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/WebServerLogFormatter.java b/webserver/webserver/src/main/java/io/helidon/webserver/WebServerLogFormatter.java deleted file mode 100644 index b261c5a9b..000000000 --- a/webserver/webserver/src/main/java/io/helidon/webserver/WebServerLogFormatter.java +++ /dev/null @@ -1,37 +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.webserver; - -import java.util.logging.LogRecord; -import java.util.logging.SimpleFormatter; -import java.util.regex.Pattern; - -/** - * The WebServerLogFormatter provides a way to customize logging messages. - */ -@Deprecated -public class WebServerLogFormatter extends SimpleFormatter { - - private static final Pattern THREAD_PATTERN = Pattern.compile("!thread!"); - - @Override - public String format(LogRecord record) { - String message = super.format(record); - - return THREAD_PATTERN.matcher(message).replaceAll(Thread.currentThread().toString()); - } -} diff --git a/webserver/webserver/src/test/java/io/helidon/webserver/ExperimentalConfigTest.java b/webserver/webserver/src/test/java/io/helidon/webserver/ExperimentalConfigTest.java index a37797ab3..7ec9f6dc5 100644 --- a/webserver/webserver/src/test/java/io/helidon/webserver/ExperimentalConfigTest.java +++ b/webserver/webserver/src/test/java/io/helidon/webserver/ExperimentalConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -44,7 +44,7 @@ public class ExperimentalConfigTest { Http2Configuration http2 = builder.build(); assertThat(http2.enable(), is(true)); assertThat(http2.maxContentLength(), is(32 * 1024)); - ExperimentalConfiguration config = new ExperimentalConfiguration.Builder().http2(http2).build(); + ExperimentalConfiguration config = ExperimentalConfiguration.builder().http2(http2).build(); assertThat(config.http2(), is(http2)); } diff --git a/webserver/webserver/src/test/java/io/helidon/webserver/RequestTestStub.java b/webserver/webserver/src/test/java/io/helidon/webserver/RequestTestStub.java index b5bd37641..ebcf5d819 100644 --- a/webserver/webserver/src/test/java/io/helidon/webserver/RequestTestStub.java +++ b/webserver/webserver/src/test/java/io/helidon/webserver/RequestTestStub.java @@ -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,8 +16,10 @@ package io.helidon.webserver; -import io.helidon.common.reactive.Single; import java.net.URI; +import java.util.Optional; + +import io.helidon.common.reactive.Single; import io.opentracing.Span; import io.opentracing.SpanContext; @@ -60,13 +62,8 @@ public class RequestTestStub extends Request { } @Override - public Span span() { - return span; - } - - @Override - public SpanContext spanContext() { - return span.context(); + public Optional spanContext() { + return Optional.ofNullable(span.context()); } @Override