(tomcat) branch 9.0.x updated (31fc71858f -> 725467428b)

2024-04-19 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 31fc71858f Dispatch after AsyncListener.onError() should actually 
dispatch
 new acc9a94f89 Fix typos
 new 3f9b18d778 Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new 3d81c5cd9e Refactor to specify acceptor stop wait time in ms rather 
than s
 new 725467428b Reduce the default wait time for the acceptor unlock

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:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   | 12 
 java/org/apache/tomcat/util/net/Acceptor.java   | 12 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java   |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java|  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  | 11 +++
 webapps/docs/config/http.xml|  7 +--
 8 files changed, 53 insertions(+), 17 deletions(-)


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



(tomcat) 02/04: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 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 3f9b18d7788300571178b6d3f95e96fdbd80504b
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  6 +-
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 19edc2f514..b047a5490e 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1183,13 +1183,9 @@ public abstract class AbstractEndpoint {
 
 try (java.net.Socket s = new java.net.Socket()) {
 int stmo = 2 * 1000;
-int utmo = 2 * 1000;
 if (getSocketProperties().getSoTimeout() > stmo) {
 stmo = getSocketProperties().getSoTimeout();
 }
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
@@ -1198,7 +1194,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getDeferAccept()) {
 /*
  * In the case of a deferred accept / accept filters we 
need to
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 0945510492..10b4fc1f47 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -161,6 +161,8 @@ socket.apr.write.error=Unexpected error [{0}] writing data 
to the APR/native soc
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b08325a20c..d71f6bffb8 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -462,7 +469,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 void setObjectName(ObjectName oname) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8bb08ecb3c..c3f8e97f95 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -143,6 +143,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (markt)
   
+  
+Allow any positive value for socket.unlockTimeout. If a
+negative or zero value is 

(tomcat) 01/04: Fix typos

2024-04-19 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 acc9a94f89a1c3a6e6829c0bcb1c732e59df7bf1
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 53a0b807b3..19edc2f514 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1192,7 +1192,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1216,7 +1216,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


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



(tomcat) 04/04: Reduce the default wait time for the acceptor unlock

2024-04-19 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 725467428b4cfe14b325168bf9849f3d5fe4ae9d
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 434ce6d889..99966fd464 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -323,7 +323,12 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stopMillis(1);
+/*
+ * Need to wait for the acceptor to unlock but not too long. 100ms 
plus twice the unlock timeout should be
+ * plenty of time for the acceptor to unlock without being an 
excessively long wait if the unlock fails.
+ */
+int acceptorWaitMilliSeconds = 100 + 2 * 
getSocketProperties().getUnlockTimeout();
+acceptor.stopMillis(acceptorWaitMilliSeconds);
 if (poller != null) {
 poller.destroy();
 poller = null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c3f8e97f95..3d11e31374 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -148,6 +148,12 @@
 negative or zero value is configured, the default of 250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


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



(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 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 3d81c5cd9e3836be806b651b0f81dc68f58fc4f4
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index b047a5490e..d6dfe75f5f 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1562,7 +1562,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index bbfd8dd695..3b5cf500a3 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -200,12 +200,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 21b9f8acfb..0c8848bb98 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -210,7 +210,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint {
@@ -448,11 +448,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 if (poller != null) {
 poller.destroy();
 poller = null;


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



(tomcat) branch 10.1.x updated (443e9be641 -> b76216af5d)

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from 443e9be641 getDeferAccept() always returns false - remove unused code
 new d30a545b31 SocketTimeout has no impact for acceptor unlock - remove it
 new b79a946cbc Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new ba98642273 Refactor to specify acceptor stop wait time in ms rather 
than s
 new b76216af5d Reduce the default wait time for the acceptor unlock

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:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   | 15 ---
 java/org/apache/tomcat/util/net/Acceptor.java   | 12 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java   |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java|  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  | 11 +++
 webapps/docs/config/http.xml|  7 +--
 8 files changed, 53 insertions(+), 20 deletions(-)


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



(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit ba98642273f1ce9a81857506dffb6dc370d7d2f9
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 460e7543f5..03a12d1959 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1493,7 +1493,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index b1083b292a..d8deb8cb26 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -171,12 +171,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 5bbc3a11f8..0c3cbad675 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -199,7 +199,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint {
@@ -437,11 +437,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 if (poller != null) {
 poller.destroy();
 poller = null;


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



(tomcat) 01/04: SocketTimeout has no impact for acceptor unlock - remove it

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit d30a545b319abfcdadc9f94d26a529324c9401b5
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:45:56 2024 +0100

SocketTimeout has no impact for acceptor unlock - remove it
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 7bae5f68ab..a46ee4ce9e 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1129,15 +1129,12 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int stmo = 2 * 1000;
 int utmo = 2 * 1000;
-if (getSocketProperties().getSoTimeout() > stmo) {
-stmo = getSocketProperties().getSoTimeout();
-}
 if (getSocketProperties().getUnlockTimeout() > utmo) {
 utmo = getSocketProperties().getUnlockTimeout();
 }
-s.setSoTimeout(stmo);
+// Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
+s.setSoTimeout(utmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.


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



(tomcat) 04/04: Reduce the default wait time for the acceptor unlock

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit b76216af5d8ad0608c3da5f0a9a273f3b46f647e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index c53164e256..9f646e73eb 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -296,7 +296,12 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stopMillis(1);
+/*
+ * Need to wait for the acceptor to unlock but not too long. 100ms 
plus twice the unlock timeout should be
+ * plenty of time for the acceptor to unlock without being an 
excessively long wait if the unlock fails.
+ */
+int acceptorWaitMilliSeconds = 100 + 2 * 
getSocketProperties().getUnlockTimeout();
+acceptor.stopMillis(acceptorWaitMilliSeconds);
 if (poller != null) {
 poller.destroy();
 poller = null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 53ebb4a103..c2a903f944 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -158,6 +158,12 @@
 negative or zero value is configured, the default of 250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


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



(tomcat) 02/04: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit b79a946cbc3fa55073c733dbf4a9ab1c5fdbd003
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  8 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index a46ee4ce9e..460e7543f5 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1129,12 +1129,8 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int utmo = 2 * 1000;
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 // Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
-s.setSoTimeout(utmo);
+s.setSoTimeout(getSocketProperties().getUnlockTimeout());
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
@@ -1142,7 +1138,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 8557463f7e..35c9d890c2 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -139,6 +139,8 @@ sniExtractor.tooEarly=It is illegal to call this method 
before the client hello
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b91d54f0e2..10b9fd765f 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -451,7 +458,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 3a295c0937..53ebb4a103 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -153,6 +153,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (markt)
   
+  
+Allow any 

Re: [PR] Add support for timescales with time-taken access log token. [tomcat]

2024-04-19 Thread via GitHub


markt-asf commented on code in PR #721:
URL: https://github.com/apache/tomcat/pull/721#discussion_r1572780769


##
java/org/apache/catalina/valves/AbstractAccessLogValve.java:
##
@@ -1756,10 +1776,14 @@ protected AccessLogElement 
createAccessLogElement(String name, char pattern) {
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
 } else if ("us".equals(name)) {
-return new ElapsedTimeElement(true, false);
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MICROSECONDS);
+} else if ("ms".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
+} else if ("fs".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.SECONDS_FRACTIONAL);

Review Comment:
   It is the electronics engineer in me - capacitors have really small values.
   
   `fracsec` works for me.



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

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

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) branch 10.1.x updated: getDeferAccept() always returns false - remove unused code

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 443e9be641 getDeferAccept() always returns false - remove unused code
443e9be641 is described below

commit 443e9be641fd9a0db4d60cd111dd7d61423be055
Author: Mark Thomas 
AuthorDate: Fri Apr 19 19:41:28 2024 +0100

getDeferAccept() always returns false - remove unused code
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 14 --
 1 file changed, 14 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index e53f9e0286..7bae5f68ab 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -17,7 +17,6 @@
 package org.apache.tomcat.util.net;
 
 import java.io.IOException;
-import java.io.OutputStreamWriter;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
@@ -1147,19 +1146,6 @@ public abstract class AbstractEndpoint {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
 s.connect(unlockAddress,utmo);
-if (getDeferAccept()) {
-/*
- * In the case of a deferred accept / accept filters we 
need to
- * send data to wake up the accept. Send OPTIONS * to 
bypass
- * even BSD accept filters. The Acceptor will discard it.
- */
-OutputStreamWriter sw;
-
-sw = new OutputStreamWriter(s.getOutputStream(), 
"ISO-8859-1");
-sw.write("OPTIONS * HTTP/1.0\r\n" +
-"User-Agent: Tomcat wakeup connection\r\n\r\n");
-sw.flush();
-}
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }


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



(tomcat) branch 10.1.x updated: Fix typos

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0b00fdb313 Fix typos
0b00fdb313 is described below

commit 0b00fdb3131c17de0051141b7ee4ba2e8632f032
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index bfb90b0127..e53f9e0286 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1140,7 +1140,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1164,7 +1164,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


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



(tomcat) 05/06: Reduce the default wait time for the acceptor unlock

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 59c53815d0cead640663d6a1fcdef826335e283e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:08:09 2024 +0100

Reduce the default wait time for the acceptor unlock
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 7 ++-
 webapps/docs/changelog.xml   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index e949b11df4..30279002dd 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -297,7 +297,12 @@ public class NioEndpoint extends 
AbstractNetworkChannelEndpoint250ms
 will be used. (mark)
   
+  
+Reduce the time spent waiting for the connector to unlock. The previous
+default of 10s was noticeably too long for cases where the unlock has
+failed. The wait time is now 100ms plus twice
+socket.unlockTimeout. (markt)
+  
 
   
   


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



(tomcat) 06/06: Remove deprecated code

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 1ddcd538a8b2328d02e98cb9d207940256a19f5e
Author: Mark Thomas 
AuthorDate: Fri Apr 19 19:16:07 2024 +0100

Remove deprecated code
---
 java/org/apache/tomcat/util/net/Acceptor.java | 16 
 1 file changed, 16 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index d8deb8cb26..d570bda50b 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -164,22 +164,6 @@ public class Acceptor implements Runnable {
 }
 
 
-/**
- * Signals the Acceptor to stop, optionally waiting for that stop process
- * to complete before returning. If a wait is requested and the stop does
- * not complete in that time a warning will be logged.
- *
- * @param waitSeconds The time to wait in seconds. Use a value less than
- *zero for no wait.
- *
- * @deprecated Unused. Will be remove in Tomcat 11 onwards.
- */
-@Deprecated
-public void stop(int waitSeconds) {
-stopMillis(waitSeconds * 1000);
-}
-
-
 public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
 if (waitMilliseconds > 0) {


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



(tomcat) 01/06: Fix typos

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 06ecc621637d2e9119a8640eaa71cd748e7013c3
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:44:32 2024 +0100

Fix typos
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 2c8a77ddd2..f4f31085a4 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1295,7 +1295,7 @@ public abstract class AbstractEndpoint {
 }
 s.setSoTimeout(stmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
-// That causes delays when running the unit tests. Explicitly 
enableing linger but with a timeout of
+// That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
 s.setSoLinger(true, 0);
 if (getLog().isTraceEnabled()) {
@@ -1306,7 +1306,7 @@ public abstract class AbstractEndpoint {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
 }
-// Wait for up to 1000ms acceptor threads to unlock. Particularly
+// Wait for up to 1000ms for acceptor thread to unlock. 
Particularly
 // for the unit tests, we want to exit this loop as quickly as
 // possible. However, we also don't want to trigger excessive CPU
 // usage if the unlock takes longer than expected. Therefore, we


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



(tomcat) 03/06: Allow any positive value for socket.unlockTimeout rather than >=2s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 2bbee3883dd40f3612fc2620fc58b2f43ee5debd
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:49:26 2024 +0100

Allow any positive value for socket.unlockTimeout rather than >=2s

Implement limit in setter so it always applies.
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java   |  8 ++--
 java/org/apache/tomcat/util/net/LocalStrings.properties |  2 ++
 java/org/apache/tomcat/util/net/SocketProperties.java   | 13 -
 webapps/docs/changelog.xml  |  5 +
 webapps/docs/config/http.xml|  7 +--
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 1e0f3bf28b..c3a5ee523d 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1285,12 +1285,8 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int utmo = 2 * 1000;
-if (getSocketProperties().getUnlockTimeout() > utmo) {
-utmo = getSocketProperties().getUnlockTimeout();
-}
 // Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
-s.setSoTimeout(utmo);
+s.setSoTimeout(getSocketProperties().getUnlockTimeout());
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.
@@ -1298,7 +1294,7 @@ public abstract class AbstractEndpoint {
 if (getLog().isTraceEnabled()) {
 getLog().trace("About to unlock socket for:" + 
unlockAddress);
 }
-s.connect(unlockAddress,utmo);
+s.connect(unlockAddress, 
getSocketProperties().getUnlockTimeout());
 if (getLog().isTraceEnabled()) {
 getLog().trace("Socket unlock completed for:" + 
unlockAddress);
 }
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 20460c9326..f10dfafc03 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -140,6 +140,8 @@ sniExtractor.tooEarly=It is illegal to call this method 
before the client hello
 socket.closed=The socket associated with this connection has been closed.
 socket.sslreneg=Exception re-negotiating SSL connection
 
+socketProperties.negativeUnlockTimeout=The negative value for unlockTimeout 
has been ignored
+
 socketWrapper.readTimeout=Read timeout
 socketWrapper.writeTimeout=Write timeout
 
diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java 
b/java/org/apache/tomcat/util/net/SocketProperties.java
index b91d54f0e2..10b9fd765f 100644
--- a/java/org/apache/tomcat/util/net/SocketProperties.java
+++ b/java/org/apache/tomcat/util/net/SocketProperties.java
@@ -26,6 +26,10 @@ import java.nio.channels.AsynchronousSocketChannel;
 
 import javax.management.ObjectName;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Properties that can be set in the Connector element
  * in server.xml. All properties are prefixed with socket.
@@ -33,6 +37,9 @@ import javax.management.ObjectName;
  */
 public class SocketProperties {
 
+private static final Log log = LogFactory.getLog(SocketProperties.class);
+private static final StringManager sm = 
StringManager.getManager(SocketProperties.class);
+
 /**
  * Enable/disable socket processor cache, this bounded cache stores
  * SocketProcessor objects to reduce GC
@@ -451,7 +458,11 @@ public class SocketProperties {
 }
 
 public void setUnlockTimeout(int unlockTimeout) {
-this.unlockTimeout = unlockTimeout;
+if (unlockTimeout > 0) {
+this.unlockTimeout = unlockTimeout;
+} else {
+log.warn(sm.getString("socketProperties.negativeUnlockTimeout"));
+}
 }
 
 /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f6eacba634..6cc139f23a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -148,6 +148,11 @@
 Align non-secure and secure writes with NIO and skip the write attempt
 when there are no bytes to be written. (markt)
   
+  
+Allow any 

(tomcat) branch main updated (cbefe8624e -> 1ddcd538a8)

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from cbefe8624e Fix disastrous cookie-logging patch.
 new 06ecc62163 Fix typos
 new 50d4b6fd94 SocketTimeout has no impact for acceptor unlock - remove it
 new 2bbee3883d Allow any positive value for socket.unlockTimeout rather 
than >=2s
 new ef2e8f9c06 Refactor to specify acceptor stop wait time in ms rather 
than s
 new 59c53815d0 Reduce the default wait time for the acceptor unlock
 new 1ddcd538a8 Remove deprecated code

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


Summary of changes:
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 19 ++-
 java/org/apache/tomcat/util/net/Acceptor.java | 14 +++---
 .../apache/tomcat/util/net/LocalStrings.properties|  2 ++
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  7 ++-
 java/org/apache/tomcat/util/net/SocketProperties.java | 13 -
 webapps/docs/changelog.xml| 11 +++
 webapps/docs/config/http.xml  |  7 +--
 8 files changed, 48 insertions(+), 31 deletions(-)


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



(tomcat) 04/06: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit ef2e8f9c0639a247e68c304a587a5e8b12f8bc3c
Author: Mark Thomas 
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java | 12 ++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java  |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index c3a5ee523d..4da1e460cb 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1661,7 +1661,7 @@ public abstract class AbstractEndpoint {
 public final void closeServerSocketGraceful() {
 if (bindState == BindState.BOUND_ON_START) {
 // Stop accepting new connections
-acceptor.stop(-1);
+acceptor.stopMillis(-1);
 // Release locks that may be preventing the acceptor from stopping
 releaseConnectionLatch();
 unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index b1083b292a..d8deb8cb26 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -171,12 +171,20 @@ public class Acceptor implements Runnable {
  *
  * @param waitSeconds The time to wait in seconds. Use a value less than
  *zero for no wait.
+ *
+ * @deprecated Unused. Will be remove in Tomcat 11 onwards.
  */
+@Deprecated
 public void stop(int waitSeconds) {
+stopMillis(waitSeconds * 1000);
+}
+
+
+public void stopMillis(int waitMilliseconds) {
 stopCalled = true;
-if (waitSeconds > 0) {
+if (waitMilliseconds > 0) {
 try {
-if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
 }
 } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 6aba831e9d..7e1fbd77b0 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -199,7 +199,7 @@ public class Nio2Endpoint extends 
AbstractNetworkChannelEndpoint {
@@ -440,11 +440,11 @@ public class Nio2Endpoint extends 
AbstractNetworkChannelEndpoint

(tomcat) 02/06: SocketTimeout has no impact for acceptor unlock - remove it

2024-04-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 50d4b6fd940928ca8a11420297503f563503b501
Author: Mark Thomas 
AuthorDate: Fri Apr 19 17:45:56 2024 +0100

SocketTimeout has no impact for acceptor unlock - remove it
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index f4f31085a4..1e0f3bf28b 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1285,15 +1285,12 @@ public abstract class AbstractEndpoint {
 unlockAddress = getUnlockAddress(localAddress);
 
 try (java.net.Socket s = new java.net.Socket()) {
-int stmo = 2 * 1000;
 int utmo = 2 * 1000;
-if (getSocketProperties().getSoTimeout() > stmo) {
-stmo = getSocketProperties().getSoTimeout();
-}
 if (getSocketProperties().getUnlockTimeout() > utmo) {
 utmo = getSocketProperties().getUnlockTimeout();
 }
-s.setSoTimeout(stmo);
+// Never going to read from this socket so the timeout doesn't 
matter. Use the unlock timeout.
+s.setSoTimeout(utmo);
 // Newer MacOS versions (e.g. Ventura 13.2) appear to linger 
for ~1s on close when linger is disabled.
 // That causes delays when running the unit tests. Explicitly 
enabling linger but with a timeout of
 // zero seconds seems to fix the issue.


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



[Bug 68911] Newly introduced ConfigurationSource doesn't respect environment variables

2024-04-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68911

--- Comment #8 from 7elem...@mail.bg ---
(In reply to Rainer Jung from comment #7)
> Your reproduction suggestion sounds easy, but it misses a lot of important
> precision. Since separating out CATALINA_BASE is a working recipe for many
> of us, could you please answer:
> 
> - which OS is this on? Linux? Windows?

Both Linux and Windows

> 
> - what exact Tomcat version do you use?

I try to seamlessly upgrade from 8.5 to 9/10

> 
> - how do you exactly set CATALINA_BASE?

export CATALINA_BASE=/home/user/.tomcat (conf/server.xml, conf/web.xml,
conf/context.xml, conf/localhost.jks, lib)
set CATALINA_BASE=C:\Users\user\tomcat (conf\server.xml, conf/web.xml,
conf/context.xml, conf/localhost.jks, lib)
>From server.xml you can set work, webapps, lib folders if it finds proper one
at startup

> 
> - is your new conf folder underneath the set value for CATALINA_BASE, so
> something like $CATALINA_BASE/conf?

Yes

> 
> - which other directories and files do you have underneath CATALINA_BASE$
>   - For example webapps and work?

Nothing else. From server.xml you can set work, webapps

> 
> - do you also set CATALINA_HOME to the original product directory?

Yes, but they point to the same place

> 
> - how do you exactly start Tomcat?
>   For instance using the standartup.(sh|bat) script Tomcat provides?

Yes. the standartup.(sh|bat) script Tomcat provides
> 
> - in case you do not start it as a service: in which directory is your shell
> process when you execute the start commands?

Any folder. User on the system can start it's own process and point to his
configuration folder by using CATALINA_BASE. For example

On linux:
/var/lib/tomcat for binaries
/home/user/.tomcat/conf for server.xml, certificates, global web.xml, global
context.xml
/home/user/.tomcat/workspace for webapps, work, etc. I can point to those via
server.xml using appBase and workDir

On Windows: C:\Program Files\tomcat for binaries
C:\Users\user\tomcat\conf for server.xml, certificates, global web.xml, global
context.xml
C:\Users\user\workspace for webapps, work. I can point to those via server.xml
using appBase and workDir

> 
> Thanks and regard,
> 
> Rainer

Thank you very much for the patience

Best regards

-- 
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: (tomcat) branch main updated: Fix disastrous cookie-logging patch.

2024-04-19 Thread Chuck Caldarale


> On Apr 19, 2024, at 09:18, Christopher Schultz  
> wrote:
> 
> Hopefully this patch has the intended effect. ;)


I’m not convinced this change will have any measurable performance improvement. 
The JVM C2 compiler is pretty good with escape analysis, so an unused 
StringBuilder object may not even get allocated. Also, there’s now an added 
comparison for each iteration of the cookies loop, plus the additional code for 
an object allocation. This enlarges the body of the loop, putting more pressure 
on the microcode cache in the CPU, possibly making each iteration take longer.

Are there any practical examples that show a performance benefit or GC 
reduction?

  - Chuck


> -chris
> 
> On 4/19/24 10:17, schu...@apache.org wrote:
>> This is an automated email from the ASF dual-hosted git repository.
>> schultz pushed a commit to branch main
>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>> The following commit(s) were added to refs/heads/main by this push:
>>  new cbefe8624e Fix disastrous cookie-logging patch.
>> cbefe8624e is described below
>> commit cbefe8624ee5d6255955134d08498f9926295126
>> Author: Christopher Schultz 
>> AuthorDate: Fri Apr 19 10:16:36 2024 -0400
>> Fix disastrous cookie-logging patch.
>> ---
>>  java/org/apache/catalina/valves/AbstractAccessLogValve.java | 6 --
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
>> b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
>> index 0576b83442..dd29a5ec37 100644
>> --- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
>> +++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
>> @@ -1513,17 +1513,19 @@ public abstract class AbstractAccessLogValve extends 
>> ValveBase implements Access
>>  if (cookies != null) {
>>  for (Cookie cookie : cookies) {
>>  if (cookieNameToLog.equals(cookie.getName())) {
>> +if (value == null) {
>> +value = new StringBuilder();
>> +}
>>  if (first) {
>>  first = false;
>>  } else {
>>  value.append(',');
>>  }
>> -value = new StringBuilder();
>>  value.append(cookie.getValue());
>>  }
>>  }
>>  }
>> -if (value.length() == 0) {
>> +if (value == null) {
>>  buf.append('-');
>>  } else {
>>  escapeAndAppend(value.toString(), buf);
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 


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



Re: [PR] Add support for timescales with time-taken access log token. [tomcat]

2024-04-19 Thread via GitHub


ChristopherSchultz commented on code in PR #721:
URL: https://github.com/apache/tomcat/pull/721#discussion_r1572455403


##
java/org/apache/catalina/valves/AbstractAccessLogValve.java:
##
@@ -1756,10 +1776,14 @@ protected AccessLogElement 
createAccessLogElement(String name, char pattern) {
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
 } else if ("us".equals(name)) {
-return new ElapsedTimeElement(true, false);
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MICROSECONDS);
+} else if ("ms".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
+} else if ("fs".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.SECONDS_FRACTIONAL);

Review Comment:
   Good question. I actually thought of femtoseconds and then thought "who 
actually knows about those?" and now I guess I have my answer.
   
   We could use `sf`, sure... also `s.` which is a little obscure. There is no 
reason is has to be two-letters, either. `fracsec`?



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

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

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



Re: [PR] Add support for timescales with time-taken access log token. [tomcat]

2024-04-19 Thread via GitHub


ChristopherSchultz commented on code in PR #721:
URL: https://github.com/apache/tomcat/pull/721#discussion_r1572451843


##
java/org/apache/catalina/valves/AbstractAccessLogValve.java:
##
@@ -1756,10 +1776,14 @@ protected AccessLogElement 
createAccessLogElement(String name, char pattern) {
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);

Review Comment:
   If course I did. Thanks for spotting that.



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

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

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



Re: (tomcat) branch main updated: Fix disastrous cookie-logging patch.

2024-04-19 Thread Christopher Schultz

All,

Hopefully this patch has the intended effect. ;)

-chris

On 4/19/24 10:17, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
  new cbefe8624e Fix disastrous cookie-logging patch.
cbefe8624e is described below

commit cbefe8624ee5d6255955134d08498f9926295126
Author: Christopher Schultz 
AuthorDate: Fri Apr 19 10:16:36 2024 -0400

 Fix disastrous cookie-logging patch.
---
  java/org/apache/catalina/valves/AbstractAccessLogValve.java | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 0576b83442..dd29a5ec37 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1513,17 +1513,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  if (cookies != null) {
  for (Cookie cookie : cookies) {
  if (cookieNameToLog.equals(cookie.getName())) {
+if (value == null) {
+value = new StringBuilder();
+}
  if (first) {
  first = false;
  } else {
  value.append(',');
  }
-value = new StringBuilder();
  value.append(cookie.getValue());
  }
  }
  }
-if (value.length() == 0) {
+if (value == null) {
  buf.append('-');
  } else {
  escapeAndAppend(value.toString(), buf);


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



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



[PR] Tomcat-jdbc causes problem with graalvm [tomcat]

2024-04-19 Thread via GitHub


MartinLei opened a new pull request, #722:
URL: https://github.com/apache/tomcat/pull/722

   Using the Tomcat-JDBC library inside a Spring Native project causes the 
compilation step of a GraalVM native image to crash with the given error.
   
   >   Exception in thread "main" 
org.springframework.boot.context.properties.bind.MissingParametersCompilerArgumentException:
 Constructor binding in a native image requires compilation with -parameters 
but the following classes were compiled without it:
   >   org.apache.tomcat.jdbc.pool.PoolProperties$InterceptorProperty
   
   See this little [demo project 
](https://github.com/MartinLei/bugNativeTomcatJdBC) to reproduce the problem.
   
   It seems this error could be easily fixed by adding the **-params** flag at 
the compile step, as suggested by the error.
   


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

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

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) branch main updated: Fix disastrous cookie-logging patch.

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new cbefe8624e Fix disastrous cookie-logging patch.
cbefe8624e is described below

commit cbefe8624ee5d6255955134d08498f9926295126
Author: Christopher Schultz 
AuthorDate: Fri Apr 19 10:16:36 2024 -0400

Fix disastrous cookie-logging patch.
---
 java/org/apache/catalina/valves/AbstractAccessLogValve.java | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index 0576b83442..dd29a5ec37 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1513,17 +1513,19 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
 if (cookies != null) {
 for (Cookie cookie : cookies) {
 if (cookieNameToLog.equals(cookie.getName())) {
+if (value == null) {
+value = new StringBuilder();
+}
 if (first) {
 first = false;
 } else {
 value.append(',');
 }
-value = new StringBuilder();
 value.append(cookie.getValue());
 }
 }
 }
-if (value.length() == 0) {
+if (value == null) {
 buf.append('-');
 } else {
 escapeAndAppend(value.toString(), buf);


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



Re: (tomcat) branch main updated: Don't create a StringBuilder object until we know we have at least one Cookie value to log.

2024-04-19 Thread Christopher Schultz

Mark,

On 4/18/24 11:12, Mark Thomas wrote:

On 18/04/2024 14:31, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
  new 23facd507d Don't create a StringBuilder object until we know 
we have at least one Cookie value to log.

23facd507d is described below

commit 23facd507db72d583ed89a13f20ab1cb766f0221
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 09:30:50 2024 -0400

 Don't create a StringBuilder object until we know we have at 
least one Cookie value to log.


-1. veto. Please fix/revert ASAP.

Note: This veto applies to this commit and the back-ports.

This creates multiple paths where a NPE is possible.


OMG what the heck happened to this patch? Grr. I saw this while working 
on the timestamp-style stuff and decided to separate it out into a 
separate commit and but did I get it wrong. It NPEs on /every/ path :(


Sorry for such a low-quality commit.

I'm going to try a "correct" commit on top of it and would appreciate a 
review. If it still looks like a no-go, I'll revert the whole thing.


This does not work if there are multiple cookies with the same name that 
need to be logged.

ACK

Thanks,
-chris


---
  java/org/apache/catalina/valves/AbstractAccessLogValve.java | 3 ++-
  webapps/docs/changelog.xml  | 4 
  2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java

index 5502d1c183..e13bb9e5ac 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1479,7 +1479,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  @Override
  public void addElement(CharArrayWriter buf, Date date, 
Request request, Response response, long time) {

-    StringBuilder value = new StringBuilder();
+    StringBuilder value = null;
  boolean first = true;
  Cookie[] cookies = request.getCookies();
  if (cookies != null) {
@@ -1490,6 +1490,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  } else {
  value.append(',');
  }
+    value = new StringBuilder();
  value.append(cookie.getValue());
  }
  }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8ef77e52aa..f6c6c62962 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,10 @@
  including the removal of the trimCredentials 
setting which

  is now hard-coded to false. (markt)
    
+  
+    Small performance optimization when logging cookies with no 
values.

+    (schultz)
+  
  
    
    


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



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



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



Re: (tomcat) branch main updated: Don't create a StringBuilder object until we know we have at least one Cookie value to log.

2024-04-19 Thread Christopher Schultz

Mark,

On 4/19/24 08:38, Mark Thomas wrote:
Ping. Just making sure this veto hasn't been lost in the recent flurry 
of commits.


ACK

I'll revert and re-evaluate.

Thanks,
-chris


On 18/04/2024 16:12, Mark Thomas wrote:

On 18/04/2024 14:31, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
  new 23facd507d Don't create a StringBuilder object until we 
know we have at least one Cookie value to log.

23facd507d is described below

commit 23facd507db72d583ed89a13f20ab1cb766f0221
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 09:30:50 2024 -0400

 Don't create a StringBuilder object until we know we have at 
least one Cookie value to log.


-1. veto. Please fix/revert ASAP.

Note: This veto applies to this commit and the back-ports.

This creates multiple paths where a NPE is possible.

This does not work if there are multiple cookies with the same name 
that need to be logged.


Mark



---
  java/org/apache/catalina/valves/AbstractAccessLogValve.java | 3 ++-
  webapps/docs/changelog.xml  | 4 
  2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java

index 5502d1c183..e13bb9e5ac 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1479,7 +1479,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  @Override
  public void addElement(CharArrayWriter buf, Date date, 
Request request, Response response, long time) {

-    StringBuilder value = new StringBuilder();
+    StringBuilder value = null;
  boolean first = true;
  Cookie[] cookies = request.getCookies();
  if (cookies != null) {
@@ -1490,6 +1490,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  } else {
  value.append(',');
  }
+    value = new StringBuilder();
  value.append(cookie.getValue());
  }
  }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8ef77e52aa..f6c6c62962 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,10 @@
  including the removal of the trimCredentials 
setting which

  is now hard-coded to false. (markt)
    
+  
+    Small performance optimization when logging cookies with no 
values.

+    (schultz)
+  
  
    
    


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



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



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



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



Re: [PR] Re-adding support for fractional seconds in access log [tomcat]

2024-04-19 Thread via GitHub


jose-galvez commented on PR #720:
URL: https://github.com/apache/tomcat/pull/720#issuecomment-2066644940

   I like it!! Definitely way better than my change which now seems like a bad 
hack 藍  I can close this PR in favor of yours  


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

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

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



Re: [PR] Re-adding support for fractional seconds in access log [tomcat]

2024-04-19 Thread via GitHub


jose-galvez closed pull request #720: Re-adding support for fractional seconds 
in access log
URL: https://github.com/apache/tomcat/pull/720


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

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

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



[Bug 68919] Make Tomcat return 503 on stopped web applications

2024-04-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68919

Michael Osipov  changed:

   What|Removed |Added

 CC||micha...@apache.org

-- 
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 68919] New: Make Tomcat return 503 on stopped web applications

2024-04-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68919

Bug ID: 68919
   Summary: Make Tomcat return 503 on stopped web applications
   Product: Tomcat 9
   Version: 9.0.x
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: micha...@apache.org
  Target Milestone: -

This somewhat reverts or picks up Bug 51117.

When a webapp is deliberately stopped or failed to start Tomcat should respond
with 503 since the resource is known, but Tomcat isn't able to serve it. For
me, it is clearly a difference from 404.

On occasions I have to stop applications because upstream services aren't
available and my downstream clients shall rather see 503 in their logs. I think
it is in conformance with
https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavailable.

At least the behavior should be configurable whether the admin prefers 404 or
503 on a per app basis? Maybe something in context.xml or per Host?

-- 
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: (tomcat) branch main updated: Don't create a StringBuilder object until we know we have at least one Cookie value to log.

2024-04-19 Thread Mark Thomas
Ping. Just making sure this veto hasn't been lost in the recent flurry 
of commits.


Mark


On 18/04/2024 16:12, Mark Thomas wrote:

On 18/04/2024 14:31, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
  new 23facd507d Don't create a StringBuilder object until we know 
we have at least one Cookie value to log.

23facd507d is described below

commit 23facd507db72d583ed89a13f20ab1cb766f0221
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 09:30:50 2024 -0400

 Don't create a StringBuilder object until we know we have at 
least one Cookie value to log.


-1. veto. Please fix/revert ASAP.

Note: This veto applies to this commit and the back-ports.

This creates multiple paths where a NPE is possible.

This does not work if there are multiple cookies with the same name that 
need to be logged.


Mark



---
  java/org/apache/catalina/valves/AbstractAccessLogValve.java | 3 ++-
  webapps/docs/changelog.xml  | 4 
  2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java

index 5502d1c183..e13bb9e5ac 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1479,7 +1479,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  @Override
  public void addElement(CharArrayWriter buf, Date date, 
Request request, Response response, long time) {

-    StringBuilder value = new StringBuilder();
+    StringBuilder value = null;
  boolean first = true;
  Cookie[] cookies = request.getCookies();
  if (cookies != null) {
@@ -1490,6 +1490,7 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

  } else {
  value.append(',');
  }
+    value = new StringBuilder();
  value.append(cookie.getValue());
  }
  }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8ef77e52aa..f6c6c62962 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,10 @@
  including the removal of the trimCredentials 
setting which

  is now hard-coded to false. (markt)
    
+  
+    Small performance optimization when logging cookies with no 
values.

+    (schultz)
+  
  
    
    


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



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



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



Re: (tomcat) 02/02: Re-factor ElapsedTimeElement to use a customizable Style

2024-04-19 Thread Mark Thomas

On 19/04/2024 13:31, Mark Thomas wrote:

On 19/04/2024 13:12, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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

commit d3482c35bf144cc891dfa325b2f2f50460708c23
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 10:22:16 2024 -0400

 Re-factor ElapsedTimeElement to use a customizable Style


How is this customizable?

This seems to add complexity to somewhere we probably want to keep 
things simple.


Never mind. I think you meant extensible. I can see what you are trying 
to do in the PR that adds ns etc.


Mark




Mark



---
  .../catalina/valves/AbstractAccessLogValve.java    | 52 
+-

  webapps/docs/changelog.xml |  4 ++
  2 files changed, 44 insertions(+), 12 deletions(-)

diff --git 
a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java

index e13bb9e5ac..0576b83442 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1307,8 +1307,44 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

   * write time taken to process the request - %D, %T
   */
  protected static class ElapsedTimeElement implements 
AccessLogElement {

-    private final boolean micros;
-    private final boolean millis;
+    enum Style {
+    SECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));

+    }
+    },
+    MILLISECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));

+    }
+    },
+    MICROSECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));

+    }
+    };
+
+    /**
+ * Append the time to the buffer in the appropriate format.
+ *
+ * @param buf The buffer to append to.
+ * @param time The time to log in nanoseconds.
+ */
+    public abstract void append(CharArrayWriter buf, long time);
+    }
+    private final Style style;
+
+    /**
+ * Create a new ElapsedTimeElement that will log the time in 
the specified style.

+ *
+ * @param style The elapsed-time style to use.
+ */
+    public ElapsedTimeElement(Style style) {
+    this.style = style;
+    }
  /**
   * @param micros true, write time in 
microseconds - %D
@@ -1316,20 +1352,12 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

   *   time in seconds - %T
   */
  public ElapsedTimeElement(boolean micros, boolean millis) {
-    this.micros = micros;
-    this.millis = millis;
+    this(micros ? Style.MICROSECONDS : millis ? 
Style.MILLISECONDS : Style.SECONDS);

  }
  @Override
  public void addElement(CharArrayWriter buf, Date date, 
Request request, Response response, long time) {

-    if (micros) {
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));

-    } else if (millis) {
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));

-    } else {
-    // second
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));

-    }
+    style.append(buf, time);
  }
  }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bda2e5d98c..f6eacba634 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
  dispatch is now performed rather than completing the request 
using the

  error page mechanism. (markt)
    
+  
+    Re-factor ElapsedTimeElement in AbstractAccessLogValve to use 
a customizable

+    style. (schultz)
+  
  
    
    


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



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



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

Re: [PR] Add support for timescales with time-taken access log token. [tomcat]

2024-04-19 Thread via GitHub


markt-asf commented on code in PR #721:
URL: https://github.com/apache/tomcat/pull/721#discussion_r1572301203


##
java/org/apache/catalina/valves/AbstractAccessLogValve.java:
##
@@ -1756,10 +1776,14 @@ protected AccessLogElement 
createAccessLogElement(String name, char pattern) {
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);

Review Comment:
   I think you want `NANOSECONDS` here.



##
java/org/apache/catalina/valves/AbstractAccessLogValve.java:
##
@@ -1756,10 +1776,14 @@ protected AccessLogElement 
createAccessLogElement(String name, char pattern) {
 return new DateAndTimeElement(name);
 case 'T':
 // ms for milliseconds, us for microseconds, and s for seconds
-if ("ms".equals(name)) {
-return new ElapsedTimeElement(false, true);
+if ("ns".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
 } else if ("us".equals(name)) {
-return new ElapsedTimeElement(true, false);
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MICROSECONDS);
+} else if ("ms".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.MILLISECONDS);
+} else if ("fs".equals(name)) {
+return new 
ElapsedTimeElement(ElapsedTimeElement.Style.SECONDS_FRACTIONAL);

Review Comment:
   Strictly, that is fs is femto seconds which doesn't look right. Maybe sf?



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

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

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



Re: (tomcat) 02/02: Re-factor ElapsedTimeElement to use a customizable Style

2024-04-19 Thread Christopher Schultz

Mark,

On 4/19/24 08:31, Mark Thomas wrote:

On 19/04/2024 13:12, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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

commit d3482c35bf144cc891dfa325b2f2f50460708c23
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 10:22:16 2024 -0400

 Re-factor ElapsedTimeElement to use a customizable Style


How is this customizable?

This seems to add complexity to somewhere we probably want to keep 
things simple.


It was preparation for this PR:

https://github.com/apache/tomcat/pull/721

The use of two-booleans means that we could support only 4 possible 
formats where one of them didn't make any sense (i.e. microseconds=true 
&& milliseconds == true).


-chris


---
  .../catalina/valves/AbstractAccessLogValve.java    | 52 
+-

  webapps/docs/changelog.xml |  4 ++
  2 files changed, 44 insertions(+), 12 deletions(-)

diff --git 
a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java

index e13bb9e5ac..0576b83442 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1307,8 +1307,44 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

   * write time taken to process the request - %D, %T
   */
  protected static class ElapsedTimeElement implements 
AccessLogElement {

-    private final boolean micros;
-    private final boolean millis;
+    enum Style {
+    SECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));

+    }
+    },
+    MILLISECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));

