diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/BadURITest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/BadURITest.java index 1af69c4f5f8..4e62047ce2d 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/BadURITest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/BadURITest.java @@ -43,7 +43,6 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.LifeCycle; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -69,7 +68,6 @@ public class BadURITest } @Test - @Disabled("TODO: need to fix ErrorHandler") public void testBadURI() throws Exception { CountDownLatch handlerLatch = new CountDownLatch(1); diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HTTP2CServerTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HTTP2CServerTest.java index 076354932d9..de928de15e7 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HTTP2CServerTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HTTP2CServerTest.java @@ -52,7 +52,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -94,9 +93,7 @@ public class HTTP2CServerTest extends AbstractServerTest } } - // TODO: this test fails on IO.toString(), for some reason the second request does not close the connection. @Test - @Disabled public void testHTTP11Simple() throws Exception { try (Socket client = new Socket("localhost", connector.getLocalPort())) diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java index a732c330ae7..6321d9c4292 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HttpClientTransportOverHTTP2Test.java @@ -78,7 +78,6 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -736,7 +735,6 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest }); } - @Disabled @Test @Tag("external") public void testExternalServer() throws Exception @@ -750,9 +748,7 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest clientConnector.setExecutor(executor); httpClient.start(); -// ContentResponse response = httpClient.GET("https://http2.akamai.com/"); ContentResponse response = httpClient.GET("https://webtide.com/"); - assertEquals(HttpStatus.OK_200, response.getStatus()); httpClient.stop(); diff --git a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java index 709685cbd33..ed5f1846347 100644 --- a/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java +++ b/jetty-core/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/StreamResetTest.java @@ -81,7 +81,6 @@ import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.hamcrest.Matchers; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.awaitility.Awaitility.await; @@ -334,13 +333,7 @@ public class StreamResetTest extends AbstractTest assertTrue(dataLatch.await(5, TimeUnit.SECONDS)); } - // TODO: This test writes after a failure and highlights some problem in the implementation - // of the handling of errors. For example, the request._error field is set by the failure, - // but checked during the succeed of the callback (so cannot turn a failure into a success) - // and also highlights that the implementation should be more precise at severing the link - // between channel and request, possibly where the request only has one field, the channel. @Test - @Disabled public void testAsyncWriteAfterStreamReceivingReset() throws Exception { CountDownLatch commitLatch = new CountDownLatch(1); diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java index 191ce676bf9..fe77b6fe205 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ExternalServerTest.java @@ -31,15 +31,20 @@ import org.eclipse.jetty.http3.client.HTTP3Client; import org.eclipse.jetty.http3.client.transport.HttpClientTransportOverHTTP3; import org.eclipse.jetty.http3.frames.HeadersFrame; import org.eclipse.jetty.util.HostPort; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertTrue; -@Disabled +@Tag("external") public class ExternalServerTest { + private static final Logger LOG = LoggerFactory.getLogger(ExternalServerTest.class); + @Test @Tag("external") public void testExternalServerWithHttpClient() throws Exception @@ -52,8 +57,7 @@ public class ExternalServerTest { URI uri = URI.create("https://maven-central-eu.storage-download.googleapis.com/maven2/org/apache/maven/maven-parent/38/maven-parent-38.pom"); ContentResponse response = httpClient.newRequest(uri).send(); - System.err.println("response = " + response); - System.err.println(response.getContentAsString()); + assertThat(response.getContentAsString(), containsString("maven-parent")); } finally { @@ -69,11 +73,7 @@ public class ExternalServerTest client.start(); try { - HostPort hostPort = new HostPort("google.com:443"); -// HostPort hostPort = new HostPort("nghttp2.org:4433"); -// HostPort hostPort = new HostPort("quic.tech:8443"); -// HostPort hostPort = new HostPort("h2o.examp1e.net:443"); -// HostPort hostPort = new HostPort("test.privateoctopus.com:4433"); + HostPort hostPort = new HostPort("maven-central-eu.storage-download.googleapis.com:443"); Session.Client session = client.connect(new InetSocketAddress(hostPort.getHost(), hostPort.getPort()), new Session.Client.Listener() {}) .get(5, TimeUnit.SECONDS); @@ -85,7 +85,8 @@ public class ExternalServerTest @Override public void onResponse(Stream.Client stream, HeadersFrame frame) { - System.err.println("RESPONSE HEADER = " + frame); + if (LOG.isDebugEnabled()) + LOG.debug("RESPONSE HEADER = {}", frame); if (frame.isLast()) { requestLatch.countDown(); @@ -98,7 +99,8 @@ public class ExternalServerTest public void onDataAvailable(Stream.Client stream) { Stream.Data data = stream.readData(); - System.err.println("RESPONSE DATA = " + data); + if (LOG.isDebugEnabled()) + LOG.debug("RESPONSE DATA = {}", data); if (data != null) { data.release(); @@ -114,7 +116,8 @@ public class ExternalServerTest @Override public void onTrailer(Stream.Client stream, HeadersFrame frame) { - System.err.println("RESPONSE TRAILER = " + frame); + if (LOG.isDebugEnabled()) + LOG.debug("RESPONSE TRAILER = {}", frame); requestLatch.countDown(); } }); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java index 512af5fbeb1..0b8db88ed07 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/ErrorHandlerTest.java @@ -153,6 +153,7 @@ public class ErrorHandlerTest assertThat("Response status code", response.getStatus(), is(404)); assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0)); assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=ISO-8859-1")); + assertThat(response.get(HttpHeader.DATE), notNullValue()); assertThat(response.getContent(), containsString("content=\"text/html;charset=ISO-8859-1\"")); assertContent(response); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java index 48f60baa62e..7c0356cb399 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java @@ -24,12 +24,10 @@ import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Content; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -@Disabled // TODO public class HalfCloseTest { @Test diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletApiResponse.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletApiResponse.java index aa073b32df9..07e6c11062d 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletApiResponse.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletApiResponse.java @@ -227,7 +227,12 @@ public class ServletApiResponse implements HttpServletResponse } } } - default -> _response.getState().sendError(sc, msg); + default -> + { + if (isCommitted()) + throw new IllegalStateException("Committed"); + _response.getState().sendError(sc, msg); + } } } diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java index 431eedb82dd..e0e2e203c38 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletContextResponse.java @@ -379,7 +379,6 @@ public class ServletContextResponse extends ContextResponse case CACHE_CONTROL: case LAST_MODIFIED: case EXPIRES: - case DATE: case VARY: i.remove(); continue; diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ErrorPageTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ErrorPageTest.java index 9411a75eb95..95874a83e15 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ErrorPageTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ErrorPageTest.java @@ -59,6 +59,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -156,6 +157,7 @@ public class ErrorPageTest HttpTester.Response response = HttpTester.parseResponse(rawResponse); assertThat(response.getStatus(), is(595)); + assertThat(response.get(HttpHeader.DATE), notNullValue()); String actualContentType = response.get(HttpHeader.CONTENT_TYPE); // should not expect to see charset line from servlet assertThat(actualContentType, not(containsString("charset=US-ASCII"))); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/JakartaWebSocketClientContainer.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/JakartaWebSocketClientContainer.java index f60b3366ea4..5e17f9311a9 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/JakartaWebSocketClientContainer.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/JakartaWebSocketClientContainer.java @@ -16,7 +16,6 @@ package org.eclipse.jetty.ee10.websocket.jakarta.client; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; @@ -169,10 +168,12 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i return error; } - private Session connect(ConfiguredEndpoint configuredEndpoint, URI destURI) throws IOException + private Session connect(ConfiguredEndpoint configuredEndpoint, URI destURI) throws IOException, DeploymentException { - Objects.requireNonNull(configuredEndpoint, "WebSocket configured endpoint cannot be null"); - Objects.requireNonNull(destURI, "Destination URI cannot be null"); + if (configuredEndpoint == null) + throw new DeploymentException("WebSocket configured endpoint cannot be null"); + if (destURI == null) + throw new DeploymentException("Destination URI cannot be null"); JakartaClientUpgradeRequest upgradeRequest = new JakartaClientUpgradeRequest(this, getWebSocketCoreClient(), destURI, configuredEndpoint); @@ -202,8 +203,8 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i catch (ExecutionException e) { var cause = e.getCause(); - if (cause instanceof RuntimeException) - throw (RuntimeException)cause; + if (cause instanceof DeploymentException) + throw (DeploymentException)cause; if (cause instanceof IOException) throw (IOException)cause; throw new IOException(cause); @@ -286,7 +287,6 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i ClientEndpoint anno = endpoint.getClass().getAnnotation(ClientEndpoint.class); if (anno == null) throw new DeploymentException("Could not get ClientEndpoint annotation for " + endpoint.getClass().getName()); - return new AnnotatedClientEndpointConfig(anno, components); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java index 5d402a439e6..947b6daaaee 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java @@ -18,37 +18,31 @@ import java.util.List; import jakarta.websocket.ClientEndpoint; import jakarta.websocket.ClientEndpointConfig; +import jakarta.websocket.DeploymentException; import org.eclipse.jetty.ee10.websocket.jakarta.common.ClientEndpointConfigWrapper; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; public class AnnotatedClientEndpointConfig extends ClientEndpointConfigWrapper { - public AnnotatedClientEndpointConfig(ClientEndpoint anno, WebSocketComponents components) + public AnnotatedClientEndpointConfig(ClientEndpoint anno, WebSocketComponents components) throws DeploymentException { - Configurator configurator; try { - configurator = components.getObjectFactory().createInstance(anno.configurator()); + Configurator configurator = components.getObjectFactory().createInstance(anno.configurator()); + ClientEndpointConfig build = Builder.create() + .encoders(List.of(anno.encoders())) + .decoders(List.of(anno.decoders())) + .preferredSubprotocols(List.of(anno.subprotocols())) + .extensions(Collections.emptyList()) + .configurator(configurator) + .build(); + init(build); } - catch (Exception e) + catch (Throwable t) { - StringBuilder err = new StringBuilder(); - err.append("Unable to instantiate ClientEndpoint.configurator() of "); - err.append(anno.configurator().getName()); - err.append(" defined as annotation in "); - err.append(anno.getClass().getName()); - throw new InvalidWebSocketException(err.toString(), e); + String err = "Unable to instantiate ClientEndpoint.configurator() of " + anno.configurator().getName() + + " defined as annotation in " + anno.getClass().getName(); + throw new DeploymentException(err, t); } - - ClientEndpointConfig build = Builder.create() - .encoders(List.of(anno.encoders())) - .decoders(List.of(anno.decoders())) - .preferredSubprotocols(List.of(anno.subprotocols())) - .extensions(Collections.emptyList()) - .configurator(configurator) - .build(); - - init(build); } } diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Response.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Response.java index 866a0de6146..5142d10373d 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Response.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/Response.java @@ -1217,7 +1217,6 @@ public class Response implements HttpServletResponse case LAST_MODIFIED: case EXPIRES: case ETAG: - case DATE: case VARY: i.remove(); continue; diff --git a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/ResponseTest.java b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/ResponseTest.java index 12555ab4a9e..83d9cedaa41 100644 --- a/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/ResponseTest.java +++ b/jetty-ee9/jetty-ee9-nested/src/test/java/org/eclipse/jetty/ee9/nested/ResponseTest.java @@ -2052,6 +2052,7 @@ public class ResponseTest response.setContentType("some/type"); response.setContentLength(3); response.setHeader(HttpHeader.EXPIRES, "never"); + response.setHeader(HttpHeader.DATE, "2000-01-01"); response.setHeader("SomeHeader", "SomeValue"); @@ -2068,6 +2069,7 @@ public class ResponseTest // check arbitrary header still set assertThat(response.getHeader("SomeHeader"), is("SomeValue")); + assertThat(response.getHeader("Date"), is("2000-01-01")); // check cookies are still there Enumeration set = response.getHttpFields().getValues("Set-Cookie"); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/JakartaWebSocketClientContainer.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/JakartaWebSocketClientContainer.java index 48adf25dc4f..1180bb30dce 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/JakartaWebSocketClientContainer.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/JakartaWebSocketClientContainer.java @@ -16,7 +16,6 @@ package org.eclipse.jetty.ee9.websocket.jakarta.client; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; @@ -169,10 +168,12 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i return error; } - private Session connect(ConfiguredEndpoint configuredEndpoint, URI destURI) throws IOException + private Session connect(ConfiguredEndpoint configuredEndpoint, URI destURI) throws IOException, DeploymentException { - Objects.requireNonNull(configuredEndpoint, "WebSocket configured endpoint cannot be null"); - Objects.requireNonNull(destURI, "Destination URI cannot be null"); + if (configuredEndpoint == null) + throw new DeploymentException("WebSocket configured endpoint cannot be null"); + if (destURI == null) + throw new DeploymentException("Destination URI cannot be null"); JakartaClientUpgradeRequest upgradeRequest = new JakartaClientUpgradeRequest(this, getWebSocketCoreClient(), destURI, configuredEndpoint); @@ -202,8 +203,8 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i catch (ExecutionException e) { var cause = e.getCause(); - if (cause instanceof RuntimeException) - throw (RuntimeException)cause; + if (cause instanceof DeploymentException) + throw (DeploymentException)cause; if (cause instanceof IOException) throw (IOException)cause; throw new IOException(cause); @@ -286,7 +287,6 @@ public class JakartaWebSocketClientContainer extends JakartaWebSocketContainer i ClientEndpoint anno = endpoint.getClass().getAnnotation(ClientEndpoint.class); if (anno == null) throw new DeploymentException("Could not get ClientEndpoint annotation for " + endpoint.getClass().getName()); - return new AnnotatedClientEndpointConfig(anno, components); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java index 9dfb8cbc5b1..33658a872f7 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-client/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/client/internal/AnnotatedClientEndpointConfig.java @@ -18,37 +18,31 @@ import java.util.List; import jakarta.websocket.ClientEndpoint; import jakarta.websocket.ClientEndpointConfig; +import jakarta.websocket.DeploymentException; import org.eclipse.jetty.ee9.websocket.jakarta.common.ClientEndpointConfigWrapper; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; public class AnnotatedClientEndpointConfig extends ClientEndpointConfigWrapper { - public AnnotatedClientEndpointConfig(ClientEndpoint anno, WebSocketComponents components) + public AnnotatedClientEndpointConfig(ClientEndpoint anno, WebSocketComponents components) throws DeploymentException { - Configurator configurator; try { - configurator = components.getObjectFactory().createInstance(anno.configurator()); + Configurator configurator = components.getObjectFactory().createInstance(anno.configurator()); + ClientEndpointConfig build = Builder.create() + .encoders(List.of(anno.encoders())) + .decoders(List.of(anno.decoders())) + .preferredSubprotocols(List.of(anno.subprotocols())) + .extensions(Collections.emptyList()) + .configurator(configurator) + .build(); + init(build); } - catch (Exception e) + catch (Throwable t) { - StringBuilder err = new StringBuilder(); - err.append("Unable to instantiate ClientEndpoint.configurator() of "); - err.append(anno.configurator().getName()); - err.append(" defined as annotation in "); - err.append(anno.getClass().getName()); - throw new InvalidWebSocketException(err.toString(), e); + String err = "Unable to instantiate ClientEndpoint.configurator() of " + anno.configurator().getName() + + " defined as annotation in " + anno.getClass().getName(); + throw new DeploymentException(err, t); } - - ClientEndpointConfig build = Builder.create() - .encoders(List.of(anno.encoders())) - .decoders(List.of(anno.decoders())) - .preferredSubprotocols(List.of(anno.subprotocols())) - .extensions(Collections.emptyList()) - .configurator(configurator) - .build(); - - init(build); } }