buildbot success in on tomcat-85-trunk

2021-05-05 Thread buildbot
The Buildbot has detected a restored build on builder tomcat-85-trunk while 
building tomcat. Full details are available at:
https://ci.apache.org/builders/tomcat-85-trunk/builds/2710

Buildbot URL: https://ci.apache.org/

Buildslave for this Build: asf946_ubuntu

Build Reason: The AnyBranchScheduler scheduler named 'on-tomcat-85-commit' 
triggered this build
Build Source Stamp: [branch 8.5.x] 4eff5e04156a7f4f25c6615835689d616df9cda3
Blamelist: remm 

Build succeeded!

Sincerely,
 -The Buildbot




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



[tomcat] branch master updated: Drop docs on runtime conversion

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

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


The following commit(s) were added to refs/heads/master by this push:
 new 6ae6242  Drop docs on runtime conversion
6ae6242 is described below

commit 6ae6242d29b980f44c46a82dbccc9d854c4930d1
Author: remm 
AuthorDate: Wed May 5 17:21:39 2021 +0200

Drop docs on runtime conversion

Just noticed annotation scanning avoids it (no surprise since it doesn't
use classloading), and this causes too many problems to be useful.
---
 webapps/docs/config/loader.xml | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/webapps/docs/config/loader.xml b/webapps/docs/config/loader.xml
index ddd0d62..16cb521 100644
--- a/webapps/docs/config/loader.xml
+++ b/webapps/docs/config/loader.xml
@@ -103,17 +103,6 @@
 
 
 
-  
-If the Tomcat JakartaEE Migration Tool JAR is placed in the Catalina
-lib folder, this attribute allows using it. The value of
-the attribute should be the desired profile name for the conversion.
-If an invalid value is specified, the TOMCAT profile will
-be used, which includes all javax classes which are used by Tomcat.
-Only classes will be converted, classloader resources (loaded using
-getResource or getResourceAsStream will not
-be processed).
-  
-
   
 Java class name of the java.lang.ClassLoader
 implementation class to use. Custom implementations must extend

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



[tomcat] branch 8.5.x updated (4eff5e0 -> 38aff8f)

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

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


from 4eff5e0  Java 7 compatibility
 new d3b3552  Refactor InstanceManager lookup
 new e5ee679  Refactor with a view towards using the InstanceManager with 
decoders
 new def4c1a  Create/destroy Decoders via the InstanceManager (BZ 65262)
 new 38aff8f  Complete fix for BZ 65262. Encoders and decoders now use 
InstanceManager

The 4 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:
 .../tomcat/websocket/LocalStrings.properties   |  1 +
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 79 --
 .../tomcat/websocket/WsRemoteEndpointImplBase.java | 20 +-
 java/org/apache/tomcat/websocket/WsSession.java| 29 +++-
 .../tomcat/websocket/WsWebSocketContainer.java |  8 ++-
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 42 +++-
 .../pojo/PojoMessageHandlerWholeBinary.java| 22 ++
 .../pojo/PojoMessageHandlerWholeText.java  | 21 ++
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java | 22 +++---
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 webapps/docs/changelog.xml |  6 +-
 16 files changed, 207 insertions(+), 97 deletions(-)

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



[tomcat] 02/04: Refactor with a view towards using the InstanceManager with decoders

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

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

commit e5ee679cbca26a2468a3803bfa44074a62208ea6
Author: Mark Thomas 
AuthorDate: Wed May 5 12:57:56 2021 +0100

Refactor with a view towards using the InstanceManager with decoders
---
 java/org/apache/tomcat/websocket/WsSession.java|  2 +-
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java | 14 +-
 .../websocket/pojo/PojoMessageHandlerWholeBinary.java  | 11 ---
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeText.java | 10 --
 4 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index 39a2684..c090c20 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -749,7 +749,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
+InstanceManager instanceManager = getInstanceManager();
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
index aa4abbe..d2b0f12 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
@@ -18,8 +18,11 @@ package org.apache.tomcat.websocket.pojo;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.websocket.DecodeException;
+import javax.websocket.Decoder;
 import javax.websocket.MessageHandler;
 import javax.websocket.Session;
 
@@ -34,6 +37,8 @@ import org.apache.tomcat.websocket.WsSession;
 public abstract class PojoMessageHandlerWholeBase
 extends PojoMessageHandlerBase implements MessageHandler.Whole {
 
+protected final List decoders = new ArrayList<>();
+
 public PojoMessageHandlerWholeBase(Object pojo, Method method,
 Session session, Object[] params, int indexPayload,
 boolean convert, int indexSession, long maxMessageSize) {
@@ -84,11 +89,18 @@ public abstract class PojoMessageHandlerWholeBase
 processResult(result);
 }
 
+
+protected void onClose() {
+for (Decoder decoder : decoders) {
+decoder.destroy();
+}
+}
+
+
 protected Object convert(T message) {
 return message;
 }
 
 
 protected abstract Object decode(T message) throws DecodeException;
-protected abstract void onClose();
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
index e4756f6..0444d3d 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.websocket.DecodeException;
@@ -41,8 +40,6 @@ public class PojoMessageHandlerWholeBinary
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeBinary.class);
 
-private final List decoders = new ArrayList<>();
-
 private final boolean isForInputStream;
 
 public PojoMessageHandlerWholeBinary(Object pojo, Method method,
@@ -120,12 +117,4 @@ public class PojoMessageHandlerWholeBinary
 return array;
 }
 }
-
-
-@Override
-protected void onClose() {
-for (Decoder decoder : decoders) {
-decoder.destroy();
-}
-}
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
index 3ec4bd7..fd16273 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
@@ -19,7 +19,6 @@ package org.apache.tomcat.websocket.pojo;
 import java.io.IOException;
 import java.io.StringReader;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.websocket.DecodeException;
@@ -42,7 +41,6 @@ public class PojoMessageHandlerWholeText
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeText.class);
 
-   

[tomcat] 03/04: Create/destroy Decoders via the InstanceManager (BZ 65262)

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

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

commit def4c1ab9bb478b57dcf8baa9276d0bd8fcf53e7
Author: Mark Thomas 
AuthorDate: Wed Apr 28 12:47:31 2021 +0100

Create/destroy Decoders via the InstanceManager (BZ 65262)
---
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 79 --
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 28 
 .../pojo/PojoMessageHandlerWholeBinary.java| 11 ++-
 .../pojo/PojoMessageHandlerWholeText.java  | 11 ++-
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java |  2 +-
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 11 files changed, 144 insertions(+), 41 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/PojoClassHolder.java 
b/java/org/apache/tomcat/websocket/PojoClassHolder.java
index ef11fce..dcfa7d4 100644
--- a/java/org/apache/tomcat/websocket/PojoClassHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoClassHolder.java
@@ -53,7 +53,7 @@ public class PojoClassHolder implements ClientEndpointHolder {
 } else {
 pojo = instanceManager.newInstance(pojoClazz);
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 } catch (ReflectiveOperationException | SecurityException | 
NamingException e) {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceCreationFailed"),
 e);
 }
diff --git a/java/org/apache/tomcat/websocket/PojoHolder.java 
b/java/org/apache/tomcat/websocket/PojoHolder.java
index 166a934..d1604d1 100644
--- a/java/org/apache/tomcat/websocket/PojoHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoHolder.java
@@ -54,6 +54,6 @@ public class PojoHolder implements ClientEndpointHolder {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceRegistrationFailed"),
 e);
 }
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 }
 }
diff --git a/java/org/apache/tomcat/websocket/Util.java 
b/java/org/apache/tomcat/websocket/Util.java
index 63009a6..fe311b6 100644
--- a/java/org/apache/tomcat/websocket/Util.java
+++ b/java/org/apache/tomcat/websocket/Util.java
@@ -33,6 +33,7 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+import javax.naming.NamingException;
 import javax.websocket.CloseReason.CloseCode;
 import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.Decoder;
@@ -48,6 +49,7 @@ import javax.websocket.MessageHandler;
 import javax.websocket.PongMessage;
 import javax.websocket.Session;
 
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerPartialBinary;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBinary;
@@ -330,26 +332,59 @@ public class Util {
 }
 
 