+    }
+    },
+    MICROSECONDS {
+    @Override
+    public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));

+    }
+    };
+
+    /**
+ * Append the time to the buffer in the appropriate format.
+ *
+ * @param buf The buffer to append to.
+ * @param time The time to log in nanoseconds.
+ */
+    public abstract void append(CharArrayWriter buf, long time);
+    }
+    private final Style style;
+
+    /**
+ * Create a new ElapsedTimeElement that will log the time in 
the specified style.

+ *
+ * @param style The elapsed-time style to use.
+ */
+    public ElapsedTimeElement(Style style) {
+    this.style = style;
+    }
  /**
   * @param micros true, write time in 
microseconds - %D
@@ -1316,20 +1352,12 @@ public abstract class AbstractAccessLogValve 
extends ValveBase implements Access

   *   time in seconds - %T
   */
  public ElapsedTimeElement(boolean micros, boolean millis) {
-    this.micros = micros;
-    this.millis = millis;
+    this(micros ? Style.MICROSECONDS : millis ? 
Style.MILLISECONDS : Style.SECONDS);

  }
  @Override
  public void addElement(CharArrayWriter buf, Date date, 
Request request, Response response, long time) {

-    if (micros) {
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));

-    } else if (millis) {
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));

-    } else {
-    // second
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));

-    }
+    style.append(buf, time);
  }
  }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bda2e5d98c..f6eacba634 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
  dispatch is now performed rather than completing the request 
using the

  error page mechanism. (markt)
    
+  
+    Re-factor ElapsedTimeElement in AbstractAccessLogValve to use 
a customizable

+    style. (schultz)
+  
  
    
    


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



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




Re: (tomcat) 02/02: Re-factor ElapsedTimeElement to use a customizable Style

2024-04-19 Thread Mark Thomas

On 19/04/2024 13:12, schu...@apache.org wrote:

This is an automated email from the ASF dual-hosted git repository.

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

commit d3482c35bf144cc891dfa325b2f2f50460708c23
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 10:22:16 2024 -0400

 Re-factor ElapsedTimeElement to use a customizable Style


How is this customizable?

This seems to add complexity to somewhere we probably want to keep 
things simple.


Mark



---
  .../catalina/valves/AbstractAccessLogValve.java| 52 +-
  webapps/docs/changelog.xml |  4 ++
  2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index e13bb9e5ac..0576b83442 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1307,8 +1307,44 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
   * write time taken to process the request - %D, %T
   */
  protected static class ElapsedTimeElement implements AccessLogElement {
-private final boolean micros;
-private final boolean millis;
+enum Style {
+SECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
+}
+},
+MILLISECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
+}
+},
+MICROSECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
+}
+};
+
+/**
+ * Append the time to the buffer in the appropriate format.
+ *
+ * @param buf The buffer to append to.
+ * @param time The time to log in nanoseconds.
+ */
+public abstract void append(CharArrayWriter buf, long time);
+}
+private final Style style;
+
+/**
+ * Create a new ElapsedTimeElement that will log the time in the 
specified style.
+ *
+ * @param style The elapsed-time style to use.
+ */
+public ElapsedTimeElement(Style style) {
+this.style = style;
+}
  
  /**

   * @param micros true, write time in microseconds - %D
@@ -1316,20 +1352,12 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
   *   time in seconds - %T
   */
  public ElapsedTimeElement(boolean micros, boolean millis) {
-this.micros = micros;
-this.millis = millis;
+this(micros ? Style.MICROSECONDS : millis ? Style.MILLISECONDS : 
Style.SECONDS);
  }
  
  @Override

  public void addElement(CharArrayWriter buf, Date date, Request 
request, Response response, long time) {
-if (micros) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
-} else if (millis) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
-} else {
-// second
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
-}
+style.append(buf, time);
  }
  }
  
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml

index bda2e5d98c..f6eacba634 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
  dispatch is now performed rather than completing the request using the
  error page mechanism. (markt)

+  
+Re-factor ElapsedTimeElement in AbstractAccessLogValve to use a 
customizable
+style. (schultz)
+  
  




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



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



Re: [PR] Re-adding support for fractional seconds in access log [tomcat]

2024-04-19 Thread via GitHub


ChristopherSchultz commented on PR #720:
URL: https://github.com/apache/tomcat/pull/720#issuecomment-2066468644

   Please have a look at a different PR which builds on some refactoring I just 
pushed: https://github.com/apache/tomcat/pull/721
   
   I think I like mine better.


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

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

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) 02/02: Re-factor ElapsedTimeElement to use a customizable Style

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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

commit 1448eccfd86ef6385e0af629c138ab28405ed6c2
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 10:22:16 2024 -0400

Re-factor ElapsedTimeElement to use a customizable Style
---
 .../catalina/valves/AbstractAccessLogValve.java| 52 +-
 webapps/docs/changelog.xml |  4 ++
 2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index df942110ab..03acb492fa 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1309,8 +1309,44 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  * write time taken to process the request - %D, %T
  */
 protected static class ElapsedTimeElement implements AccessLogElement {
-private final boolean micros;
-private final boolean millis;
+enum Style {
+SECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
+}
+},
+MILLISECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
+}
+},
+MICROSECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
+}
+};
+
+/**
+ * Append the time to the buffer in the appropriate format.
+ *
+ * @param buf The buffer to append to.
+ * @param time The time to log in nanoseconds.
+ */
+public abstract void append(CharArrayWriter buf, long time);
+}
+private final Style style;
+
+/**
+ * Create a new ElapsedTimeElement that will log the time in the 
specified style.
+ *
+ * @param style The elapsed-time style to use.
+ */
+public ElapsedTimeElement(Style style) {
+this.style = style;
+}
 
 /**
  * @param micros true, write time in microseconds - %D
@@ -1318,20 +1354,12 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  *   time in seconds - %T
  */
 public ElapsedTimeElement(boolean micros, boolean millis) {
-this.micros = micros;
-this.millis = millis;
+this(micros ? Style.MICROSECONDS : millis ? Style.MILLISECONDS : 
Style.SECONDS);
 }
 
 @Override
 public void addElement(CharArrayWriter buf, Date date, Request 
request, Response response, long time) {
-if (micros) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
-} else if (millis) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
-} else {
-// second
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
-}
+style.append(buf, time);
 }
 }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e724ed92a6..3a295c0937 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,10 @@
 dispatch is now performed rather than completing the request using the
 error page mechanism. (markt)
   
+  
+Re-factor ElapsedTimeElement in AbstractAccessLogValve to use a 
customizable
+style. (schultz)
+  
 
   
   


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



(tomcat) 01/02: Clarify that time-taken is now in seconds and not fractional-seconds.

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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

commit 89433ad101747669eb34d3e30f26caf4e8d59232
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 09:38:23 2024 -0400

Clarify that time-taken is now in seconds and not fractional-seconds.
---
 webapps/docs/config/valve.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml
index ceb4a84218..800da1b323 100644
--- a/webapps/docs/config/valve.xml
+++ b/webapps/docs/config/valve.xml
@@ -465,7 +465,7 @@
 s-ip - Local IP address
 sc-status - HTTP status code of the response
 time - Time the request was served in HH:mm:ss format for 
GMT
-time-taken - Time (in seconds as floating point) taken to serve 
the request
+time-taken - Time (in seconds) taken to serve the request
 x-threadname - Current request thread name (can compare later 
with stacktraces)
 
 


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



(tomcat) branch 10.1.x updated (1ffc62afa7 -> 1448eccfd8)

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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


from 1ffc62afa7 Add openssl ffm testing
 new 89433ad101 Clarify that time-taken is now in seconds and not 
fractional-seconds.
 new 1448eccfd8 Re-factor ElapsedTimeElement to use a customizable Style

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


Summary of changes:
 .../catalina/valves/AbstractAccessLogValve.java| 52 +-
 webapps/docs/changelog.xml |  4 ++
 webapps/docs/config/valve.xml  |  2 +-
 3 files changed, 45 insertions(+), 13 deletions(-)


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



(tomcat) 01/02: Clarify that time-taken is now in seconds and not fractional-seconds.

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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

commit cbc2b3500fc4051d6a94530c50d451cf0c79e54d
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 09:38:23 2024 -0400

Clarify that time-taken is now in seconds and not fractional-seconds.
---
 webapps/docs/config/valve.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml
index ce63a66764..9e5fb8d20d 100644
--- a/webapps/docs/config/valve.xml
+++ b/webapps/docs/config/valve.xml
@@ -465,7 +465,7 @@
 s-ip - Local IP address
 sc-status - HTTP status code of the response
 time - Time the request was served in HH:mm:ss format for 
GMT
-time-taken - Time (in seconds as floating point) taken to serve 
the request
+time-taken - Time (in seconds) taken to serve the request
 x-threadname - Current request thread name (can compare later 
with stacktraces)
 
 


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



(tomcat) 02/02: Re-factor ElapsedTimeElement to use a customizable Style

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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

commit d3482c35bf144cc891dfa325b2f2f50460708c23
Author: Christopher Schultz 
AuthorDate: Thu Apr 18 10:22:16 2024 -0400

Re-factor ElapsedTimeElement to use a customizable Style
---
 .../catalina/valves/AbstractAccessLogValve.java| 52 +-
 webapps/docs/changelog.xml |  4 ++
 2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java 
b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
index e13bb9e5ac..0576b83442 100644
--- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java
+++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java
@@ -1307,8 +1307,44 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  * write time taken to process the request - %D, %T
  */
 protected static class ElapsedTimeElement implements AccessLogElement {
-private final boolean micros;
-private final boolean millis;
+enum Style {
+SECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
+}
+},
+MILLISECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
+}
+},
+MICROSECONDS {
+@Override
+public void append(CharArrayWriter buf, long time) {
+
buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
+}
+};
+
+/**
+ * Append the time to the buffer in the appropriate format.
+ *
+ * @param buf The buffer to append to.
+ * @param time The time to log in nanoseconds.
+ */
+public abstract void append(CharArrayWriter buf, long time);
+}
+private final Style style;
+
+/**
+ * Create a new ElapsedTimeElement that will log the time in the 
specified style.
+ *
+ * @param style The elapsed-time style to use.
+ */
+public ElapsedTimeElement(Style style) {
+this.style = style;
+}
 
 /**
  * @param micros true, write time in microseconds - %D
@@ -1316,20 +1352,12 @@ public abstract class AbstractAccessLogValve extends 
ValveBase implements Access
  *   time in seconds - %T
  */
 public ElapsedTimeElement(boolean micros, boolean millis) {
-this.micros = micros;
-this.millis = millis;
+this(micros ? Style.MICROSECONDS : millis ? Style.MILLISECONDS : 
Style.SECONDS);
 }
 
 @Override
 public void addElement(CharArrayWriter buf, Date date, Request 
request, Response response, long time) {
-if (micros) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMicros(time)));
-} else if (millis) {
-buf.append(Long.toString(TimeUnit.NANOSECONDS.toMillis(time)));
-} else {
-// second
-
buf.append(Long.toString(TimeUnit.NANOSECONDS.toSeconds(time)));
-}
+style.append(buf, time);
 }
 }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bda2e5d98c..f6eacba634 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
 dispatch is now performed rather than completing the request using the
 error page mechanism. (markt)
   
