diff --git a/.github/workflows/kumuluzee-ci.yml b/.github/workflows/kumuluzee-ci.yml index 597020b9..f10f1a84 100644 --- a/.github/workflows/kumuluzee-ci.yml +++ b/.github/workflows/kumuluzee-ci.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - java-version: ['11', '17', '18'] + java-version: ['11', '17', '21'] steps: - name: Checkout code diff --git a/components/cdi/weld/pom.xml b/components/cdi/weld/pom.xml index 938e3a8e..81880edc 100644 --- a/components/cdi/weld/pom.xml +++ b/components/cdi/weld/pom.xml @@ -35,8 +35,9 @@ jakarta.el-api - jakarta.enterprise - jakarta.enterprise.cdi-api + org.jboss.weld.servlet + weld-servlet-core + ${weld.version} diff --git a/components/jax-rs/jersey/src/main/java/org/glassfish/jersey/jetty/connector/Jetty10Connector.java b/components/jax-rs/jersey/src/main/java/org/glassfish/jersey/jetty/connector/Jetty10Connector.java index 5303ddd6..ef9dcf04 100644 --- a/components/jax-rs/jersey/src/main/java/org/glassfish/jersey/jetty/connector/Jetty10Connector.java +++ b/components/jax-rs/jersey/src/main/java/org/glassfish/jersey/jetty/connector/Jetty10Connector.java @@ -40,7 +40,7 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.ClientRequest; import org.glassfish.jersey.client.ClientResponse; -import org.glassfish.jersey.client.internal.LocalizationMessages; +import org.glassfish.jersey.client.innate.ClientProxy; import org.glassfish.jersey.client.spi.AsyncConnectorCallback; import org.glassfish.jersey.client.spi.Connector; import org.glassfish.jersey.internal.util.collection.ByteBufferInputStream; @@ -79,8 +79,10 @@ *
  • {@link ClientProperties#PROXY_USERNAME}
  • *
  • {@link ClientProperties#PROXY_PASSWORD}
  • *
  • {@link ClientProperties#PROXY_PASSWORD}
  • + *
  • {@link JettyClientProperties#DISABLE_COOKIES}
  • * + *
  • {@link JettyClientProperties#ENABLE_SSL_HOSTNAME_VERIFICATION}
  • *
  • {@link JettyClientProperties#PREEMPTIVE_BASIC_AUTHENTICATION}
  • - *
  • {@link JettyClientProperties#DISABLE_COOKIES}
  • + *
  • {@link JettyClientProperties#SYNC_LISTENER_RESPONSE_MAX_SIZE}
  • * *

    * This transport supports both synchronous and asynchronous processing of client requests. @@ -156,18 +158,22 @@ public Jetty10Connector(final Client jaxrsClient, final Configuration config) { Boolean enableHostnameVerification = (Boolean) config.getProperties() .get(JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION); - if (enableHostnameVerification != null && enableHostnameVerification) { - client.getSslContextFactory().setEndpointIdentificationAlgorithm("https"); + if (enableHostnameVerification != null) { + final String verificationAlgorithm = enableHostnameVerification ? "HTTPS" : null; + client.getSslContextFactory().setEndpointIdentificationAlgorithm(verificationAlgorithm); + } + if (jaxrsClient.getHostnameVerifier() != null) { + client.getSslContextFactory().setHostnameVerifier(jaxrsClient.getHostnameVerifier()); } final Object connectTimeout = config.getProperties().get(ClientProperties.CONNECT_TIMEOUT); - if (connectTimeout instanceof Integer cTimeout && cTimeout > 0) { - client.setConnectTimeout(cTimeout); + if (connectTimeout instanceof Integer && (Integer) connectTimeout > 0) { + client.setConnectTimeout((Integer) connectTimeout); } final Object threadPoolSize = config.getProperties().get(ClientProperties.ASYNC_THREADPOOL_SIZE); - if (threadPoolSize instanceof Integer tPoolSize && tPoolSize > 0) { + if (threadPoolSize instanceof Integer && (Integer) threadPoolSize > 0) { final String name = HttpClient.class.getSimpleName() + "@" + hashCode(); - final QueuedThreadPool threadPool = new QueuedThreadPool(tPoolSize); + final QueuedThreadPool threadPool = new QueuedThreadPool((Integer) threadPoolSize); threadPool.setName(name); client.setExecutor(threadPool); } @@ -176,23 +182,21 @@ public Jetty10Connector(final Client jaxrsClient, final Configuration config) { final AuthenticationStore auth = client.getAuthenticationStore(); final Object basicAuthProvider = config.getProperty(JettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION); - if (basicAuthProvider instanceof BasicAuthentication baseAuth) { - auth.addAuthentication(baseAuth); + if ((basicAuthProvider instanceof BasicAuthentication)) { + auth.addAuthentication((BasicAuthentication) basicAuthProvider); } - final Object proxyUri = config.getProperties().get(ClientProperties.PROXY_URI); - if (proxyUri != null) { - final URI u = getProxyUri(proxyUri); + final Optional proxy = ClientProxy.proxyFromConfiguration(config); + proxy.ifPresent(clientProxy -> { final ProxyConfiguration proxyConfig = client.getProxyConfiguration(); - proxyConfig.getProxies().add(new HttpProxy(u.getHost(), u.getPort())); + final URI u = clientProxy.uri(); + proxyConfig.addProxy(new HttpProxy(u.getHost(), u.getPort())); - final Object proxyUsername = config.getProperties().get(ClientProperties.PROXY_USERNAME); - if (proxyUsername != null) { - final Object proxyPassword = config.getProperties().get(ClientProperties.PROXY_PASSWORD); + if (clientProxy.userName() != null) { auth.addAuthentication(new BasicAuthentication(u, "<>", - String.valueOf(proxyUsername), String.valueOf(proxyPassword))); + clientProxy.userName(), clientProxy.password())); } - } + }); if (disableCookies) { client.setCookieStore(new HttpCookieStore.Empty()); @@ -200,9 +204,9 @@ public Jetty10Connector(final Client jaxrsClient, final Configuration config) { final Object slResponseMaxSize = configuration.getProperties() .get(JettyClientProperties.SYNC_LISTENER_RESPONSE_MAX_SIZE); - if (slResponseMaxSize instanceof Integer slResponseMaxSizeC - && slResponseMaxSizeC > 0) { - this.syncListenerResponseMaxSize = Optional.of(slResponseMaxSizeC); + if (slResponseMaxSize instanceof Integer + && (Integer) slResponseMaxSize > 0) { + this.syncListenerResponseMaxSize = Optional.of((Integer) slResponseMaxSize); } else { this.syncListenerResponseMaxSize = Optional.empty(); } @@ -215,17 +219,6 @@ public Jetty10Connector(final Client jaxrsClient, final Configuration config) { this.cookieStore = client.getCookieStore(); } - @SuppressWarnings("ChainOfInstanceofChecks") - private static URI getProxyUri(final Object proxy) { - if (proxy instanceof URI uriProxy) { - return uriProxy; - } else if (proxy instanceof String stringProxy) { - return URI.create(stringProxy); - } else { - throw new ProcessingException(LocalizationMessages.WRONG_PROXY_URI_TYPE(ClientProperties.PROXY_URI)); - } - } - /** * Get the {@link HttpClient}. * @@ -257,7 +250,7 @@ public ClientResponse apply(final ClientRequest jerseyRequest) throws Processing try { final ContentResponse jettyResponse; - if (!syncListenerResponseMaxSize.isPresent()) { + if (syncListenerResponseMaxSize.isEmpty()) { jettyResponse = jettyRequest.send(); } else { final FutureResponseListener listener @@ -317,10 +310,16 @@ private Request translateRequest(final ClientRequest clientRequest) { request.method(clientRequest.getMethod()); request.followRedirects(clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true)); - final Object readTimeout = clientRequest.resolveProperty(ClientProperties.READ_TIMEOUT, -1); - if (readTimeout instanceof Integer rTimeout && rTimeout > 0) { - request.timeout(rTimeout, TimeUnit.MILLISECONDS); + final Integer readTimeout = clientRequest.resolveProperty(ClientProperties.READ_TIMEOUT, -1); + if (readTimeout != null && readTimeout > 0) { + request.timeout(readTimeout, TimeUnit.MILLISECONDS); } + + final Integer totalTimeout = clientRequest.resolveProperty(JettyClientProperties.TOTAL_TIMEOUT, -1); + if (totalTimeout != null && totalTimeout > 0) { + request.timeout(totalTimeout, TimeUnit.MILLISECONDS); + } + return request; } @@ -394,9 +393,9 @@ public Future apply(final ClientRequest jerseyRequest, final AsyncConnectorCa final CompletableFuture responseFuture = new CompletableFuture().whenComplete( (clientResponse, throwable) -> { - if (throwable instanceof CancellationException throwable1) { + if (throwable instanceof CancellationException) { // take care of future cancellation - jettyRequest.abort(throwable1); + jettyRequest.abort(throwable); } }); diff --git a/core/src/main/java/com/kumuluz/ee/EeApplication.java b/core/src/main/java/com/kumuluz/ee/EeApplication.java index 84cd9bb2..f4401325 100644 --- a/core/src/main/java/com/kumuluz/ee/EeApplication.java +++ b/core/src/main/java/com/kumuluz/ee/EeApplication.java @@ -47,6 +47,7 @@ import java.util.logging.Handler; import java.util.logging.LogManager; import java.util.logging.Logger; +import java.util.stream.Collectors; /** * @author Tilen Faganel @@ -65,6 +66,7 @@ public EeApplication() { initialize(); } + @SuppressWarnings("unused") public EeApplication(EeConfig eeConfig) { this.eeConfig = eeConfig; @@ -72,11 +74,12 @@ public EeApplication(EeConfig eeConfig) { initialize(); } - public static void main(String args[]) { + public static void main(String[] args) { - EeApplication app = new EeApplication(); + new EeApplication(); } + @SuppressWarnings("unused") public KumuluzServer getServer() { return this.server.getServer(); } @@ -186,24 +189,24 @@ private void initialize() { List eeRuntimeComponents = eeComponents.stream() .map(e -> new EeRuntimeComponent(e.getType(), e.getName())) - .toList(); + .collect(Collectors.toList()); - List serverEeRuntimeComponents = new ArrayList<>(Arrays.stream(server.getProvidedEeComponents()) + List serverEeRuntimeComponents = Arrays.stream(server.getProvidedEeComponents()) .map(c -> new EeRuntimeComponent(c, server.getName())) - .toList()); + .collect(Collectors.toList()); serverEeRuntimeComponents.addAll(eeRuntimeComponents); eeRuntimeInternal.setEeComponents(serverEeRuntimeComponents); - List eeRuntimeExtensions = new ArrayList<>(eeExtensions.stream() - .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).toList()); + List eeRuntimeExtensions = eeExtensions.stream() + .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).collect(Collectors.toList()); eeRuntimeExtensions.addAll(eeConfigExtensions.stream() - .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).toList()); + .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).collect(Collectors.toList())); eeRuntimeExtensions.addAll(eeLogsExtensions.stream() - .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).toList()); + .map(e -> new EeRuntimeExtension(e.getGroup(), e.getName())).collect(Collectors.toList())); eeRuntimeInternal.setEeExtensions(eeRuntimeExtensions); @@ -258,15 +261,17 @@ private void initialize() { server.getServer().initServer(); // Depending on the server type, initiate server specific functionality - if (server.getServer() instanceof ServletServer servletServer) { + if (server.getServer() instanceof ServletServer) { + + ServletServer servletServer = (ServletServer) server.getServer(); List allExtensions = new ArrayList<>(); allExtensions.addAll(eeExtensions.stream().map(ExtensionWrapper::getExtension) - .toList()); + .collect(Collectors.toList())); allExtensions.addAll(eeConfigExtensions.stream().map(ExtensionWrapper::getExtension) - .toList()); + .collect(Collectors.toList())); allExtensions.addAll(eeLogsExtensions.stream().map(ExtensionWrapper::getExtension) - .toList()); + .collect(Collectors.toList())); servletServer.initWebContext(collectScanLibraries(allExtensions)); // Create and register datasources to the underlying server diff --git a/pom.xml b/pom.xml index 6c215591..a2945ad5 100644 --- a/pom.xml +++ b/pom.xml @@ -29,8 +29,8 @@ https://ee.kumuluz.com - 21 - 21 + 11 + 11 UTF-8 4.0.1