You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2026/05/27 16:53:54 UTC
(tomcat) branch main updated: Restore short-circuit behaviour where required.
This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 7b8ac34e50 Restore short-circuit behaviour where required.
7b8ac34e50 is described below
commit 7b8ac34e50742b147ff98f38c4c0ec8947a45dbe
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed May 27 17:53:24 2026 +0100
Restore short-circuit behaviour where required.
---
java/org/apache/catalina/tribes/transport/PooledSender.java | 3 ++-
java/org/apache/tomcat/util/net/NioEndpoint.java | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/tribes/transport/PooledSender.java b/java/org/apache/catalina/tribes/transport/PooledSender.java
index 6a3a832f1f..1f25b99083 100644
--- a/java/org/apache/catalina/tribes/transport/PooledSender.java
+++ b/java/org/apache/catalina/tribes/transport/PooledSender.java
@@ -196,7 +196,8 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
DataSender[] list = notinuse.toArray(new DataSender[0]);
boolean result = false;
for (DataSender dataSender : list) {
- result = result || dataSender.keepalive();
+ // Do not short-circuit. dataSender.keepalive() does real, required work for all senders.
+ result = result | dataSender.keepalive();
}
return result;
}
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 0c55f89af1..34cb4d2a69 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -925,7 +925,8 @@ public class NioEndpoint extends AbstractNetworkChannelEndpoint<NioChannel,Socke
}
// Either we timed out or we woke up, process events first
if (keyCount == 0) {
- hasEvents = (hasEvents || events());
+ // Non-shorrt-circuit OR since events() always needs to run here.
+ hasEvents = (hasEvents | events());
}
} catch (Throwable x) {
ExceptionUtils.handleThrowable(x);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Restore short-circuit behaviour where required.
Posted by Mark Thomas <ma...@apache.org>.
On 27/05/2026 20:31, Rémy Maucherat wrote:
> On Wed, May 27, 2026 at 6:54 PM <ma...@apache.org> wrote:
>>
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> markt-asf 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 7b8ac34e50 Restore short-circuit behaviour where required.
>> 7b8ac34e50 is described below
>>
>> commit 7b8ac34e50742b147ff98f38c4c0ec8947a45dbe
>> Author: Mark Thomas <ma...@apache.org>
>> AuthorDate: Wed May 27 17:53:24 2026 +0100
>>
>> Restore short-circuit behaviour where required.
<snip/>
> Good thing you caught this one. I see the trick was added 20 years
> ago, and I never really paid attention to it. This does not seem to be
> something that my model understands very well, it's likely not used
> too much around.
> Shouldn't we rewrite it as "hasEvents = events() ? : true : hasEvents"
> or something like that ?
Possibly. I wasn't sure if re-writing it would be clearer or as
performant so I went with the option of adding a comment.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Restore short-circuit behaviour where required.
Posted by Rémy Maucherat <re...@apache.org>.
On Wed, May 27, 2026 at 6:54 PM <ma...@apache.org> wrote:
>
> This is an automated email from the ASF dual-hosted git repository.
>
> markt-asf 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 7b8ac34e50 Restore short-circuit behaviour where required.
> 7b8ac34e50 is described below
>
> commit 7b8ac34e50742b147ff98f38c4c0ec8947a45dbe
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Wed May 27 17:53:24 2026 +0100
>
> Restore short-circuit behaviour where required.
> ---
> java/org/apache/catalina/tribes/transport/PooledSender.java | 3 ++-
> java/org/apache/tomcat/util/net/NioEndpoint.java | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/java/org/apache/catalina/tribes/transport/PooledSender.java b/java/org/apache/catalina/tribes/transport/PooledSender.java
> index 6a3a832f1f..1f25b99083 100644
> --- a/java/org/apache/catalina/tribes/transport/PooledSender.java
> +++ b/java/org/apache/catalina/tribes/transport/PooledSender.java
> @@ -196,7 +196,8 @@ public abstract class PooledSender extends AbstractSender implements MultiPointS
> DataSender[] list = notinuse.toArray(new DataSender[0]);
> boolean result = false;
> for (DataSender dataSender : list) {
> - result = result || dataSender.keepalive();
> + // Do not short-circuit. dataSender.keepalive() does real, required work for all senders.
> + result = result | dataSender.keepalive();
> }
> return result;
> }
> diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
> index 0c55f89af1..34cb4d2a69 100644
> --- a/java/org/apache/tomcat/util/net/NioEndpoint.java
> +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
> @@ -925,7 +925,8 @@ public class NioEndpoint extends AbstractNetworkChannelEndpoint<NioChannel,Socke
> }
> // Either we timed out or we woke up, process events first
> if (keyCount == 0) {
> - hasEvents = (hasEvents || events());
> + // Non-shorrt-circuit OR since events() always needs to run here.
> + hasEvents = (hasEvents | events());
> }
> } catch (Throwable x) {
> ExceptionUtils.handleThrowable(x);
Good thing you caught this one. I see the trick was added 20 years
ago, and I never really paid attention to it. This does not seem to be
something that my model understands very well, it's likely not used
too much around.
Shouldn't we rewrite it as "hasEvents = events() ? : true : hasEvents"
or something like that ?
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org