+  
+Re-factor ElapsedTimeElement in AbstractAccessLogValve to use a 
customizable
+style. (schultz)
+  
 
   
   


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



(tomcat) branch main updated (899e06a7ba -> d3482c35bf)

2024-04-19 Thread schultz
This is an automated email from the ASF dual-hosted git repository.

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


from 899e06a7ba Merge branch 'main' of https://github.com/apache/tomcat
 new cbc2b3500f Clarify that time-taken is now in seconds and not 
fractional-seconds.
 new d3482c35bf Re-factor ElapsedTimeElement to use a customizable Style

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


Summary of changes:
 .../catalina/valves/AbstractAccessLogValve.java| 52 +-
 webapps/docs/changelog.xml |  4 ++
 webapps/docs/config/valve.xml  |  2 +-
 3 files changed, 45 insertions(+), 13 deletions(-)


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



[Bug 68911] Newly introduced ConfigurationSource doesn't respect environment variables

2024-04-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68911

--- Comment #7 from Rainer Jung  ---
Your reproduction suggestion sounds easy, but it misses a lot of important
precision. Since separating out CATALINA_BASE is a working recipe for many of
us, could you please answer:

- which OS is this on? Linux? Windows?

- what exact Tomcat version do you use?

- how do you exactly set CATALINA_BASE?

- is your new conf folder underneath the set value for CATALINA_BASE, so
something like $CATALINA_BASE/conf?

- which other directories and files do you have underneath CATALINA_BASE$
  - For example webapps and work?

- do you also set CATALINA_HOME to the original product directory?

- how do you exactly start Tomcat?
  For instance using the standartup.(sh|bat) script Tomcat provides?

- in case you do not start it as a service: in which directory is your shell
process when you execute the start commands?

Thanks and regard,

Rainer

-- 
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 68911] Newly introduced ConfigurationSource doesn't respect environment variables

2024-04-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68911

7elem...@mail.bg changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|INVALID |---

--- Comment #6 from 7elem...@mail.bg ---
I think I can't explain it good, but I'll try
Install tomcat 8, remove conf folder, set CATALINA_BASE outside of tomcat 8
folder with valid (even default configuration). Start tomcat. Check the result.
Do the same with tomcat 9 and you'll understand what I mean.
In this case "If you want to override the default, then call (static)
ConfigFileLoader.setSource with whatever you want", I don't want to call
anything. just to move configuration in different location and set
CATALINA_BASE with no coding whatsoever.

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