-public static List getDecoders(
-List> decoderClazzes)
-throws DeploymentException{
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzes Decoder implementation classes
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ *
+ * @deprecated Will be removed in Tomcat 10.1.x.
+ * Use {@link Util#getDecoders(List, InstanceManager)}
+ */
+@Deprecated
+public static List getDecoders(List> decoderClazzes)
+throws DeploymentException {
+return getDecoders(decoderClazzes, null);
+}
+
+
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzesDecoder implementation classes
+ * @param instanceManager   Instance manager to use to create Decoder
+ *  instances
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ */
+public static List getDecoders(List> decoderClazzes,
+InstanceManager instanceManager) throws DeploymentException{
 
 List result = new ArrayList<>();
 if (decoderClazzes != null)

[tomcat] 04/04: Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

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

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

commit 38aff8f0ee8a5cfa2b383bd56a053db6d59d50c3
Author: Mark Thomas 
AuthorDate: Wed May 5 15:14:30 2021 +0100

Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

https://bz.apache.org/bugzilla/show_bug.cgi?id=65262
---
 .../apache/tomcat/websocket/LocalStrings.properties  |  1 +
 .../tomcat/websocket/WsRemoteEndpointImplBase.java   | 20 ++--
 .../tomcat/websocket/server/WsServerContainer.java   | 20 +---
 webapps/docs/changelog.xml   |  6 +++---
 4 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties 
b/java/org/apache/tomcat/websocket/LocalStrings.properties
index ae54da0..fbd7bfd 100644
--- a/java/org/apache/tomcat/websocket/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/LocalStrings.properties
@@ -92,6 +92,7 @@ wsRemoteEndpoint.closed=Message will not be sent because the 
WebSocket session h
 wsRemoteEndpoint.closedDuringMessage=The remainder of the message will not be 
sent because the WebSocket session has been closed
 wsRemoteEndpoint.closedOutputStream=This method may not be called as the 
OutputStream has been closed
 wsRemoteEndpoint.closedWriter=This method may not be called as the Writer has 
been closed
+wsRemoteEndpoint.encoderDestoryFailed=Failed to destroy the encoder of type 
[{0}]
 wsRemoteEndpoint.flushOnCloseFailed=Batched messages still enabled after 
session has been closed. Unable to flush remaining batched message.
 wsRemoteEndpoint.invalidEncoder=The specified encoder of type [{0}] could not 
be instantiated
 wsRemoteEndpoint.noEncoder=No encoder specified for object of class [{0}]
diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
index 18c723a..11f6fd4 100644
--- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
+++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
@@ -19,6 +19,7 @@ package org.apache.tomcat.websocket;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -33,6 +34,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.naming.NamingException;
 import javax.websocket.CloseReason;
 import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.DeploymentException;
@@ -45,6 +47,7 @@ import javax.websocket.SendResult;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.Utf8Encoder;
 import org.apache.tomcat.util.res.StringManager;
@@ -704,10 +707,15 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 for (Class encoderClazz :
 endpointConfig.getEncoders()) {
 Encoder instance;
+InstanceManager instanceManager = wsSession.getInstanceManager();
 try {
-instance = encoderClazz.getConstructor().newInstance();
+if (instanceManager == null) {
+instance = encoderClazz.getConstructor().newInstance();
+} else {
+instance = (Encoder) 
instanceManager.newInstance(encoderClazz);
+}
 instance.init(endpointConfig);
-} catch (ReflectiveOperationException e) {
+} catch (ReflectiveOperationException | NamingException e) {
 throw new DeploymentException(
 sm.getString("wsRemoteEndpoint.invalidEncoder",
 encoderClazz.getName()), e);
@@ -730,8 +738,16 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 
 
 public final void close() {
+InstanceManager instanceManager = wsSession.getInstanceManager();
 for (EncoderEntry entry : encoderEntries) {
 entry.getEncoder().destroy();
+if (instanceManager != null) {
+try {
+instanceManager.destroyInstance(entry);
+} catch (IllegalAccessException | InvocationTargetException e) 
{
+
log.warn(sm.getString("wsRemoteEndpoint.encoderDestoryFailed", 
encoder.getClass()), e);
+}
+}
 }
 // The transformation handles both input and output. It only needs to 
be
 // closed once so it is closed here on the output side.
diff --git a/java/org/apache/tomcat/websocket/server/WsServerC

[Bug 65262] Enable websocket endpoints to be IoC friendly (javaee integration at least)

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65262

Mark Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Mark Thomas  ---
Fixed in:
- 10.0.x for 10.0.6 onwards
- 9.0.x for 9.0.46 onwards
- 8.5.x for 8.5.66 onwards

-- 
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/04: Refactor InstanceManager lookup

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

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

commit d3b3552b5627c4434899e21255c06b932ae7df2c
Author: Mark Thomas 
AuthorDate: Wed May 5 12:08:50 2021 +0100

Refactor InstanceManager lookup
---
 java/org/apache/tomcat/websocket/WsSession.java| 29 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  8 --
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index cbd599e..39a2684 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -53,7 +53,6 @@ import 
javax.websocket.server.ServerEndpointConfig.Configurator;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
-import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoEndpointServer;
@@ -172,12 +171,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
-this.localEndpoint = clientEndpointHolder.getInstance(instanceManager);
+this.localEndpoint = 
clientEndpointHolder.getInstance(getInstanceManager());
 
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("wsSession.created", id));
@@ -260,11 +254,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
+InstanceManager instanceManager = getInstanceManager();
 Configurator configurator = serverEndpointConfig.getConfigurator();
 Class clazz = serverEndpointConfig.getEndpointClass();
 
@@ -389,10 +379,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = getInstanceManager();
 if (instanceManager != null) {
 try {
 instanceManager.newInstance(localEndpoint);
@@ -407,6 +394,11 @@ public class WsSession implements Session {
 }
 
 
+public InstanceManager getInstanceManager() {
+return webSocketContainer.getInstanceManager(applicationClassLoader);
+}
+
+
 @Override
 public WebSocketContainer getContainer() {
 checkState();
@@ -757,10 +749,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index a6a677b..890 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -68,6 +68,7 @@ import javax.websocket.WebSocketContainer;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
@@ -104,8 +105,11 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
 
 private InstanceManager instanceManager;
 
-InstanceManager getInstanceManager() {
-return instanceManager;
+protected InstanceManager ge

[tomcat] 03/04: Create/destroy Decoders via the InstanceManager (BZ 65262)

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

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

commit 5675ae968efb2497126185f15e5c5e6a434ea125
Author: Mark Thomas 
AuthorDate: Wed Apr 28 12:47:31 2021 +0100

Create/destroy Decoders via the InstanceManager (BZ 65262)
---
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 79 --
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 28 
 .../pojo/PojoMessageHandlerWholeBinary.java| 11 ++-
 .../pojo/PojoMessageHandlerWholeText.java  | 11 ++-
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java |  2 +-
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 11 files changed, 144 insertions(+), 41 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/PojoClassHolder.java 
b/java/org/apache/tomcat/websocket/PojoClassHolder.java
index ef11fce..dcfa7d4 100644
--- a/java/org/apache/tomcat/websocket/PojoClassHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoClassHolder.java
@@ -53,7 +53,7 @@ public class PojoClassHolder implements ClientEndpointHolder {
 } else {
 pojo = instanceManager.newInstance(pojoClazz);
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 } catch (ReflectiveOperationException | SecurityException | 
NamingException e) {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceCreationFailed"),
 e);
 }
diff --git a/java/org/apache/tomcat/websocket/PojoHolder.java 
b/java/org/apache/tomcat/websocket/PojoHolder.java
index 166a934..d1604d1 100644
--- a/java/org/apache/tomcat/websocket/PojoHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoHolder.java
@@ -54,6 +54,6 @@ public class PojoHolder implements ClientEndpointHolder {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceRegistrationFailed"),
 e);
 }
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 }
 }
diff --git a/java/org/apache/tomcat/websocket/Util.java 
b/java/org/apache/tomcat/websocket/Util.java
index 63009a6..fe311b6 100644
--- a/java/org/apache/tomcat/websocket/Util.java
+++ b/java/org/apache/tomcat/websocket/Util.java
@@ -33,6 +33,7 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+import javax.naming.NamingException;
 import javax.websocket.CloseReason.CloseCode;
 import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.Decoder;
@@ -48,6 +49,7 @@ import javax.websocket.MessageHandler;
 import javax.websocket.PongMessage;
 import javax.websocket.Session;
 
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerPartialBinary;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBinary;
@@ -330,26 +332,59 @@ public class Util {
 }
 
 
-public static List getDecoders(
-List> decoderClazzes)
-throws DeploymentException{
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzes Decoder implementation classes
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ *
+ * @deprecated Will be removed in Tomcat 10.1.x.
+ * Use {@link Util#getDecoders(List, InstanceManager)}
+ */
+@Deprecated
+public static List getDecoders(List> decoderClazzes)
+throws DeploymentException {
+return getDecoders(decoderClazzes, null);
+}
+
+
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzesDecoder implementation classes
+ * @param instanceManager   Instance manager to use to create Decoder
+ *  instances
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ */
+public static List getDecoders(List> decoderClazzes,
+InstanceManager instanceManager) throws DeploymentException{
 
 List result = new ArrayList<>();
 if (decoderClazzes != null)

[tomcat] 04/04: Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

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

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

commit ea99dd0edb07973ae677dd9ff90e2057aaa696e5
Author: Mark Thomas 
AuthorDate: Wed May 5 15:14:30 2021 +0100

Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

https://bz.apache.org/bugzilla/show_bug.cgi?id=65262
---
 .../apache/tomcat/websocket/LocalStrings.properties  |  1 +
 .../tomcat/websocket/WsRemoteEndpointImplBase.java   | 20 ++--
 .../tomcat/websocket/server/WsServerContainer.java   | 20 +---
 webapps/docs/changelog.xml   |  6 +++---
 4 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties 
b/java/org/apache/tomcat/websocket/LocalStrings.properties
index ae54da0..fbd7bfd 100644
--- a/java/org/apache/tomcat/websocket/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/LocalStrings.properties
@@ -92,6 +92,7 @@ wsRemoteEndpoint.closed=Message will not be sent because the 
WebSocket session h
 wsRemoteEndpoint.closedDuringMessage=The remainder of the message will not be 
sent because the WebSocket session has been closed
 wsRemoteEndpoint.closedOutputStream=This method may not be called as the 
OutputStream has been closed
 wsRemoteEndpoint.closedWriter=This method may not be called as the Writer has 
been closed
+wsRemoteEndpoint.encoderDestoryFailed=Failed to destroy the encoder of type 
[{0}]
 wsRemoteEndpoint.flushOnCloseFailed=Batched messages still enabled after 
session has been closed. Unable to flush remaining batched message.
 wsRemoteEndpoint.invalidEncoder=The specified encoder of type [{0}] could not 
be instantiated
 wsRemoteEndpoint.noEncoder=No encoder specified for object of class [{0}]
diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
index 18c723a..11f6fd4 100644
--- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
+++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
@@ -19,6 +19,7 @@ package org.apache.tomcat.websocket;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -33,6 +34,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.naming.NamingException;
 import javax.websocket.CloseReason;
 import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.DeploymentException;
@@ -45,6 +47,7 @@ import javax.websocket.SendResult;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.Utf8Encoder;
 import org.apache.tomcat.util.res.StringManager;
@@ -704,10 +707,15 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 for (Class encoderClazz :
 endpointConfig.getEncoders()) {
 Encoder instance;
+InstanceManager instanceManager = wsSession.getInstanceManager();
 try {
-instance = encoderClazz.getConstructor().newInstance();
+if (instanceManager == null) {
+instance = encoderClazz.getConstructor().newInstance();
+} else {
+instance = (Encoder) 
instanceManager.newInstance(encoderClazz);
+}
 instance.init(endpointConfig);
-} catch (ReflectiveOperationException e) {
+} catch (ReflectiveOperationException | NamingException e) {
 throw new DeploymentException(
 sm.getString("wsRemoteEndpoint.invalidEncoder",
 encoderClazz.getName()), e);
@@ -730,8 +738,16 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 
 
 public final void close() {
+InstanceManager instanceManager = wsSession.getInstanceManager();
 for (EncoderEntry entry : encoderEntries) {
 entry.getEncoder().destroy();
+if (instanceManager != null) {
+try {
+instanceManager.destroyInstance(entry);
+} catch (IllegalAccessException | InvocationTargetException e) 
{
+
log.warn(sm.getString("wsRemoteEndpoint.encoderDestoryFailed", 
encoder.getClass()), e);
+}
+}
 }
 // The transformation handles both input and output. It only needs to 
be
 // closed once so it is closed here on the output side.
diff --git a/java/org/apache/tomcat/websocket/server/WsServerC

[tomcat] 01/04: Refactor InstanceManager lookup

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

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

commit 59ef18f34d1bba2d3023d72313f3c2e02f86bd4f
Author: Mark Thomas 
AuthorDate: Wed May 5 12:08:50 2021 +0100

Refactor InstanceManager lookup
---
 java/org/apache/tomcat/websocket/WsSession.java| 29 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  8 --
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index cbd599e..39a2684 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -53,7 +53,6 @@ import 
javax.websocket.server.ServerEndpointConfig.Configurator;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
-import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoEndpointServer;
@@ -172,12 +171,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
-this.localEndpoint = clientEndpointHolder.getInstance(instanceManager);
+this.localEndpoint = 
clientEndpointHolder.getInstance(getInstanceManager());
 
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("wsSession.created", id));
@@ -260,11 +254,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
+InstanceManager instanceManager = getInstanceManager();
 Configurator configurator = serverEndpointConfig.getConfigurator();
 Class clazz = serverEndpointConfig.getEndpointClass();
 
@@ -389,10 +379,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = getInstanceManager();
 if (instanceManager != null) {
 try {
 instanceManager.newInstance(localEndpoint);
@@ -407,6 +394,11 @@ public class WsSession implements Session {
 }
 
 
+public InstanceManager getInstanceManager() {
+return webSocketContainer.getInstanceManager(applicationClassLoader);
+}
+
+
 @Override
 public WebSocketContainer getContainer() {
 checkState();
@@ -757,10 +749,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 13c16a2..a463cef 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -68,6 +68,7 @@ import javax.websocket.WebSocketContainer;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
@@ -104,8 +105,11 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
 
 private InstanceManager instanceManager;
 
-InstanceManager getInstanceManager() {
-return instanceManager;
+protected InstanceManager ge

[tomcat] branch 9.0.x updated (e092977 -> ea99dd0)

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

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


from e092977  Move to javax
 new 59ef18f  Refactor InstanceManager lookup
 new ff45d67  Refactor with a view towards using the InstanceManager with 
decoders
 new 5675ae9  Create/destroy Decoders via the InstanceManager (BZ 65262)
 new ea99dd0  Complete fix for BZ 65262. Encoders and decoders now use 
InstanceManager

The 4 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:
 .../tomcat/websocket/LocalStrings.properties   |  1 +
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 79 --
 .../tomcat/websocket/WsRemoteEndpointImplBase.java | 20 +-
 java/org/apache/tomcat/websocket/WsSession.java| 29 +++-
 .../tomcat/websocket/WsWebSocketContainer.java |  8 ++-
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 42 +++-
 .../pojo/PojoMessageHandlerWholeBinary.java| 22 ++
 .../pojo/PojoMessageHandlerWholeText.java  | 21 ++
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java | 22 +++---
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 webapps/docs/changelog.xml |  6 +-
 16 files changed, 207 insertions(+), 97 deletions(-)

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



[tomcat] 02/04: Refactor with a view towards using the InstanceManager with decoders

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

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

commit ff45d67bec25d3a360837e37984e9e18d81502eb
Author: Mark Thomas 
AuthorDate: Wed May 5 12:57:56 2021 +0100

Refactor with a view towards using the InstanceManager with decoders
---
 java/org/apache/tomcat/websocket/WsSession.java|  2 +-
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java | 14 +-
 .../websocket/pojo/PojoMessageHandlerWholeBinary.java  | 11 ---
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeText.java | 10 --
 4 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index 39a2684..c090c20 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -749,7 +749,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
+InstanceManager instanceManager = getInstanceManager();
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
index aa4abbe..d2b0f12 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
@@ -18,8 +18,11 @@ package org.apache.tomcat.websocket.pojo;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.websocket.DecodeException;
+import javax.websocket.Decoder;
 import javax.websocket.MessageHandler;
 import javax.websocket.Session;
 
@@ -34,6 +37,8 @@ import org.apache.tomcat.websocket.WsSession;
 public abstract class PojoMessageHandlerWholeBase
 extends PojoMessageHandlerBase implements MessageHandler.Whole {
 
+protected final List decoders = new ArrayList<>();
+
 public PojoMessageHandlerWholeBase(Object pojo, Method method,
 Session session, Object[] params, int indexPayload,
 boolean convert, int indexSession, long maxMessageSize) {
@@ -84,11 +89,18 @@ public abstract class PojoMessageHandlerWholeBase
 processResult(result);
 }
 
+
+protected void onClose() {
+for (Decoder decoder : decoders) {
+decoder.destroy();
+}
+}
+
+
 protected Object convert(T message) {
 return message;
 }
 
 
 protected abstract Object decode(T message) throws DecodeException;
-protected abstract void onClose();
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
index e4756f6..0444d3d 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.websocket.DecodeException;
@@ -41,8 +40,6 @@ public class PojoMessageHandlerWholeBinary
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeBinary.class);
 
-private final List decoders = new ArrayList<>();
-
 private final boolean isForInputStream;
 
 public PojoMessageHandlerWholeBinary(Object pojo, Method method,
@@ -120,12 +117,4 @@ public class PojoMessageHandlerWholeBinary
 return array;
 }
 }
-
-
-@Override
-protected void onClose() {
-for (Decoder decoder : decoders) {
-decoder.destroy();
-}
-}
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
index 3ec4bd7..fd16273 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
@@ -19,7 +19,6 @@ package org.apache.tomcat.websocket.pojo;
 import java.io.IOException;
 import java.io.StringReader;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.websocket.DecodeException;
@@ -42,7 +41,6 @@ public class PojoMessageHandlerWholeText
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeText.class);
 
-   

[tomcat] 01/03: Refactor with a view towards using the InstanceManager with decoders

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

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

commit 56ce1d9a83c55cf37bbb4ebff7cbd404a54cb00f
Author: Mark Thomas 
AuthorDate: Wed May 5 12:57:56 2021 +0100

Refactor with a view towards using the InstanceManager with decoders
---
 java/org/apache/tomcat/websocket/WsSession.java|  2 +-
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java | 14 +-
 .../websocket/pojo/PojoMessageHandlerWholeBinary.java  | 11 ---
 .../tomcat/websocket/pojo/PojoMessageHandlerWholeText.java | 10 --
 4 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index c91a0f2..0120845 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -750,7 +750,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
+InstanceManager instanceManager = getInstanceManager();
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
index e973552..90d7398 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java
@@ -18,8 +18,11 @@ package org.apache.tomcat.websocket.pojo;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 import jakarta.websocket.DecodeException;
+import jakarta.websocket.Decoder;
 import jakarta.websocket.MessageHandler;
 import jakarta.websocket.Session;
 
@@ -34,6 +37,8 @@ import org.apache.tomcat.websocket.WsSession;
 public abstract class PojoMessageHandlerWholeBase
 extends PojoMessageHandlerBase implements MessageHandler.Whole {
 
+protected final List decoders = new ArrayList<>();
+
 public PojoMessageHandlerWholeBase(Object pojo, Method method,
 Session session, Object[] params, int indexPayload,
 boolean convert, int indexSession, long maxMessageSize) {
@@ -84,11 +89,18 @@ public abstract class PojoMessageHandlerWholeBase
 processResult(result);
 }
 
+
+protected void onClose() {
+for (Decoder decoder : decoders) {
+decoder.destroy();
+}
+}
+
+
 protected Object convert(T message) {
 return message;
 }
 
 
 protected abstract Object decode(T message) throws DecodeException;
-protected abstract void onClose();
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
index 07b49ce..93feeeb 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.List;
 
 import jakarta.websocket.DecodeException;
@@ -41,8 +40,6 @@ public class PojoMessageHandlerWholeBinary
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeBinary.class);
 
-private final List decoders = new ArrayList<>();
-
 private final boolean isForInputStream;
 
 public PojoMessageHandlerWholeBinary(Object pojo, Method method,
@@ -120,12 +117,4 @@ public class PojoMessageHandlerWholeBinary
 return array;
 }
 }
-
-
-@Override
-protected void onClose() {
-for (Decoder decoder : decoders) {
-decoder.destroy();
-}
-}
 }
diff --git 
a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java 
b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
index 0cb5fec..ce12f16 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
@@ -19,7 +19,6 @@ package org.apache.tomcat.websocket.pojo;
 import java.io.IOException;
 import java.io.StringReader;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.List;
 
 import jakarta.websocket.DecodeException;
@@ -42,7 +41,6 @@ public class PojoMessageHandlerWholeText
 private static final StringManager sm =
 StringManager.getManager(PojoMessageHandlerWholeText.c

[tomcat] 03/03: Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

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

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

commit a23c5788012712609c760a77f9cebfc45aaa29d9
Author: Mark Thomas 
AuthorDate: Wed May 5 15:14:30 2021 +0100

Complete fix for BZ 65262. Encoders and decoders now use InstanceManager

https://bz.apache.org/bugzilla/show_bug.cgi?id=65262
---
 .../apache/tomcat/websocket/LocalStrings.properties |  1 +
 .../tomcat/websocket/WsRemoteEndpointImplBase.java  | 21 +++--
 .../tomcat/websocket/server/WsServerContainer.java  | 21 ++---
 webapps/docs/changelog.xml  |  6 +++---
 4 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties 
b/java/org/apache/tomcat/websocket/LocalStrings.properties
index 3ee86ae..382cc04 100644
--- a/java/org/apache/tomcat/websocket/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/LocalStrings.properties
@@ -92,6 +92,7 @@ wsRemoteEndpoint.closed=Message will not be sent because the 
WebSocket session h
 wsRemoteEndpoint.closedDuringMessage=The remainder of the message will not be 
sent because the WebSocket session has been closed
 wsRemoteEndpoint.closedOutputStream=This method may not be called as the 
OutputStream has been closed
 wsRemoteEndpoint.closedWriter=This method may not be called as the Writer has 
been closed
+wsRemoteEndpoint.encoderDestoryFailed=Failed to destroy the encoder of type 
[{0}]
 wsRemoteEndpoint.flushOnCloseFailed=Batched messages still enabled after 
session has been closed. Unable to flush remaining batched message.
 wsRemoteEndpoint.invalidEncoder=The specified encoder of type [{0}] could not 
be instantiated
 wsRemoteEndpoint.noEncoder=No encoder specified for object of class [{0}]
diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
index aaeebd8..cbc1a72 100644
--- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
+++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
@@ -19,6 +19,7 @@ package org.apache.tomcat.websocket;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -33,6 +34,8 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.naming.NamingException;
+
 import jakarta.websocket.CloseReason;
 import jakarta.websocket.CloseReason.CloseCodes;
 import jakarta.websocket.DeploymentException;
@@ -45,6 +48,7 @@ import jakarta.websocket.SendResult;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.Utf8Encoder;
 import org.apache.tomcat.util.res.StringManager;
@@ -704,10 +708,15 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 for (Class encoderClazz :
 endpointConfig.getEncoders()) {
 Encoder instance;
+InstanceManager instanceManager = wsSession.getInstanceManager();
 try {
-instance = encoderClazz.getConstructor().newInstance();
+if (instanceManager == null) {
+instance = encoderClazz.getConstructor().newInstance();
+} else {
+instance = (Encoder) 
instanceManager.newInstance(encoderClazz);
+}
 instance.init(endpointConfig);
-} catch (ReflectiveOperationException e) {
+} catch (ReflectiveOperationException | NamingException e) {
 throw new DeploymentException(
 sm.getString("wsRemoteEndpoint.invalidEncoder",
 encoderClazz.getName()), e);
@@ -730,8 +739,16 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
 
 
 public final void close() {
+InstanceManager instanceManager = wsSession.getInstanceManager();
 for (EncoderEntry entry : encoderEntries) {
 entry.getEncoder().destroy();
+if (instanceManager != null) {
+try {
+instanceManager.destroyInstance(entry);
+} catch (IllegalAccessException | InvocationTargetException e) 
{
+
log.warn(sm.getString("wsRemoteEndpoint.encoderDestoryFailed", 
encoder.getClass()), e);
+}
+}
 }
 // The transformation handles both input and output. It only needs to 
be
 // closed once so it is closed here on the output side.
diff --git a/java/org/apache/tomcat/websocket/server/

[tomcat] 02/03: Create/destroy Decoders via the InstanceManager (BZ 65262)

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

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

commit c48f647d951f20d5b51a5ad3f3dbd07be05c3e3e
Author: Mark Thomas 
AuthorDate: Wed Apr 28 12:47:31 2021 +0100

Create/destroy Decoders via the InstanceManager (BZ 65262)
---
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 80 --
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 29 
 .../pojo/PojoMessageHandlerWholeBinary.java| 12 ++--
 .../pojo/PojoMessageHandlerWholeText.java  | 12 ++--
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java |  2 +-
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 11 files changed, 148 insertions(+), 41 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/PojoClassHolder.java 
b/java/org/apache/tomcat/websocket/PojoClassHolder.java
index e2c1da8..61e338b 100644
--- a/java/org/apache/tomcat/websocket/PojoClassHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoClassHolder.java
@@ -54,7 +54,7 @@ public class PojoClassHolder implements ClientEndpointHolder {
 } else {
 pojo = instanceManager.newInstance(pojoClazz);
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 } catch (ReflectiveOperationException | SecurityException | 
NamingException e) {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceCreationFailed"),
 e);
 }
diff --git a/java/org/apache/tomcat/websocket/PojoHolder.java 
b/java/org/apache/tomcat/websocket/PojoHolder.java
index 7195944..8ff3f42 100644
--- a/java/org/apache/tomcat/websocket/PojoHolder.java
+++ b/java/org/apache/tomcat/websocket/PojoHolder.java
@@ -55,6 +55,6 @@ public class PojoHolder implements ClientEndpointHolder {
 throw new 
DeploymentException(sm.getString("clientEndpointHolder.instanceRegistrationFailed"),
 e);
 }
 }
-return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders());
+return new PojoEndpointClient(pojo, 
clientEndpointConfig.getDecoders(), instanceManager);
 }
 }
diff --git a/java/org/apache/tomcat/websocket/Util.java 
b/java/org/apache/tomcat/websocket/Util.java
index ac8ea2d..6095f54 100644
--- a/java/org/apache/tomcat/websocket/Util.java
+++ b/java/org/apache/tomcat/websocket/Util.java
@@ -33,6 +33,8 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+import javax.naming.NamingException;
+
 import jakarta.websocket.CloseReason.CloseCode;
 import jakarta.websocket.CloseReason.CloseCodes;
 import jakarta.websocket.Decoder;
@@ -48,6 +50,7 @@ import jakarta.websocket.MessageHandler;
 import jakarta.websocket.PongMessage;
 import jakarta.websocket.Session;
 
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerPartialBinary;
 import org.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBinary;
@@ -330,26 +333,59 @@ public class Util {
 }
 
 
-public static List getDecoders(
-List> decoderClazzes)
-throws DeploymentException{
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzes Decoder implementation classes
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ *
+ * @deprecated Will be removed in Tomcat 10.1.x.
+ * Use {@link Util#getDecoders(List, InstanceManager)}
+ */
+@Deprecated
+public static List getDecoders(List> decoderClazzes)
+throws DeploymentException {
+return getDecoders(decoderClazzes, null);
+}
+
+
+/**
+ * Build the list of decoder entries from a set of decoder implementations.
+ *
+ * @param decoderClazzesDecoder implementation classes
+ * @param instanceManager   Instance manager to use to create Decoder
+ *  instances
+ *
+ * @return List of mappings from target type to associated decoder
+ *
+ * @throws DeploymentException If a provided decoder class is not valid
+ */
+public static List getDecoders(List> decoderClazzes,
+InstanceManager instanceManager) throws DeploymentException{
 
 List result = new ArrayList<>();
 if (decode

[tomcat] branch master updated (0235fd7 -> a23c578)

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

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


from 0235fd7  Remove trailing space
 new 56ce1d9  Refactor with a view towards using the InstanceManager with 
decoders
 new c48f647  Create/destroy Decoders via the InstanceManager (BZ 65262)
 new a23c578  Complete fix for BZ 65262. Encoders and decoders now use 
InstanceManager

The 3 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:
 .../tomcat/websocket/LocalStrings.properties   |  1 +
 .../apache/tomcat/websocket/PojoClassHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/PojoHolder.java   |  2 +-
 java/org/apache/tomcat/websocket/Util.java | 80 --
 .../tomcat/websocket/WsRemoteEndpointImplBase.java | 21 +-
 java/org/apache/tomcat/websocket/WsSession.java|  2 +-
 .../tomcat/websocket/pojo/LocalStrings.properties  |  2 +
 .../tomcat/websocket/pojo/PojoEndpointClient.java  |  9 +++
 .../pojo/PojoMessageHandlerWholeBase.java  | 43 +++-
 .../pojo/PojoMessageHandlerWholeBinary.java| 23 ++-
 .../pojo/PojoMessageHandlerWholeText.java  | 22 ++
 .../tomcat/websocket/pojo/PojoMethodMapping.java   | 37 --
 .../tomcat/websocket/server/WsServerContainer.java | 23 ---
 .../tomcat/websocket/TesterWsClientAutobahn.java   |  2 +-
 webapps/docs/changelog.xml |  6 +-
 15 files changed, 199 insertions(+), 76 deletions(-)

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



[tomcat] branch 8.5.x updated: Java 7 compatibility

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 4eff5e0  Java 7 compatibility
4eff5e0 is described below

commit 4eff5e04156a7f4f25c6615835689d616df9cda3
Author: remm 
AuthorDate: Wed May 5 16:45:34 2021 +0200

Java 7 compatibility
---
 java/org/apache/tomcat/util/bcel/classfile/JavaClass.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java 
b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
index 819175a..431df3a 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
@@ -95,7 +95,9 @@ public class JavaClass {
 if (runtimeVisibleFieldOrMethodAnnotations != null) {
 for (Annotations annotations : 
runtimeVisibleFieldOrMethodAnnotations.toArray(new Annotations[0])) {
 for (AnnotationEntry annotationEntry : 
annotations.getAnnotationEntries()) {
-
annotationEntries.putIfAbsent(annotationEntry.getAnnotationType(), 
annotationEntry);
+if 
(!annotationEntries.containsKey(annotationEntry.getAnnotationType())) {
+
annotationEntries.put(annotationEntry.getAnnotationType(), annotationEntry);
+}
 }
 }
 }

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



Re: JSTL issue

2021-05-05 Thread Christopher Schultz

Jean-Louis,

On 5/5/21 09:49, Jean-Louis MONTEIRO wrote:
Now that we crossed the finish line with TomEE compatibility, I'd like 
to give back the BOM changes according to this discussion.


I did the updated and created another subclass for 
DefaultServletEncodingBaseTest

image.png
Did some fixes around that test to take the changes into account.
I'll see if I can get this to fully pass

image.png

Good news, it's backward compatible as we wanted.
I may post if I need some help or guidance.

As soon as it's done, I believe we want a bugzilla ticket so I can link 
it to a PR?


All the images were stripped from the list-posting.

Either Bugzilla or GitHub PR is fine.

-chris

Le jeu. 15 avr. 2021 à 19:19, Christopher Schultz 
mailto:ch...@christopherschultz.net>> a 
écrit :


Mark,

On 4/15/21 04:57, Mark Thomas wrote:
 > If we wanted to address this and provide a way to allow JSTL to
have the
 > control over the included content required to pass this TCK test
then we
 > could modify 'useBomIfPresent' as follows:
 >
 > - true   - no change - remains the default
 >
 > - false  - no change
 >
 > - ignore - as current false but does not strip the BoM from the
output

I might re-name the "ignore" case to "pass-through" to be perfectly
clear about what's happening. "Ignore" might be mis-interpreted to mean
that the BOM would be removed. "Pass-through" makes it clear that the
BOM will still be sent IMHO.

-chris

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org

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




--
Jean-Louis


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



buildbot failure in on tomcat-85-trunk

2021-05-05 Thread buildbot
The Buildbot has detected a new failure on builder tomcat-85-trunk while 
building tomcat. Full details are available at:
https://ci.apache.org/builders/tomcat-85-trunk/builds/2709

Buildbot URL: https://ci.apache.org/

Buildslave for this Build: asf946_ubuntu

Build Reason: The AnyBranchScheduler scheduler named 'on-tomcat-85-commit' 
triggered this build
Build Source Stamp: [branch 8.5.x] eb974b44ff17f4d8b612ec8a3e12a4b318d1d530
Blamelist: remm 

BUILD FAILED: failed compile

Sincerely,
 -The Buildbot




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



Re: JSTL issue

2021-05-05 Thread Jean-Louis MONTEIRO
Hi,

Now that we crossed the finish line with TomEE compatibility, I'd like to
give back the BOM changes according to this discussion.

I did the updated and created another subclass for
DefaultServletEncodingBaseTest
[image: image.png]
Did some fixes around that test to take the changes into account.
I'll see if I can get this to fully pass

[image: image.png]

Good news, it's backward compatible as we wanted.
I may post if I need some help or guidance.

As soon as it's done, I believe we want a bugzilla ticket so I can link it
to a PR?


Le jeu. 15 avr. 2021 à 19:19, Christopher Schultz <
ch...@christopherschultz.net> a écrit :

> Mark,
>
> On 4/15/21 04:57, Mark Thomas wrote:
> > If we wanted to address this and provide a way to allow JSTL to have the
> > control over the included content required to pass this TCK test then we
> > could modify 'useBomIfPresent' as follows:
> >
> > - true   - no change - remains the default
> >
> > - false  - no change
> >
> > - ignore - as current false but does not strip the BoM from the output
>
> I might re-name the "ignore" case to "pass-through" to be perfectly
> clear about what's happening. "Ignore" might be mis-interpreted to mean
> that the BOM would be removed. "Pass-through" makes it clear that the
> BOM will still be sent IMHO.
>
> -chris
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

-- 
Jean-Louis


[Bug 65244] annotations from @HandlesTypes are checked only at class level when scanning

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65244

Remy Maucherat  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #25 from Remy Maucherat  ---
The fix will be in 9.0.46 and 8.5.66.

-- 
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] 02/04: Fix typos and consistent naming

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

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

commit a15c8dab7b888c06a1996bc4c754ab8e520b7e41
Author: remm 
AuthorDate: Mon Apr 19 16:49:14 2021 +0200

Fix typos and consistent naming
---
 java/org/apache/tomcat/util/bcel/classfile/ClassParser.java | 10 +-
 java/org/apache/tomcat/util/bcel/classfile/JavaClass.java   | 12 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
index 89dab31..af24856 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
@@ -49,7 +49,7 @@ public final class ClassParser {
 private String[] interfaceNames; // Names of implemented interfaces
 private ConstantPool constantPool; // collection of constants
 private Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
-private List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
+private List runtimeVisibleFieldOrMethodAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 private static final int BUFSIZE = 8192;
 
 private static final String[] INTERFACES_EMPTY_ARRAY = new String[0];
@@ -99,7 +99,7 @@ public final class ClassParser {
 // Return the information we have gathered in a new object
 return new JavaClass(class_name, superclassName,
 accessFlags, constantPool, interfaceNames,
-runtimeVisibleAnnotations, 
runtimeVisibleMethodOfFieldAnnotations);
+runtimeVisibleAnnotations, 
runtimeVisibleFieldOrMethodAnnotations);
 }
 
 
@@ -126,10 +126,10 @@ public final class ClassParser {
 if (name.equals("RuntimeVisibleAnnotations")) {
 if (fieldOrMethod) {
 Annotations fieldOrMethodAnnotations = new 
Annotations(dataInputStream, constantPool);
-if (runtimeVisibleMethodOfFieldAnnotations == null) {
-runtimeVisibleMethodOfFieldAnnotations = new 
ArrayList<>();
+if (runtimeVisibleFieldOrMethodAnnotations == null) {
+runtimeVisibleFieldOrMethodAnnotations = new 
ArrayList<>();
 }
-
runtimeVisibleMethodOfFieldAnnotations.add(fieldOrMethodAnnotations);
+
runtimeVisibleFieldOrMethodAnnotations.add(fieldOrMethodAnnotations);
 } else {
 if (runtimeVisibleAnnotations != null) {
 throw new ClassFormatException(
diff --git a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java 
b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
index 14ef3a1..819175a 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
@@ -35,7 +35,7 @@ public class JavaClass {
 private final String superclassName;
 private final String[] interfaceNames;
 private final Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
-private final List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
+private final List runtimeVisibleFieldOrMethodAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 
 /**
  * Constructor gets all contents as arguments.
@@ -46,14 +46,14 @@ public class JavaClass {
  * @param constant_pool Array of constants
  * @param interfaceNames Implemented interfaces
  * @param runtimeVisibleAnnotations "RuntimeVisibleAnnotations" attribute 
defined on the Class, or null
- * @param runtimeVisibleMethodOfFieldAnnotations 
"RuntimeVisibleAnnotations" attribute defined on the fields or methids, or null
+ * @param runtimeVisibleFieldOrMethodAnnotations 
"RuntimeVisibleAnnotations" attribute defined on the fields or methods, or null
  */
 JavaClass(final String className, final String superclassName,
 final int accessFlags, final ConstantPool constant_pool, final 
String[] interfaceNames,
-final Annotations runtimeVisibleAnnotations, final 
List runtimeVisibleMethodOfFieldAnnotations) {
+final Annotations runtimeVisibleAnnotations, final 
List runtimeVisibleFieldOrMethodAnnotations) {
 this.accessFlags = accessFlags;
 this.runtimeVisibleAnnotations = runtimeVisibleAnnotations;
-this.runtimeVisibleMethodOfFieldAnnotations = 
runtimeVisibleMethodOfFieldAnnotations;
+this.runtimeVisibleFieldOrMethodAnnotations = 
runtimeVisibleFieldOrMethodAnnotations;
 this.className = className;
 this.superclassName = superc

[tomcat] 03/04: Add HandlesTypes test

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

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

commit 2b4fd1b13838814ba77afb0bf3a8060c56d6f503
Author: remm 
AuthorDate: Tue Apr 20 14:34:04 2021 +0200

Add HandlesTypes test

Based on the way to validate from the BZ 65244 example.
---
 test/org/apache/tomcat/util/scan/FooSCI.java   | 37 ++
 .../apache/tomcat/util/scan/TestClassParser.java   | 58 ++
 .../jakarta.servlet.ServletContainerInitializer| 16 ++
 3 files changed, 111 insertions(+)

diff --git a/test/org/apache/tomcat/util/scan/FooSCI.java 
b/test/org/apache/tomcat/util/scan/FooSCI.java
new file mode 100644
index 000..be45d4f
--- /dev/null
+++ b/test/org/apache/tomcat/util/scan/FooSCI.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomcat.util.scan;
+
+import java.util.Set;
+
+import jakarta.servlet.ServletContainerInitializer;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.annotation.HandlesTypes;
+
+import org.apache.tomcat.util.scan.TestClassParser.Foo;
+
+@HandlesTypes(Foo.class)
+public class FooSCI implements ServletContainerInitializer {
+
+static Set> classSet;
+
+@Override
+public void onStartup(final Set> set, final ServletContext 
servletContext) {
+classSet = set;
+}
+
+}
diff --git a/test/org/apache/tomcat/util/scan/TestClassParser.java 
b/test/org/apache/tomcat/util/scan/TestClassParser.java
new file mode 100644
index 000..3756535
--- /dev/null
+++ b/test/org/apache/tomcat/util/scan/TestClassParser.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomcat.util.scan;
+
+import java.io.File;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+
+public class TestClassParser extends TomcatBaseTest {
+
+@Target({ElementType.TYPE, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Foo {
+}
+
+/** and beans */
+@Foo
+public class OnClass {
+}
+
+public class OnField {
+@Foo
+private String name;
+}
+
+@Test
+public void testAnnotations() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+File appDir = new File("test/webapp-sci");
+tomcat.addWebapp("", appDir.getAbsolutePath());
+tomcat.start();
+Assert.assertTrue(FooSCI.classSet.size() == 2);
+Assert.assertTrue(FooSCI.classSet.contains(OnClass.class));
+Assert.assertTrue(FooSCI.classSet.contains(OnField.class));
+}
+}
diff --git 
a/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
new file mode 100644
index 000..19b37e3
--- /dev/null
+++ 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional inform

[tomcat] 01/04: Parse annotations on fields or methods

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

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

commit 5d85f9440e2b3c2d547f45fd6b2c07c0527254e6
Author: remm 
AuthorDate: Mon Apr 19 10:49:04 2021 +0200

Parse annotations on fields or methods

BZ 65244: Use that info for HandlesTypes since it is supposed to also
include annotations used on fields and methods.
---
 .../org/apache/catalina/startup/ContextConfig.java |  2 +-
 .../tomcat/util/bcel/classfile/ClassParser.java| 43 --
 .../tomcat/util/bcel/classfile/JavaClass.java  | 35 +-
 .../apache/tomcat/util/bcel/classfile/Utility.java | 13 ---
 webapps/docs/changelog.xml |  4 ++
 5 files changed, 71 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/catalina/startup/ContextConfig.java 
b/java/org/apache/catalina/startup/ContextConfig.java
index dd980a6..6bbe9e3 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -2094,7 +2094,7 @@ public class ContextConfig implements LifecycleListener {
 }
 
 if (handlesTypesAnnotations) {
-AnnotationEntry[] annotationEntries = 
javaClass.getAnnotationEntries();
+AnnotationEntry[] annotationEntries = 
javaClass.getAllAnnotationEntries();
 if (annotationEntries != null) {
 for (Map.Entry, Set> 
entry :
 typeInitializerMap.entrySet()) {
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
index 303be90..89dab31 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
@@ -22,6 +22,8 @@ import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tomcat.util.bcel.Const;
 
@@ -47,6 +49,7 @@ public final class ClassParser {
 private String[] interfaceNames; // Names of implemented interfaces
 private ConstantPool constantPool; // collection of constants
 private Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
+private List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 private static final int BUFSIZE = 8192;
 
 private static final String[] INTERFACES_EMPTY_ARRAY = new String[0];
@@ -91,41 +94,49 @@ public final class ClassParser {
 // Read class methods, i.e., the functions in the class
 readMethods();
 // Read class attributes
-readAttributes();
+readAttributes(false);
 
 // Return the information we have gathered in a new object
 return new JavaClass(class_name, superclassName,
 accessFlags, constantPool, interfaceNames,
-runtimeVisibleAnnotations);
+runtimeVisibleAnnotations, 
runtimeVisibleMethodOfFieldAnnotations);
 }
 
 
 /**
  * Reads information about the attributes of the class.
+ * @param fieldOrMethod false if processing a class
  * @throws  IOException
  * @throws  ClassFormatException
  */
-private void readAttributes() throws IOException, ClassFormatException {
+private void readAttributes(boolean fieldOrMethod) throws IOException, 
ClassFormatException {
 final int attributes_count = dataInputStream.readUnsignedShort();
 for (int i = 0; i < attributes_count; i++) {
 ConstantUtf8 c;
 String name;
 int name_index;
 int length;
-// Get class name from constant pool via `name_index' indirection
+// Get class name from constant pool via 'name_index' indirection
 name_index = dataInputStream.readUnsignedShort();
 c = (ConstantUtf8) constantPool.getConstant(name_index,
 Const.CONSTANT_Utf8);
 name = c.getBytes();
 // Length of data in bytes
 length = dataInputStream.readInt();
-
 if (name.equals("RuntimeVisibleAnnotations")) {
-if (runtimeVisibleAnnotations != null) {
-throw new ClassFormatException(
-"RuntimeVisibleAnnotations attribute is not 
allowed more than once in a class file");
+if (fieldOrMethod) {
+Annotations fieldOrMethodAnnotations = new 
Annotations(dataInputStream, constantPool);
+if (runtimeVisibleMethodOfFieldAnnotations == null) {
+runtimeVisibleMethodOfFieldAnnotations = new 
ArrayList<>();
+}
+
runtimeVisibleMethodOfFieldAnnotations.add(fieldOrMethodAnnotatio

[tomcat] branch 8.5.x updated (8c5da31 -> eb974b4)

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

remm pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from 8c5da31  Remove trailing space
 new 5d85f94  Parse annotations on fields or methods
 new a15c8da  Fix typos and consistent naming
 new 2b4fd1b  Add HandlesTypes test
 new eb974b4  Move to javax

The 4 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:
 .../org/apache/catalina/startup/ContextConfig.java |  2 +-
 .../tomcat/util/bcel/classfile/ClassParser.java| 43 ++--
 .../tomcat/util/bcel/classfile/JavaClass.java  | 35 +++-
 .../apache/tomcat/util/bcel/classfile/Utility.java | 13 --
 .../util/scan/FooSCI.java} | 21 +-
 .../util/scan/TestClassParser.java}| 46 +++---
 .../javax.servlet.ServletContainerInitializer  |  3 +-
 webapps/docs/changelog.xml |  4 ++
 8 files changed, 106 insertions(+), 61 deletions(-)
 copy test/org/apache/{catalina/startup/TesterServletContainerInitializer1.java 
=> tomcat/util/scan/FooSCI.java} (65%)
 copy test/org/apache/{catalina/webresources/TestJarWarResourceSet.java => 
tomcat/util/scan/TestClassParser.java} (55%)
 copy java/org/apache/catalina/util/CharsetMapperDefault.properties => 
test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer
 (95%)

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



[tomcat] 04/04: Move to javax

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

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

commit eb974b44ff17f4d8b612ec8a3e12a4b318d1d530
Author: remm 
AuthorDate: Wed May 5 15:25:25 2021 +0200

Move to javax
---
 test/org/apache/tomcat/util/scan/FooSCI.java| 6 +++---
 ...ntainerInitializer => javax.servlet.ServletContainerInitializer} | 0
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/tomcat/util/scan/FooSCI.java 
b/test/org/apache/tomcat/util/scan/FooSCI.java
index be45d4f..51deec4 100644
--- a/test/org/apache/tomcat/util/scan/FooSCI.java
+++ b/test/org/apache/tomcat/util/scan/FooSCI.java
@@ -18,9 +18,9 @@ package org.apache.tomcat.util.scan;
 
 import java.util.Set;
 
-import jakarta.servlet.ServletContainerInitializer;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.annotation.HandlesTypes;
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.ServletContext;
+import javax.servlet.annotation.HandlesTypes;
 
 import org.apache.tomcat.util.scan.TestClassParser.Foo;
 
diff --git 
a/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer
similarity index 100%
rename from 
test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
rename to 
test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer

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



[tomcat] 04/04: Move to javax

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

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

commit e092977e08ceda0401efd3af9f14e468ccd73fc6
Author: remm 
AuthorDate: Wed May 5 15:25:25 2021 +0200

Move to javax
---
 test/org/apache/tomcat/util/scan/FooSCI.java| 6 +++---
 ...ntainerInitializer => javax.servlet.ServletContainerInitializer} | 0
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/tomcat/util/scan/FooSCI.java 
b/test/org/apache/tomcat/util/scan/FooSCI.java
index be45d4f..51deec4 100644
--- a/test/org/apache/tomcat/util/scan/FooSCI.java
+++ b/test/org/apache/tomcat/util/scan/FooSCI.java
@@ -18,9 +18,9 @@ package org.apache.tomcat.util.scan;
 
 import java.util.Set;
 
-import jakarta.servlet.ServletContainerInitializer;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.annotation.HandlesTypes;
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.ServletContext;
+import javax.servlet.annotation.HandlesTypes;
 
 import org.apache.tomcat.util.scan.TestClassParser.Foo;
 
diff --git 
a/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer
similarity index 100%
rename from 
test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
rename to 
test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer

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



[tomcat] 03/04: Add HandlesTypes test

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

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

commit dc98d9d5642c7785a5350e353337d832ee020037
Author: remm 
AuthorDate: Tue Apr 20 14:34:04 2021 +0200

Add HandlesTypes test

Based on the way to validate from the BZ 65244 example.
---
 test/org/apache/tomcat/util/scan/FooSCI.java   | 37 ++
 .../apache/tomcat/util/scan/TestClassParser.java   | 58 ++
 .../jakarta.servlet.ServletContainerInitializer| 16 ++
 3 files changed, 111 insertions(+)

diff --git a/test/org/apache/tomcat/util/scan/FooSCI.java 
b/test/org/apache/tomcat/util/scan/FooSCI.java
new file mode 100644
index 000..be45d4f
--- /dev/null
+++ b/test/org/apache/tomcat/util/scan/FooSCI.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomcat.util.scan;
+
+import java.util.Set;
+
+import jakarta.servlet.ServletContainerInitializer;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.annotation.HandlesTypes;
+
+import org.apache.tomcat.util.scan.TestClassParser.Foo;
+
+@HandlesTypes(Foo.class)
+public class FooSCI implements ServletContainerInitializer {
+
+static Set> classSet;
+
+@Override
+public void onStartup(final Set> set, final ServletContext 
servletContext) {
+classSet = set;
+}
+
+}
diff --git a/test/org/apache/tomcat/util/scan/TestClassParser.java 
b/test/org/apache/tomcat/util/scan/TestClassParser.java
new file mode 100644
index 000..3756535
--- /dev/null
+++ b/test/org/apache/tomcat/util/scan/TestClassParser.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomcat.util.scan;
+
+import java.io.File;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+
+public class TestClassParser extends TomcatBaseTest {
+
+@Target({ElementType.TYPE, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Foo {
+}
+
+/** and beans */
+@Foo
+public class OnClass {
+}
+
+public class OnField {
+@Foo
+private String name;
+}
+
+@Test
+public void testAnnotations() throws Exception {
+Tomcat tomcat = getTomcatInstance();
+File appDir = new File("test/webapp-sci");
+tomcat.addWebapp("", appDir.getAbsolutePath());
+tomcat.start();
+Assert.assertTrue(FooSCI.classSet.size() == 2);
+Assert.assertTrue(FooSCI.classSet.contains(OnClass.class));
+Assert.assertTrue(FooSCI.classSet.contains(OnField.class));
+}
+}
diff --git 
a/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
new file mode 100644
index 000..19b37e3
--- /dev/null
+++ 
b/test/webapp-sci/WEB-INF/classes/META-INF/services/jakarta.servlet.ServletContainerInitializer
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional inform

[tomcat] 02/04: Fix typos and consistent naming

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

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

commit 32de88082e74c38dd56f7fff8f9b9c7af1d23e97
Author: remm 
AuthorDate: Mon Apr 19 16:49:14 2021 +0200

Fix typos and consistent naming
---
 java/org/apache/tomcat/util/bcel/classfile/ClassParser.java | 10 +-
 java/org/apache/tomcat/util/bcel/classfile/JavaClass.java   | 12 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
index 89dab31..af24856 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
@@ -49,7 +49,7 @@ public final class ClassParser {
 private String[] interfaceNames; // Names of implemented interfaces
 private ConstantPool constantPool; // collection of constants
 private Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
-private List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
+private List runtimeVisibleFieldOrMethodAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 private static final int BUFSIZE = 8192;
 
 private static final String[] INTERFACES_EMPTY_ARRAY = new String[0];
@@ -99,7 +99,7 @@ public final class ClassParser {
 // Return the information we have gathered in a new object
 return new JavaClass(class_name, superclassName,
 accessFlags, constantPool, interfaceNames,
-runtimeVisibleAnnotations, 
runtimeVisibleMethodOfFieldAnnotations);
+runtimeVisibleAnnotations, 
runtimeVisibleFieldOrMethodAnnotations);
 }
 
 
@@ -126,10 +126,10 @@ public final class ClassParser {
 if (name.equals("RuntimeVisibleAnnotations")) {
 if (fieldOrMethod) {
 Annotations fieldOrMethodAnnotations = new 
Annotations(dataInputStream, constantPool);
-if (runtimeVisibleMethodOfFieldAnnotations == null) {
-runtimeVisibleMethodOfFieldAnnotations = new 
ArrayList<>();
+if (runtimeVisibleFieldOrMethodAnnotations == null) {
+runtimeVisibleFieldOrMethodAnnotations = new 
ArrayList<>();
 }
-
runtimeVisibleMethodOfFieldAnnotations.add(fieldOrMethodAnnotations);
+
runtimeVisibleFieldOrMethodAnnotations.add(fieldOrMethodAnnotations);
 } else {
 if (runtimeVisibleAnnotations != null) {
 throw new ClassFormatException(
diff --git a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java 
b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
index 14ef3a1..819175a 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
@@ -35,7 +35,7 @@ public class JavaClass {
 private final String superclassName;
 private final String[] interfaceNames;
 private final Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
-private final List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
+private final List runtimeVisibleFieldOrMethodAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 
 /**
  * Constructor gets all contents as arguments.
@@ -46,14 +46,14 @@ public class JavaClass {
  * @param constant_pool Array of constants
  * @param interfaceNames Implemented interfaces
  * @param runtimeVisibleAnnotations "RuntimeVisibleAnnotations" attribute 
defined on the Class, or null
- * @param runtimeVisibleMethodOfFieldAnnotations 
"RuntimeVisibleAnnotations" attribute defined on the fields or methids, or null
+ * @param runtimeVisibleFieldOrMethodAnnotations 
"RuntimeVisibleAnnotations" attribute defined on the fields or methods, or null
  */
 JavaClass(final String className, final String superclassName,
 final int accessFlags, final ConstantPool constant_pool, final 
String[] interfaceNames,
-final Annotations runtimeVisibleAnnotations, final 
List runtimeVisibleMethodOfFieldAnnotations) {
+final Annotations runtimeVisibleAnnotations, final 
List runtimeVisibleFieldOrMethodAnnotations) {
 this.accessFlags = accessFlags;
 this.runtimeVisibleAnnotations = runtimeVisibleAnnotations;
-this.runtimeVisibleMethodOfFieldAnnotations = 
runtimeVisibleMethodOfFieldAnnotations;
+this.runtimeVisibleFieldOrMethodAnnotations = 
runtimeVisibleFieldOrMethodAnnotations;
 this.className = className;
 this.superclassName = superc

[tomcat] 01/04: Parse annotations on fields or methods

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

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

commit bae8d30b20fabb7c11e7b09dfba7dedd75f26d2c
Author: remm 
AuthorDate: Mon Apr 19 10:49:04 2021 +0200

Parse annotations on fields or methods

BZ 65244: Use that info for HandlesTypes since it is supposed to also
include annotations used on fields and methods.
---
 .../org/apache/catalina/startup/ContextConfig.java |  2 +-
 .../tomcat/util/bcel/classfile/ClassParser.java| 43 --
 .../tomcat/util/bcel/classfile/JavaClass.java  | 35 +-
 .../apache/tomcat/util/bcel/classfile/Utility.java | 13 ---
 webapps/docs/changelog.xml |  4 ++
 5 files changed, 71 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/catalina/startup/ContextConfig.java 
b/java/org/apache/catalina/startup/ContextConfig.java
index 8172a3b..1cb168e 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -2426,7 +2426,7 @@ public class ContextConfig implements LifecycleListener {
 }
 
 if (handlesTypesAnnotations) {
-AnnotationEntry[] annotationEntries = 
javaClass.getAnnotationEntries();
+AnnotationEntry[] annotationEntries = 
javaClass.getAllAnnotationEntries();
 if (annotationEntries != null) {
 for (Map.Entry, Set> 
entry :
 typeInitializerMap.entrySet()) {
diff --git a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java 
b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
index 303be90..89dab31 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
@@ -22,6 +22,8 @@ import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tomcat.util.bcel.Const;
 
@@ -47,6 +49,7 @@ public final class ClassParser {
 private String[] interfaceNames; // Names of implemented interfaces
 private ConstantPool constantPool; // collection of constants
 private Annotations runtimeVisibleAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined in the class
+private List runtimeVisibleMethodOfFieldAnnotations; // 
"RuntimeVisibleAnnotations" attribute defined elsewhere
 private static final int BUFSIZE = 8192;
 
 private static final String[] INTERFACES_EMPTY_ARRAY = new String[0];
@@ -91,41 +94,49 @@ public final class ClassParser {
 // Read class methods, i.e., the functions in the class
 readMethods();
 // Read class attributes
-readAttributes();
+readAttributes(false);
 
 // Return the information we have gathered in a new object
 return new JavaClass(class_name, superclassName,
 accessFlags, constantPool, interfaceNames,
-runtimeVisibleAnnotations);
+runtimeVisibleAnnotations, 
runtimeVisibleMethodOfFieldAnnotations);
 }
 
 
 /**
  * Reads information about the attributes of the class.
+ * @param fieldOrMethod false if processing a class
  * @throws  IOException
  * @throws  ClassFormatException
  */
-private void readAttributes() throws IOException, ClassFormatException {
+private void readAttributes(boolean fieldOrMethod) throws IOException, 
ClassFormatException {
 final int attributes_count = dataInputStream.readUnsignedShort();
 for (int i = 0; i < attributes_count; i++) {
 ConstantUtf8 c;
 String name;
 int name_index;
 int length;
-// Get class name from constant pool via `name_index' indirection
+// Get class name from constant pool via 'name_index' indirection
 name_index = dataInputStream.readUnsignedShort();
 c = (ConstantUtf8) constantPool.getConstant(name_index,
 Const.CONSTANT_Utf8);
 name = c.getBytes();
 // Length of data in bytes
 length = dataInputStream.readInt();
-
 if (name.equals("RuntimeVisibleAnnotations")) {
-if (runtimeVisibleAnnotations != null) {
-throw new ClassFormatException(
-"RuntimeVisibleAnnotations attribute is not 
allowed more than once in a class file");
+if (fieldOrMethod) {
+Annotations fieldOrMethodAnnotations = new 
Annotations(dataInputStream, constantPool);
+if (runtimeVisibleMethodOfFieldAnnotations == null) {
+runtimeVisibleMethodOfFieldAnnotations = new 
ArrayList<>();
+}
+
runtimeVisibleMethodOfFieldAnnotations.add(fieldOrMethodAnnotatio

[tomcat] branch 9.0.x updated (f971941 -> e092977)

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

remm pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from f971941  Remove trailing space
 new bae8d30  Parse annotations on fields or methods
 new 32de880  Fix typos and consistent naming
 new dc98d9d  Add HandlesTypes test
 new e092977  Move to javax

The 4 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:
 .../org/apache/catalina/startup/ContextConfig.java |  2 +-
 .../tomcat/util/bcel/classfile/ClassParser.java| 43 ++--
 .../tomcat/util/bcel/classfile/JavaClass.java  | 35 +++-
 .../apache/tomcat/util/bcel/classfile/Utility.java | 13 --
 .../util/scan/FooSCI.java} | 21 +-
 .../util/scan/TestClassParser.java}| 46 +++---
 .../javax.servlet.ServletContainerInitializer  |  2 +-
 webapps/docs/changelog.xml |  4 ++
 8 files changed, 106 insertions(+), 60 deletions(-)
 copy test/org/apache/{catalina/startup/TesterServletContainerInitializer1.java 
=> tomcat/util/scan/FooSCI.java} (65%)
 copy test/org/apache/{catalina/webresources/TestJarWarResourceSet.java => 
tomcat/util/scan/TestClassParser.java} (55%)
 copy res/META-INF/jasper-el.jar/services/javax.el.ExpressionFactory => 
test/webapp-sci/WEB-INF/classes/META-INF/services/javax.servlet.ServletContainerInitializer
 (95%)

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



[Bug 65244] annotations from @HandlesTypes are checked only at class level when scanning

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65244

--- Comment #24 from Mark Thomas  ---
I have no objection to a back-port now.

-- 
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



Re: Implementing web.xml default-context-path

2021-05-05 Thread Rémy Maucherat
On Wed, May 5, 2021 at 2:42 PM Jean-Louis MONTEIRO 
wrote:

> Thanks for the feedback.
>
> Actually I was not looking for Mark or the Tomcat community to change their
> minds. But for some guidance on how to hack something to get this test
> to pass.
>
> I've been able to do it in TomEE which was the goal.
> Now, I'm totally with you guys. If this is in your opinion a bad use case
> with a bad specification solution, we should challenge the feature and then
> the test.
>

The feature is optional, so it's "fine" with me. It allows suggesting a
path to map the webapp, like Jira saying it should be mapped to /jira
because "why not". This is pointless in practice, but since it's optional,
there's nothing to do and I'm fine with it. The problem is then only the
TCK testing for a mandatory optional feature.

Good news on you working around it.

Rémy


>
> Le mer. 5 mai 2021 à 11:22, Romain Manni-Bucau  a
> écrit :
>
> > Le mer. 5 mai 2021 à 11:19, Mark Thomas  a écrit :
> >
> > > On 05/05/2021 09:58, Rémy Maucherat wrote:
> > > > On Sun, May 2, 2021 at 3:17 PM Jean-Louis MONTEIRO <
> jeano...@gmail.com
> > >
> > > > wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> Still working on getting TomEE certified for Jakarta EE 9.1
> > > >> We are using latest Tomcat 10.x and we indeed see now only one
> failure
> > > as
> > > >> described here
> > > >>
> > > >> https://cwiki.apache.org/confluence/display/TOMCAT/Servlet+TCK+5.0
> > > >>
> > > >> I understand this is not really a critical thing to be certified for
> > > >> Tomcat.
> > > >> And I also understand this is not something the community agrees on.
> > > >>
> > > >> But I'd like, for the sake of getting TomEE certified, to pass this
> > test
> > > >> and therefore I'm looking at a way to patch it on our side.
> > > >>
> > > >> Would you be able to help in giving pointers on how to do it?
> > > >>
> > > >> Any help is appreciated at this point.
> > > >>
> > > >
> > > > We already talked about this (bad) "feature" quite a bit in the past.
> > > > Unless there's a big surprise:
> > > > - This needs intrusive and annoying change to the deployer
> > > > - The benefit to actual users seems to be zero
> > > > - The feature is optional
> > > > As a result, I doubt Mark will change his mind [I am not enthusiastic
> > > > either] and I still don't understand how it is a mandatory TCK test.
> > >
> > > +1 allowing this feature opens up a huge mess of deployment edge cases
> > > that the Tomcat deployment process was designed very carefully to
> avoid.
> > >
> > > > So ... I think you can come up with a hack instead: a Catalina
> listener
> > > > could be added to the Context, then it could configure the rewrite
> > valve
> > > to
> > > > do the url mapping. It should be enough to make this work.
> > >
> > > Another option would be to challenge the TCK test on the grounds the
> > > spec allows containers to override any default-context-path setting but
> > > the TCK assumes this isn't going to happen (in Tomcat it will always
> > > happen).
> > >
> >
> > +1 to challenge this test, if there is a consensus it is wrong no point
> to
> > keep it year after year IMHO.
> >
> >
> > >
> > > Mark
> > >
> > > -
> > > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> > > For additional commands, e-mail: dev-h...@tomcat.apache.org
> > >
> > >
> >
>
>
> --
> Jean-Louis
>


Re: [VOTE] Apache Tomcat migration tool for Jakarta EE 1.0.0

2021-05-05 Thread jean-frederic clere

On 04/05/2021 14:06, Mark Thomas wrote:

[X] +1: Acceptable. Go ahead and release.


tested with my test war file, works like a charm.

--
Cheers

Jean-Frederic

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



Re: Implementing web.xml default-context-path

2021-05-05 Thread Jean-Louis MONTEIRO
Thanks for the feedback.

Actually I was not looking for Mark or the Tomcat community to change their
minds. But for some guidance on how to hack something to get this test
to pass.

I've been able to do it in TomEE which was the goal.
Now, I'm totally with you guys. If this is in your opinion a bad use case
with a bad specification solution, we should challenge the feature and then
the test.

Le mer. 5 mai 2021 à 11:22, Romain Manni-Bucau  a
écrit :

> Le mer. 5 mai 2021 à 11:19, Mark Thomas  a écrit :
>
> > On 05/05/2021 09:58, Rémy Maucherat wrote:
> > > On Sun, May 2, 2021 at 3:17 PM Jean-Louis MONTEIRO  >
> > > wrote:
> > >
> > >> Hi,
> > >>
> > >> Still working on getting TomEE certified for Jakarta EE 9.1
> > >> We are using latest Tomcat 10.x and we indeed see now only one failure
> > as
> > >> described here
> > >>
> > >> https://cwiki.apache.org/confluence/display/TOMCAT/Servlet+TCK+5.0
> > >>
> > >> I understand this is not really a critical thing to be certified for
> > >> Tomcat.
> > >> And I also understand this is not something the community agrees on.
> > >>
> > >> But I'd like, for the sake of getting TomEE certified, to pass this
> test
> > >> and therefore I'm looking at a way to patch it on our side.
> > >>
> > >> Would you be able to help in giving pointers on how to do it?
> > >>
> > >> Any help is appreciated at this point.
> > >>
> > >
> > > We already talked about this (bad) "feature" quite a bit in the past.
> > > Unless there's a big surprise:
> > > - This needs intrusive and annoying change to the deployer
> > > - The benefit to actual users seems to be zero
> > > - The feature is optional
> > > As a result, I doubt Mark will change his mind [I am not enthusiastic
> > > either] and I still don't understand how it is a mandatory TCK test.
> >
> > +1 allowing this feature opens up a huge mess of deployment edge cases
> > that the Tomcat deployment process was designed very carefully to avoid.
> >
> > > So ... I think you can come up with a hack instead: a Catalina listener
> > > could be added to the Context, then it could configure the rewrite
> valve
> > to
> > > do the url mapping. It should be enough to make this work.
> >
> > Another option would be to challenge the TCK test on the grounds the
> > spec allows containers to override any default-context-path setting but
> > the TCK assumes this isn't going to happen (in Tomcat it will always
> > happen).
> >
>
> +1 to challenge this test, if there is a consensus it is wrong no point to
> keep it year after year IMHO.
>
>
> >
> > Mark
> >
> > -
> > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: dev-h...@tomcat.apache.org
> >
> >
>


-- 
Jean-Louis


[tomcat] branch 8.5.x updated: Remove trailing space

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 8c5da31  Remove trailing space
8c5da31 is described below

commit 8c5da311f5517db8909266c6c0799834dcf8b872
Author: Mark Thomas 
AuthorDate: Wed May 5 12:52:29 2021 +0100

Remove trailing space
---
 webapps/docs/changelog.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5ce8918..b3affc6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -143,7 +143,7 @@
 65272: Restore the optional HTTP feature that allows
 LF to be treated as a line terminator for the request line
 and/or HTTP headers lines as well as the standard CRLF.
-This behaviour was previously removed as a side-effect of the fix for 
+This behaviour was previously removed as a side-effect of the fix for
 CVE-2020-1935. (markt)
   
 

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



[tomcat] branch 9.0.x updated (70c236b -> f971941)

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

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


from 70c236b  Fix BZ 65272. Restore the use of LF as an HTTP line terminator
 add f971941  Remove trailing space

No new revisions were added by this update.

Summary of changes:
 webapps/docs/changelog.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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



[tomcat] branch master updated: Remove trailing space

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

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


The following commit(s) were added to refs/heads/master by this push:
 new 0235fd7  Remove trailing space
0235fd7 is described below

commit 0235fd745b9fe3805bf2efa38befa9d65a3c4259
Author: Mark Thomas 
AuthorDate: Wed May 5 12:52:29 2021 +0100

Remove trailing space
---
 webapps/docs/changelog.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f8267d3..07810c6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -147,7 +147,7 @@
 65272: Restore the optional HTTP feature that allows
 LF to be treated as a line terminator for the request line
 and/or HTTP headers lines as well as the standard CRLF.
-This behaviour was previously removed as a side-effect of the fix for 
+This behaviour was previously removed as a side-effect of the fix for
 CVE-2020-1935. (markt)
   
 

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



[tomcat] branch master updated: Refactor InstanceManager lookup

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

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


The following commit(s) were added to refs/heads/master by this push:
 new 7883e3d  Refactor InstanceManager lookup
7883e3d is described below

commit 7883e3dec71c27b2d14eb4a41c1beae9ff726aa5
Author: Mark Thomas 
AuthorDate: Wed May 5 12:08:50 2021 +0100

Refactor InstanceManager lookup
---
 java/org/apache/tomcat/websocket/WsSession.java| 29 +++---
 .../tomcat/websocket/WsWebSocketContainer.java |  8 --
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index 4c71d84..c91a0f2 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -54,7 +54,6 @@ import 
jakarta.websocket.server.ServerEndpointConfig.Configurator;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
-import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoEndpointServer;
@@ -173,12 +172,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
-this.localEndpoint = clientEndpointHolder.getInstance(instanceManager);
+this.localEndpoint = 
clientEndpointHolder.getInstance(getInstanceManager());
 
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("wsSession.created", id));
@@ -261,11 +255,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
-
+InstanceManager instanceManager = getInstanceManager();
 Configurator configurator = serverEndpointConfig.getConfigurator();
 Class clazz = serverEndpointConfig.getEndpointClass();
 
@@ -390,10 +380,7 @@ public class WsSession implements Session {
 this.userProperties.putAll(endpointConfig.getUserProperties());
 this.id = Long.toHexString(ids.getAndIncrement());
 
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = getInstanceManager();
 if (instanceManager != null) {
 try {
 instanceManager.newInstance(localEndpoint);
@@ -408,6 +395,11 @@ public class WsSession implements Session {
 }
 
 
+public InstanceManager getInstanceManager() {
+return webSocketContainer.getInstanceManager(applicationClassLoader);
+}
+
+
 @Override
 public WebSocketContainer getContainer() {
 checkState();
@@ -758,10 +750,7 @@ public class WsSession implements Session {
 
 // Fire the onClose event
 Throwable throwable = null;
-InstanceManager instanceManager = 
webSocketContainer.getInstanceManager();
-if (instanceManager == null) {
-instanceManager = 
InstanceManagerBindings.get(applicationClassLoader);
-}
+InstanceManager instanceManager = 
webSocketContainer.getInstanceManager(applicationClassLoader);
 Thread t = Thread.currentThread();
 ClassLoader cl = t.getContextClassLoader();
 t.setContextClassLoader(applicationClassLoader);
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index aee1994..52d7837 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -69,6 +69,7 @@ import jakarta.websocket.WebSocketContainer;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.InstanceManagerBindings;
 import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
@@ -105,8 +106,11 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
 

[Bug 65244] annotations from @HandlesTypes are checked only at class level when scanning

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65244

--- Comment #23 from Remy Maucherat  ---
(In reply to Remy Maucherat from comment #22)
> So the fix will be in 10.0.6, will see if/when/how it can be backported to 9
> and 8.5.

Should I backport now or should it be tested in 10.0.6 before being included in
the 8.5 and 9 releases ?

-- 
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



[Bug 56148] support (multiple) ocsp stapling

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56148

Mark Thomas  changed:

   What|Removed |Added

Version|unspecified |8.5.x-trunk
Product|Tomcat 7|Tomcat 8
  Component|Connectors  |Connectors
   Target Milestone|--- |

--- Comment #14 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 56614] Add a switch to ignore annotations detection on tag instances for performance reason

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56614

Mark Thomas  changed:

   What|Removed |Added

Version|trunk   |8.5.x-trunk
   Target Milestone|--- |
  Component|Jasper  |Jasper
Product|Tomcat 7|Tomcat 8

--- Comment #12 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 57827] Enable adding/removing of members via jmx in a static-membership cluster

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57827

Mark Thomas  changed:

   What|Removed |Added

  Component|Cluster |Cluster
Version|7.0.59  |8.5.x-trunk
Product|Tomcat 7|Tomcat 8
   Target Milestone|--- |

--- Comment #1 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 60597] Add ability to set cipher suites for websocket client connections

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60597

Mark Thomas  changed:

   What|Removed |Added

Product|Tomcat 7|Tomcat 8
   Target Milestone|--- |
Version|7.0.73  |8.5.x-trunk
  Component|WebSocket   |WebSocket

--- Comment #16 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 56300] [Tribes] No useful examples, lack of documentation

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56300

Mark Thomas  changed:

   What|Removed |Added

Version|unspecified |8.5.x-trunk
  Component|Documentation   |Documentation
Product|Tomcat 7|Tomcat 8
   Target Milestone|--- |

--- Comment #4 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 63167] Network Requirements To Resolve No Members Active In Cluster Group

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=63167

Mark Thomas  changed:

   What|Removed |Added

   Target Milestone|--- |
Product|Tomcat 7|Tomcat 8
  Component|Documentation   |Documentation
Version|7.0.70  |8.5.x-trunk

--- Comment #2 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 56438] If jar scan does not find context config or TLD config, log a message

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56438

Mark Thomas  changed:

   What|Removed |Added

Product|Tomcat 7|Tomcat 8
Version|7.0.53  |8.5.x-trunk
  Component|Catalina|Catalina
   Target Milestone|--- |

--- Comment #22 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 57872] Do not auto-switch session cookie to version=1 due to '/' in Path when running in "strict compliance" mode (Internet Explorer and rfc6265)

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57872

Mark Thomas  changed:

   What|Removed |Added

  Component|Catalina|Catalina
   Target Milestone|--- |
Product|Tomcat 7|Tomcat 8
Version|7.0.61  |8.5.x-trunk

--- Comment #2 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 55477] Add a solution to map a realm name to a security role

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=55477

Mark Thomas  changed:

   What|Removed |Added

Product|Tomcat 7|Tomcat 8
Version|trunk   |8.5.x-trunk
  Component|Catalina|Catalina
   Target Milestone|--- |

--- Comment #21 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 55470] Help users for ClassNotFoundExceptions during startup [PATCH]

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=55470

Mark Thomas  changed:

   What|Removed |Added

  Component|Catalina|Catalina
   Target Milestone|--- |
Product|Tomcat 7|Tomcat 8
Version|trunk   |8.5.x-trunk

--- Comment #3 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 57367] If JAR scan experiences a stack overflow, give the URL from which each class in the loop was loaded in the complaint

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57367

Mark Thomas  changed:

   What|Removed |Added

Product|Tomcat 7|Tomcat 8
Version|7.0.57  |8.5.x-trunk
  Component|Catalina|Catalina
   Target Milestone|--- |

--- Comment #2 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 56787] Simplified jndi name parsing

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56787

Mark Thomas  changed:

   What|Removed |Added

Version|trunk   |8.5.x-trunk
Product|Tomcat 7|Tomcat 8
   Target Milestone|--- |
  Component|Catalina|Catalina

--- Comment #4 from Mark Thomas  ---
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.

-- 
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



[Bug 65272] Problems proccessing HTTP request without CR in last versions

2021-05-05 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=65272

Mark Thomas  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #7 from Mark Thomas  ---
Fixed in:
- 10.0.x for 10.0.6 onwards
- 9.0.x for 9.0.46 onwards
- 8.5.x for 8.5.66 onwards

-- 
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 8.5.x updated: Fix BZ 65272. Restore the use of LF as an HTTP line terminator

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 040d899  Fix BZ 65272. Restore the use of LF as an HTTP line terminator
040d899 is described below

commit 040d8993e491b7deece7a09da7be7b11642f444f
Author: Mark Thomas 
AuthorDate: Wed Apr 28 18:23:07 2021 +0100

Fix BZ 65272. Restore the use of LF as an HTTP line terminator
---
 .../apache/coyote/http11/Http11InputBuffer.java| 16 
 .../coyote/http11/TestHttp11InputBuffer.java   | 22 --
 .../coyote/http11/TestHttp11InputBufferCRLF.java   |  8 
 webapps/docs/changelog.xml |  7 +++
 4 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index b8fcee3..c50b4d1 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -564,10 +564,15 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 prevChr = chr;
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
-// Possible end of request line. Need LF next.
+// Possible end of request line. Need LF next else invalid.
 } else if (prevChr == Constants.CR && chr == Constants.LF) {
+// CRLF is the standard line terminator
 end = pos - 1;
 parsingRequestLineEol = true;
+} else if (chr == Constants.LF) {
+// LF is an optional line terminator
+end = pos;
+parsingRequestLineEol = true;
 } else if (prevChr == Constants.CR || 
!HttpParser.isHttpProtocol(chr)) {
 String invalidProtocol = 
parseInvalid(parsingRequestLineStart, byteBuffer);
 throw new 
IllegalArgumentException(sm.getString("iib.invalidHttpProtocol", 
invalidProtocol));
@@ -840,7 +845,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 
 if (chr == Constants.CR && prevChr != Constants.CR) {
 // Possible start of CRLF - process the next byte.
-} else if (prevChr == Constants.CR && chr == Constants.LF) {
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 return HeaderParseStatus.DONE;
 } else {
 if (prevChr == Constants.CR) {
@@ -952,7 +958,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
 // Possible start of CRLF - process the next byte.
-} else if (prevChr == Constants.CR && chr == Constants.LF) 
{
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 eol = true;
 } else if (prevChr == Constants.CR) {
 // Invalid value
@@ -1030,7 +1037,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
 // Skip
-} else if (prevChr == Constants.CR && chr == Constants.LF) {
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 eol = true;
 } else {
 headerData.lastSignificantChar = pos;
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java 
b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index ea38be0..36a65e1 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -198,6 +198,10 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 // TAB is allowed
 continue;
 }
+if (i == '\n') {
+// LF is the optional line terminator
+continue;
+}
 doTestBug51557InvalidCharInValue((char) i);
 tearDown();
 setUp();
@@ -688,24 +692,6 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 
 
 @Test
-public void testInvalidEndOfRequestLine02() {
-
-String[] request = new String[1];
-request[0] =
-"GET /test HTTP/1.1" + LF +
-"Host: localhost:8080" + CRLF +
-"Connection: close" + CRLF +
-CRLF;
-
-InvalidClient client = new InvalidClient(request

[tomcat] branch 9.0.x updated (eecdbca -> 70c236b)

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

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


from eecdbca  First part of fix for BZ 65262. Make WebSocket more IoC 
friendly
 add 70c236b  Fix BZ 65272. Restore the use of LF as an HTTP line terminator

No new revisions were added by this update.

Summary of changes:
 .../apache/coyote/http11/Http11InputBuffer.java| 16 
 .../coyote/http11/TestHttp11InputBuffer.java   | 22 --
 .../coyote/http11/TestHttp11InputBufferCRLF.java   |  8 
 webapps/docs/changelog.xml |  7 +++
 4 files changed, 31 insertions(+), 22 deletions(-)

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



[tomcat] branch master updated: Fix BZ 65272. Restore the use of LF as an HTTP line terminator

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

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


The following commit(s) were added to refs/heads/master by this push:
 new 55093a2  Fix BZ 65272. Restore the use of LF as an HTTP line terminator
55093a2 is described below

commit 55093a2bc3ccdd759c63ef52ee99ba7f05e8c34d
Author: Mark Thomas 
AuthorDate: Wed Apr 28 18:23:07 2021 +0100

Fix BZ 65272. Restore the use of LF as an HTTP line terminator
---
 .../apache/coyote/http11/Http11InputBuffer.java| 16 
 .../coyote/http11/TestHttp11InputBuffer.java   | 22 --
 .../coyote/http11/TestHttp11InputBufferCRLF.java   |  8 
 webapps/docs/changelog.xml |  7 +++
 4 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index 81a3a5a..b5f769f 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -550,10 +550,15 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 prevChr = chr;
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
-// Possible end of request line. Need LF next.
+// Possible end of request line. Need LF next else invalid.
 } else if (prevChr == Constants.CR && chr == Constants.LF) {
+// CRLF is the standard line terminator
 end = pos - 1;
 parsingRequestLineEol = true;
+} else if (chr == Constants.LF) {
+// LF is an optional line terminator
+end = pos;
+parsingRequestLineEol = true;
 } else if (prevChr == Constants.CR || 
!HttpParser.isHttpProtocol(chr)) {
 String invalidProtocol = 
parseInvalid(parsingRequestLineStart, byteBuffer);
 throw new 
IllegalArgumentException(sm.getString("iib.invalidHttpProtocol", 
invalidProtocol));
@@ -841,7 +846,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 
 if (chr == Constants.CR && prevChr != Constants.CR) {
 // Possible start of CRLF - process the next byte.
-} else if (prevChr == Constants.CR && chr == Constants.LF) {
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 return HeaderParseStatus.DONE;
 } else {
 if (prevChr == Constants.CR) {
@@ -953,7 +959,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
 // Possible start of CRLF - process the next byte.
-} else if (prevChr == Constants.CR && chr == Constants.LF) 
{
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 eol = true;
 } else if (prevChr == Constants.CR) {
 // Invalid value
@@ -1031,7 +1038,8 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 chr = byteBuffer.get();
 if (chr == Constants.CR) {
 // Skip
-} else if (prevChr == Constants.CR && chr == Constants.LF) {
+} else if (chr == Constants.LF) {
+// CRLF or LF is an acceptable line terminator
 eol = true;
 } else {
 headerData.lastSignificantChar = pos;
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java 
b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index a1d50d0..e7b04dd 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -198,6 +198,10 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 // TAB is allowed
 continue;
 }
+if (i == '\n') {
+// LF is the optional line terminator
+continue;
+}
 doTestBug51557InvalidCharInValue((char) i);
 tearDown();
 setUp();
@@ -688,24 +692,6 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 
 
 @Test
-public void testInvalidEndOfRequestLine02() {
-
-String[] request = new String[1];
-request[0] =
-"GET /test HTTP/1.1" + LF +
-"Host: localhost:8080" + CRLF +
-"Connection: close" + CRLF +
-CRLF;
-
-InvalidClient client = new InvalidClient(reque

[GitHub] [tomcat] markt-asf merged pull request #417: Fix BZ 65272. Restore the use of LF as an HTTP line terminator

2021-05-05 Thread GitBox


markt-asf merged pull request #417:
URL: https://github.com/apache/tomcat/pull/417


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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



[tomcat-jakartaee-migration] branch master updated: Further prep for next development cycle

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

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git


The following commit(s) were added to refs/heads/master by this push:
 new ecca93a  Further prep for next development cycle
ecca93a is described below

commit ecca93a20700302cf48861d452482dc9a2ea0c50
Author: Mark Thomas 
AuthorDate: Tue May 4 12:57:39 2021 +0100

Further prep for next development cycle
---
 CHANGES.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index b38a8df..98be94f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,8 @@
 # Tomcat Migration Tool for Jakarta EE - Changelog
 
-## 1.0.0 (in progress)
+## 1.0.1 (in progress)
+
+## 1.0.0
 
 - Fix [#14](https://github.com/apache/tomcat-jakartaee-migration/issues/14). 
Do not migrate `javax.xml.(registry|rpc)` namespaces. (mgrigorov)
 - The class transformer will now validate that the target classes in the 
Jakarta namespace exist in the runtime environment (remm)

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



Re: Implementing web.xml default-context-path

2021-05-05 Thread Romain Manni-Bucau
Le mer. 5 mai 2021 à 11:19, Mark Thomas  a écrit :

> On 05/05/2021 09:58, Rémy Maucherat wrote:
> > On Sun, May 2, 2021 at 3:17 PM Jean-Louis MONTEIRO 
> > wrote:
> >
> >> Hi,
> >>
> >> Still working on getting TomEE certified for Jakarta EE 9.1
> >> We are using latest Tomcat 10.x and we indeed see now only one failure
> as
> >> described here
> >>
> >> https://cwiki.apache.org/confluence/display/TOMCAT/Servlet+TCK+5.0
> >>
> >> I understand this is not really a critical thing to be certified for
> >> Tomcat.
> >> And I also understand this is not something the community agrees on.
> >>
> >> But I'd like, for the sake of getting TomEE certified, to pass this test
> >> and therefore I'm looking at a way to patch it on our side.
> >>
> >> Would you be able to help in giving pointers on how to do it?
> >>
> >> Any help is appreciated at this point.
> >>
> >
> > We already talked about this (bad) "feature" quite a bit in the past.
> > Unless there's a big surprise:
> > - This needs intrusive and annoying change to the deployer
> > - The benefit to actual users seems to be zero
> > - The feature is optional
> > As a result, I doubt Mark will change his mind [I am not enthusiastic
> > either] and I still don't understand how it is a mandatory TCK test.
>
> +1 allowing this feature opens up a huge mess of deployment edge cases
> that the Tomcat deployment process was designed very carefully to avoid.
>
> > So ... I think you can come up with a hack instead: a Catalina listener
> > could be added to the Context, then it could configure the rewrite valve
> to
> > do the url mapping. It should be enough to make this work.
>
> Another option would be to challenge the TCK test on the grounds the
> spec allows containers to override any default-context-path setting but
> the TCK assumes this isn't going to happen (in Tomcat it will always
> happen).
>

+1 to challenge this test, if there is a consensus it is wrong no point to
keep it year after year IMHO.


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


Re: Implementing web.xml default-context-path

2021-05-05 Thread Mark Thomas

On 05/05/2021 09:58, Rémy Maucherat wrote:

On Sun, May 2, 2021 at 3:17 PM Jean-Louis MONTEIRO 
wrote:


Hi,

Still working on getting TomEE certified for Jakarta EE 9.1
We are using latest Tomcat 10.x and we indeed see now only one failure as
described here

https://cwiki.apache.org/confluence/display/TOMCAT/Servlet+TCK+5.0

I understand this is not really a critical thing to be certified for
Tomcat.
And I also understand this is not something the community agrees on.

But I'd like, for the sake of getting TomEE certified, to pass this test
and therefore I'm looking at a way to patch it on our side.

Would you be able to help in giving pointers on how to do it?

Any help is appreciated at this point.



We already talked about this (bad) "feature" quite a bit in the past.
Unless there's a big surprise:
- This needs intrusive and annoying change to the deployer
- The benefit to actual users seems to be zero
- The feature is optional
As a result, I doubt Mark will change his mind [I am not enthusiastic
either] and I still don't understand how it is a mandatory TCK test.


+1 allowing this feature opens up a huge mess of deployment edge cases 
that the Tomcat deployment process was designed very carefully to avoid.



So ... I think you can come up with a hack instead: a Catalina listener
could be added to the Context, then it could configure the rewrite valve to
do the url mapping. It should be enough to make this work.


Another option would be to challenge the TCK test on the grounds the 
spec allows containers to override any default-context-path setting but 
the TCK assumes this isn't going to happen (in Tomcat it will always 
happen).


Mark

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



Re: Implementing web.xml default-context-path

2021-05-05 Thread Rémy Maucherat
On Sun, May 2, 2021 at 3:17 PM Jean-Louis MONTEIRO 
wrote:

> Hi,
>
> Still working on getting TomEE certified for Jakarta EE 9.1
> We are using latest Tomcat 10.x and we indeed see now only one failure as
> described here
>
> https://cwiki.apache.org/confluence/display/TOMCAT/Servlet+TCK+5.0
>
> I understand this is not really a critical thing to be certified for
> Tomcat.
> And I also understand this is not something the community agrees on.
>
> But I'd like, for the sake of getting TomEE certified, to pass this test
> and therefore I'm looking at a way to patch it on our side.
>
> Would you be able to help in giving pointers on how to do it?
>
> Any help is appreciated at this point.
>

We already talked about this (bad) "feature" quite a bit in the past.
Unless there's a big surprise:
- This needs intrusive and annoying change to the deployer
- The benefit to actual users seems to be zero
- The feature is optional
As a result, I doubt Mark will change his mind [I am not enthusiastic
either] and I still don't understand how it is a mandatory TCK test.

So ... I think you can come up with a hack instead: a Catalina listener
could be added to the Context, then it could configure the rewrite valve to
do the url mapping. It should be enough to make this work.

Rémy


>
>
> --
> Jean-Louis
>