Hi Chris, On Thu, Aug 27, 2020 at 8:51 PM Christopher Schultz < ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Martin, > > On 8/27/20 07:55, mgrigo...@apache.org wrote: > > This is an automated email from the ASF dual-hosted git > > repository. > > > > mgrigorov pushed a commit to branch master in repository > > https://gitbox.apache.org/repos/asf/tomcat.git > > > > > > The following commit(s) were added to refs/heads/master by this > > push: new 2cef8f1 Change forcedRemainingCapacity from Integer to > > int 2cef8f1 is described below > > > > commit 2cef8f18dee7b7bca3d03b3301fbe8e733e728fa Author: Martin > > Tzvetanov Grigorov <mgrigo...@apache.org> AuthorDate: Tue Aug 25 > > 14:36:23 2020 +0300 > > > > Change forcedRemainingCapacity from Integer to int > > > > No need to create object (or use Integer cache) and cast it to > > primitive int. 'forcedRemainingCapacity' can do its job with a > > primitive int, since Queue's capacity cannot be negative value --- > > java/org/apache/tomcat/util/threads/TaskQueue.java | 15 > > ++++++++++----- > > .../apache/tomcat/util/threads/ThreadPoolExecutor.java | 4 > > ++-- 2 files changed, 12 insertions(+), 7 deletions(-) > > > > diff --git a/java/org/apache/tomcat/util/threads/TaskQueue.java > > b/java/org/apache/tomcat/util/threads/TaskQueue.java index > > 87c93a9..35f1d89 100644 --- > > a/java/org/apache/tomcat/util/threads/TaskQueue.java +++ > > b/java/org/apache/tomcat/util/threads/TaskQueue.java @@ -35,12 > > +35,13 @@ public class TaskQueue extends > > LinkedBlockingQueue<Runnable> { private static final long > > serialVersionUID = 1L; protected static final StringManager sm = > > StringManager .getManager("org.apache.tomcat.util.threads.res"); + > > private static final int DEFAULT_FORCED_REMAINING_CAPACITY = -1; > > > > private transient volatile ThreadPoolExecutor parent = null; > > > > // No need to be volatile. This is written and read in a single > > thread - // (when stopping a context and firing the listeners) > > - private Integer forcedRemainingCapacity = null; + // (when > > stopping a context and firing the listeners) + private int > > forcedRemainingCapacity = -1; > > > > public TaskQueue() { super(); @@ -109,18 +110,22 @@ public class > > TaskQueue extends LinkedBlockingQueue<Runnable> { > > > > @Override public int remainingCapacity() { - if > > (forcedRemainingCapacity != null) { + if > > (forcedRemainingCapacity > DEFAULT_FORCED_REMAINING_CAPACITY) { // > > ThreadPoolExecutor.setCorePoolSize checks that // > > remainingCapacity==0 to allow to interrupt idle threads // I don't > > see why, but this hack allows to conform to this // "requirement" - > > return forcedRemainingCapacity.intValue(); + return > > forcedRemainingCapacity; } return super.remainingCapacity(); } > > > > - public void setForcedRemainingCapacity(Integer > > forcedRemainingCapacity) { + public void > > setForcedRemainingCapacity(int forcedRemainingCapacity) { > > this.forcedRemainingCapacity = forcedRemainingCapacity; } > > Technically, this could cause a problem for anyone who has binaries > built against the current code. My guess is that it's very unlikely > for anyone to be using this code directly so it's not really a big deal. > Mark had the same comment in the PR: https://github.com/apache/tomcat/pull/344#discussion_r476517292 I also think this API is too low level for anyone, even for Spring Boot people. > > But in general, it would be better to add a new set(Integer) method > which calls the old one and deprecate the old one to be as consistent > as possible for a point-release. > > - -chris > -----BEGIN PGP SIGNATURE----- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl9H8m4ACgkQHPApP6U8 > pFhVwQ/+MyrOmzl8+ragnuyamOlDkGSzhULnJpAnF43OScVBkCfjIbfO3S6ZxZSA > N/uzXg4c2/zXO/qN1BMCRRHi8/bbb02y54h4jT8h/2OyIdbmlFJhOWAGPpkA7A8D > GwgSpG5YbEtnpEg0nodtrbWzF1VqKw1x1Wa65tx2wFeSJCVVTlECGlQc1w3sewuV > o3rpLuupamg/3gOzHlPHaBNYOFY8IEeXtTGmdpTeKmpsh2tbkNvsctcH5IiPvaox > 8M1mz3IJpK0xb/epBADf7N+hNe+4dT7r+jsDcMyuvRD5CIsLvuKDa2Az8MgamNLQ > Jd4J1LpxY8PmWsF3EV51DIJmyijxeHEvPu9YXZQ+eR7k4vxFn7CLdfDe3p0SdhKO > z2m3Sr3BW23tKJBBRQmHLgT7N3ZlnVdoMmQ9jy+vzbb+QWYEQGO3Oc8P1tZbKEjK > CBKOYmfkBlfB6vcsX/n8pC4gFU6R/V2qKhYG6KiHGjviEoRy0gWLi+5OpD9y+dYS > u7FjQcB1NrT/kVghOSAkUcvKaIXtB/dM1Se2t/77DnVb7YrjDk97/1Jjbk7rrS6T > myaXIzsZMgI2d26wtBQSTr+AyyFvNw2h/LnooAc4bIlDJiFju6nSoVqcBPHHZ1mt > FaIwTzmRSGsSu2EX+S0HEOhHI/kHl5gCP4OVsvZDfBMZN3tKTog= > =GjCI > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > >