[Bug 65757] Async WriteListener#onWritePossible never called

2021-12-21 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65757

--- Comment #2 from Remy Maucherat  ---
This is caused by the fact that the logic identifies this as a container
thread, which is not enough in that edge case. Basically there is a need to
dispatch if the thread is not the original request thread, which is now hard to
identify (I cannot immediately think of a good way) and I don't think this is
going to be fixed.

If this wontfix resolution is validated, then the issue will be documented in
the known issues (it pretty much has been for the past 6 years as the test case
was there and ignored).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Add support for the new TLS configuration API for client connections

2021-12-21 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e03da0f2245af6381fd5081ef5f7436a740b8dec
Author: Mark Thomas 
AuthorDate: Tue Dec 21 14:42:50 2021 +

Add support for the new TLS configuration API for client connections
---
 java/jakarta/websocket/ClientEndpointConfig.java   | 20 +---
 .../websocket/DefaultClientEndpointConfig.java | 13 -
 .../tomcat/websocket/WsWebSocketContainer.java | 14 --
 res/checkstyle/jakarta-import-control.xml  |  1 +
 .../websocket/TestWsWebSocketContainerSSL.java | 58 +-
 webapps/docs/changelog.xml |  4 ++
 6 files changed, 98 insertions(+), 12 deletions(-)

diff --git a/java/jakarta/websocket/ClientEndpointConfig.java 
b/java/jakarta/websocket/ClientEndpointConfig.java
index a56af4b..fbf752b 100644
--- a/java/jakarta/websocket/ClientEndpointConfig.java
+++ b/java/jakarta/websocket/ClientEndpointConfig.java
@@ -20,12 +20,16 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import javax.net.ssl.SSLContext;
+
 public interface ClientEndpointConfig extends EndpointConfig {
 
 List getPreferredSubprotocols();
 
 List getExtensions();
 
+SSLContext getSSLContext();
+
 public Configurator getConfigurator();
 
 public final class Builder {
@@ -46,15 +50,13 @@ public interface ClientEndpointConfig extends 
EndpointConfig {
 private Configurator configurator = DEFAULT_CONFIGURATOR;
 private List preferredSubprotocols = Collections.emptyList();
 private List extensions = Collections.emptyList();
-private List> encoders =
-Collections.emptyList();
-private List> decoders =
-Collections.emptyList();
-
+private List> encoders = 
Collections.emptyList();
+private List> decoders = 
Collections.emptyList();
+private SSLContext sslContext = null;
 
 public ClientEndpointConfig build() {
 return new DefaultClientEndpointConfig(preferredSubprotocols,
-extensions, encoders, decoders, configurator);
+extensions, encoders, decoders, sslContext, configurator);
 }
 
 
@@ -110,6 +112,12 @@ public interface ClientEndpointConfig extends 
EndpointConfig {
 }
 return this;
 }
+
+
+public Builder sslContext(SSLContext sslContext) {
+this.sslContext = sslContext;
+return this;
+}
 }
 
 
diff --git a/java/jakarta/websocket/DefaultClientEndpointConfig.java 
b/java/jakarta/websocket/DefaultClientEndpointConfig.java
index e166925..cf29809 100644
--- a/java/jakarta/websocket/DefaultClientEndpointConfig.java
+++ b/java/jakarta/websocket/DefaultClientEndpointConfig.java
@@ -20,12 +20,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.net.ssl.SSLContext;
+
 final class DefaultClientEndpointConfig implements ClientEndpointConfig {
 
 private final List preferredSubprotocols;
 private final List extensions;
 private final List> encoders;
 private final List> decoders;
+private final SSLContext sslContext;
 private final Map userProperties = new 
ConcurrentHashMap<>();
 private final Configurator configurator;
 
@@ -34,11 +37,13 @@ final class DefaultClientEndpointConfig implements 
ClientEndpointConfig {
 List extensions,
 List> encoders,
 List> decoders,
+SSLContext sslContext,
 Configurator configurator) {
 this.preferredSubprotocols = preferredSubprotocols;
 this.extensions = extensions;
-this.decoders = decoders;
 this.encoders = encoders;
+this.decoders = decoders;
+this.sslContext = sslContext;
 this.configurator = configurator;
 }
 
@@ -68,6 +73,12 @@ final class DefaultClientEndpointConfig implements 
ClientEndpointConfig {
 
 
 @Override
+public SSLContext getSSLContext() {
+return sslContext;
+}
+
+
+@Override
 public final Map getUserProperties() {
 return userProperties;
 }
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 7792122..e6c5f92 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -316,7 +316,7 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
 // Regardless of whether a non-secure wrapper was created for a
 // proxy CONNECT, need to use TLS from this point on so wrap 
the
 // original AsynchronousSocketChannel
-SSLEngine sslEngine = createSSLEngine(userProperties, host, 
port);
+

[tomcat] 02/02: Deprecate the pre-WebSocket 2.1 client TLS configuration approach

2021-12-21 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 7aabd5346ddc509812941d3a9203414224720aa8
Author: Mark Thomas 
AuthorDate: Tue Dec 21 14:52:17 2021 +

Deprecate the pre-WebSocket 2.1 client TLS configuration approach
---
 java/org/apache/tomcat/websocket/Constants.java | 12 
 webapps/docs/web-socket-howto.xml   | 10 +++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/Constants.java 
b/java/org/apache/tomcat/websocket/Constants.java
index 0c4e21b..85a6034 100644
--- a/java/org/apache/tomcat/websocket/Constants.java
+++ b/java/org/apache/tomcat/websocket/Constants.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import jakarta.websocket.ClientEndpointConfig;
 import jakarta.websocket.Extension;
 
 /**
@@ -50,19 +51,30 @@ public class Constants {
  * Property name to set to configure the value that is passed to
  * {@link javax.net.ssl.SSLEngine#setEnabledProtocols(String[])}. The value
  * should be a comma separated string.
+ *
+ * @deprecated This will be removed in Tomcat 11.
+ * Use {@link ClientEndpointConfig#getSSLContext()}
  */
+@Deprecated(forRemoval = true, since = "Tomcat 10.1.x")
 public static final String SSL_PROTOCOLS_PROPERTY =
 "org.apache.tomcat.websocket.SSL_PROTOCOLS";
+@Deprecated(forRemoval = true, since = "Tomcat 10.1.x")
 public static final String SSL_TRUSTSTORE_PROPERTY =
 "org.apache.tomcat.websocket.SSL_TRUSTSTORE";
+@Deprecated(forRemoval = true, since = "Tomcat 10.1.x")
 public static final String SSL_TRUSTSTORE_PWD_PROPERTY =
 "org.apache.tomcat.websocket.SSL_TRUSTSTORE_PWD";
+@Deprecated(forRemoval = true, since = "Tomcat 10.1.x")
 public static final String SSL_TRUSTSTORE_PWD_DEFAULT = "changeit";
 /**
  * Property name to set to configure used SSLContext. The value should be 
an
  * instance of SSLContext. If this property is present, the SSL_TRUSTSTORE*
  * properties are ignored.
+ *
+ * @deprecated This will be removed in Tomcat 11.
+ * Use {@link ClientEndpointConfig#getSSLContext()}
  */
+@Deprecated(forRemoval = true, since = "Tomcat 10.1.x")
 public static final String SSL_CONTEXT_PROPERTY =
 "org.apache.tomcat.websocket.SSL_CONTEXT";
 /**
diff --git a/webapps/docs/web-socket-howto.xml 
b/webapps/docs/web-socket-howto.xml
index e97b00b..b6ea851 100644
--- a/webapps/docs/web-socket-howto.xml
+++ b/webapps/docs/web-socket-howto.xml
@@ -114,9 +114,13 @@
seconds).
 
 When using the WebSocket client to connect to secure server endpoints, the
-   client SSL configuration is controlled by the userProperties
-   of the provided jakarta.websocket.ClientEndpointConfig. The
-   following user properties are supported:
+   client SSL configuration should be configured via
+   jakarta.websocket.ClientEndpointConfig.getSSLContext(). Tomcat
+   10.1.x still supports the pre-WebSocket 2.1 configuration method where TLS 
+   configuration was via the userProperties of the provided
+   jakarta.websocket.ClientEndpointConfig. However, this approach
+   is deprecated and will be removed in Tomcat 11. The following user 
properties
+   are supported:

  org.apache.tomcat.websocket.SSL_CONTEXT
  org.apache.tomcat.websocket.SSL_PROTOCOLS

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated (714236a -> 7aabd53)

2021-12-21 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from 714236a  Switch again to shared scope for the context
 new e03da0f  Add support for the new TLS configuration API for client 
connections
 new 7aabd53  Deprecate the pre-WebSocket 2.1 client TLS configuration 
approach

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/jakarta/websocket/ClientEndpointConfig.java   | 20 +---
 .../websocket/DefaultClientEndpointConfig.java | 13 -
 java/org/apache/tomcat/websocket/Constants.java| 12 +
 .../tomcat/websocket/WsWebSocketContainer.java | 14 --
 res/checkstyle/jakarta-import-control.xml  |  1 +
 .../websocket/TestWsWebSocketContainerSSL.java | 58 +-
 webapps/docs/changelog.xml |  4 ++
 webapps/docs/web-socket-howto.xml  | 10 ++--
 8 files changed, 117 insertions(+), 15 deletions(-)

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated: Fix deprecation warnings

2021-12-21 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new ec03e1e  Fix deprecation warnings
ec03e1e is described below

commit ec03e1e9e47da3339faa1252a6f5432abf1b3e9e
Author: Mark Thomas 
AuthorDate: Tue Dec 21 15:02:50 2021 +

Fix deprecation warnings
---
 .../tomcat/websocket/WsWebSocketContainer.java |   1 +
 .../websocket/TestWebSocketFrameClientSSL.java | 140 -
 .../websocket/TestWsWebSocketContainerSSL.java |   3 +-
 3 files changed, 141 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index e6c5f92..608e854 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -900,6 +900,7 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
 }
 
 
+@SuppressWarnings("removal")
 private SSLEngine createSSLEngine(ClientEndpointConfig 
clientEndpointConfig, String host, int port)
 throws DeploymentException {
 
diff --git a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java 
b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
index 8adc942..4323cb9 100644
--- a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
+++ b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
@@ -16,7 +16,11 @@
  */
 package org.apache.tomcat.websocket;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
 import java.net.URI;
+import java.security.KeyStore;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -24,6 +28,9 @@ import java.util.Queue;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
 import jakarta.websocket.ClientEndpointConfig;
 import jakarta.websocket.ContainerProvider;
 import jakarta.websocket.MessageHandler;
@@ -43,6 +50,7 @@ import org.apache.catalina.core.StandardServer;
 import org.apache.catalina.servlets.DefaultServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.tomcat.util.net.TesterSupport;
+import org.apache.tomcat.util.security.KeyStoreUtil;
 import org.apache.tomcat.websocket.TesterMessageCountClient.BasicText;
 import org.apache.tomcat.websocket.TesterMessageCountClient.SleepingText;
 import 
org.apache.tomcat.websocket.TesterMessageCountClient.TesterProgrammaticEndpoint;
@@ -73,8 +81,9 @@ public class TestWebSocketFrameClientSSL extends 
WebSocketBaseTest {
 public String sslImplementationName;
 
 
+@SuppressWarnings("removal")
 @Test
-public void testConnectToServerEndpoint() throws Exception {
+public void testConnectToServerEndpointLegacy() throws Exception {
 Tomcat tomcat = getTomcatInstance();
 // No file system docBase required
 Context ctx = tomcat.addContext("", null);
@@ -119,7 +128,62 @@ public class TestWebSocketFrameClientSSL extends 
WebSocketBaseTest {
 
 
 @Test
-public void testBug56032() throws Exception {
+public void testConnectToServerEndpoint() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+// No file system docBase required
+Context ctx = tomcat.addContext("", null);
+
ctx.addApplicationListener(TesterFirehoseServer.ConfigInline.class.getName());
+Tomcat.addServlet(ctx, "default", new DefaultServlet());
+ctx.addServletMappingDecoded("/", "default");
+
+tomcat.start();
+
+WebSocketContainer wsContainer = 
ContainerProvider.getWebSocketContainer();
+
+// Build the SSLContext
+SSLContext sslContext = SSLContext.getInstance("TLS");
+File trustStoreFile = new File(TesterSupport.CA_JKS);
+KeyStore ks = KeyStore.getInstance("JKS");
+try (InputStream is = new FileInputStream(trustStoreFile)) {
+KeyStoreUtil.load(ks, is, TesterSupport.JKS_PASS.toCharArray());
+}
+TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+tmf.init(ks);
+sslContext.init(null,  tmf.getTrustManagers(), null);
+
+ClientEndpointConfig clientEndpointConfig =
+
ClientEndpointConfig.Builder.create().sslContext(sslContext).build();
+
+Session wsSession = wsContainer.connectToServer(
+TesterProgrammaticEndpoint.class,
+clientEndpointConfig,
+new URI("wss://localhost:" + getPort() +
+TesterFirehoseServer.PATH));
+CountDownLatch latch =
+new CountDownLatch(TesterFirehoseServer.MESSAGE_COUNT);
+BasicTex

[Bug 65757] Async WriteListener#onWritePossible never called

2021-12-21 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65757

--- Comment #3 from Remy Maucherat  ---
Created attachment 38138
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38138&action=edit
Patch

The idea is to try to identify the original processing thread better. Unless I
missed something, this is only useful for the Servlet container.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated: Checkstyle

2021-12-21 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
 new 0894720  Checkstyle
0894720 is described below

commit 08947203ce75072df68f3a7ef87e3a581314310f
Author: remm 
AuthorDate: Tue Dec 21 23:24:37 2021 +0100

Checkstyle
---
 webapps/docs/web-socket-howto.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/web-socket-howto.xml 
b/webapps/docs/web-socket-howto.xml
index b6ea851..92f 100644
--- a/webapps/docs/web-socket-howto.xml
+++ b/webapps/docs/web-socket-howto.xml
@@ -116,7 +116,7 @@
 When using the WebSocket client to connect to secure server endpoints, the
client SSL configuration should be configured via
jakarta.websocket.ClientEndpointConfig.getSSLContext(). Tomcat
-   10.1.x still supports the pre-WebSocket 2.1 configuration method where TLS 
+   10.1.x still supports the pre-WebSocket 2.1 configuration method where TLS
configuration was via the userProperties of the provided
jakarta.websocket.ClientEndpointConfig. However, this approach
is deprecated and will be removed in Tomcat 11. The following user 
properties

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org