JDK 20 Rampdown Phase 2 & JMX Heads-up

2023-01-24 Thread David Delabassee

Hi,

First off, on behalf of Oracle’s Java Team, I’d like to wish you a happy 
and prosperous new year!


In 2023, two Java releases will be made available: JDK 20 (March) &  JDK 
21 (September).


JDK 20 [1] has entered Rampdown Phase Two (RDP2) [2], its initial 
Release Candidate is planned for February 9. Given that and to be better 
prepared for the future, it makes sense to begin testing your project(s) 
using JDK 21 early-access (EA) builds. Your feedback allows us to 
evaluate and address issues you find while testing EA builds.


[1] https://jdk.java.net/20/
[2] https://mail.openjdk.org/pipermail/jdk-dev/2023-January/007308.html
[3] https://jdk.java.net/21/


## Heads-up - JDK 21: JMX Subject Delegation & Fine-grained Security 
Deprecation


JMX has some features that rely on Security Manager APIs which are 
deprecated for removal (see JEP 411 [4]). These features are "Subject 
Delegation" and "Fine-grained Security", which both seem to be generally 
unused, and would require significant investment to implement without 
touching the deprecated APIs. As a consequence, "Subject Delegation" is 
being proposed for deprecation in JDK 21 [5].


Fine-grained Security is also being considered for deprecation at the 
same time. This feature [6] has allowed configuration of a security 
policy to restrict or permit access to specific MBean actions. It is 
expected that this feature is generally unused, possibly because there 
is simply no demand for such detailed control, and that it is too 
complex to create and maintain the policies.


[4] https://openjdk.org/jeps/411
[5] https://bugs.openjdk.org/browse/JDK-8298966
[6] 
https://docs.oracle.com/en/java/javase/19/jmx/fine-grained-security-example.html



## JDK 20 Early-Access builds

The latest early-access builds of JDK 20 (builds 32) are available [7], 
and are provided under the GNU General Public License v2, with the 
Classpath Exception. The Release Notes are available here [8].


[7] https://openjdk.org/projects/jdk/20/
[8] https://jdk.java.net/20/release-notes

### JEPs integrated into JDK 20:

- JEP 429: Scoped Values (Incubator)
- JEP 432: Record Patterns (2nd Preview)
- JEP 433: Pattern Matching for switch (4th Preview)
- JEP 434: Foreign Function & Memory API (2nd Preview)
- JEP 436: Virtual Threads (2nd Preview)
- JEP 437: Structured Concurrency (2nd Incubator)

### Changes in recent JDK 20 builds that may be of interest:

- JDK-8298525: javadoc crashes with "UnsupportedOperationException: Not 
yet implemented" in SeeTaglet.inherit [Reported by Apache Ant]

- JDK-8298893: Rename option UsePolyIntrinsics to UsePoly1305Intrinsics
- JDK-8287411: Enhance DTLS Performance
- JDK-8293554: Enhanced DH Key Exchanges


## JDK 21 Early-Access builds

The latest early-access builds of JDK 21 (builds 6) are available [9], 
and are provided under the GNU General Public License v2, with the 
Classpath Exception. The related EA API Javadoc is also available [10].


[9] https://jdk.java.net/21/
[10] https://download.java.net/java/early_access/jdk21/docs/api/

### Changes in recent JDK 21 builds that may be of interest:

- JDK-8297295: Remove ThreadGroup.allowThreadSuspension
- JDK-8287411: Enhance DTLS performance
- JDK-8233269: Improve handling of JAVA_ARGS
- JDK-8297933: Compiler should only use verified interface types for 
optimization

- JDK-8298381: Improve handling of session tickets for multiple SSLContexts
- JDK-8299501: Usage of constructors of primitive wrapper classes should 
be avoided in java.util API docs
- JDK-8299475: Enhance SocketException by cause where it is missing in 
net and nio area
- JDK-8299544: Improve performance of CRC32C intrinsics (non-AVX-512) 
for small inputs

- JDK-8299576: Reimplement java.io.Bits using VarHandle access
- JDK-8278326: Socket close is not thread safe and other cleanup
- JDK-8299673: Simplify object pinning interactions with string 
deduplication



## JavaFX 20 & 21 Early-Access Builds

These are early-access builds of the JavaFX Runtime, built from 
openjdk/jfx [11]. Those EA builds are intended to allow JavaFX 
application developers to build and test their applications with JavaFX 
20 on JDK 20. The latest EA builds (JavaFX 20 EA b16 2023/1/14) are now 
available [12] and are provided under the GNU General Public License, 
version 2, with the Classpath Exception. Please note that initial JavaFX 
21 early-access builds (JavaFX 21 b1 2023/1/19) are now available [13] 
as well.

Feedback should be reported to the openjfx-dev mailing list [14].

[11] https://github.com/openjdk/jfx
[12] https://jdk.java.net/javafx20/
[13] https://jdk.java.net/javafx21/
[14] http://mail.openjdk.org/mailman/listinfo/openjfx-dev


## Topics of Interest:

- On Markdown in (Java) documentation comments
https://mail.openjdk.org/pipermail/javadoc-dev/2023-January/005563.html

- Lifetimes in the Foreign Function & Memory API
https://cr.openjdk.java.net/~mcimadamore/panama/why_lifetimes.html

- Java's Plans for 2023 - Inside Java 

[Bug 66441] Static field import failed on Expression Language lookup

2023-01-24 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66441

--- Comment #1 from Isaac Rivera Rivas  ---
Here are a few clarifications for this issue,

1) This is for EE10 specifically, as we've tried to update our Open Liberty
Pages Implementation to support static imports into the Expression Language
environment. Before EE10, only JSP expressions could be used for this type of
imports.

2) This scenario occurs with a mix up between Tomcat's EL API/Impl mixed with
Jakarta Pages' 3.1 API.

3) Perhaps the Jakarta EE Pages API is more at fault and should be updated to
look at static variables (via importHandler.resolveStatic), just as Tomcat
ImportELResolver does. 

@Mark Thomas think you would know more here, any help would be appreciated!
Thank you!

-- 
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 66441] New: Static field import failed on Expression Language lookup

2023-01-24 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66441

Bug ID: 66441
   Summary: Static field import failed on Expression Language
lookup
   Product: Tomcat 10
   Version: 10.1.5
  Hardware: PC
OS: Mac OS X 10.1
Status: NEW
  Severity: normal
  Priority: P2
 Component: Jasper
  Assignee: dev@tomcat.apache.org
  Reporter: isaacriv...@gmail.com
  Target Milestone: --

Hello! Working with JSP pages and static imports using Tomcat's EL Jasper
implementation, I found that importing a static field with EL lookup did not
resolve to the correct value. Tried the following jsp

<%@ page import = "static myapp.Example.STATIC_VAR, static
myapp.Example.STATIC_METHOD" %>

   
  Import Static
   

   
  EL expressions: 
  ${STATIC_VAR}
  ${STATIC_METHOD()}

  
  

  JSP expressions: 
  <%=STATIC_VAR%>
  <%=STATIC_METHOD()%>
   



The JSP expressions resolve as expected but of the EL expressions, only
STATIC_METHOD() works. After some investigation we narrowed down that the
problem may potentially be here
https://github.com/apache/tomcat/blob/10.1.x/java/org/apache/el/parser/AstIdentifier.java#L101-L103
where the variable is resolved by the NotFoundELResolver and the import block
to resolveStatic is not reached here
https://github.com/apache/tomcat/blob/10.1.x/java/org/apache/el/parser/AstIdentifier.java#L105-L110.
 


We are using the API from JakartaEE and not the API from Tomcat for Pages. If
we change to Tomcat's API then it does behave as expected. This is because the
ImportELResolver from Tomcat does a static lookup in its resolver here
https://github.com/apache/tomcat/blob/10.1.x/java/jakarta/servlet/jsp/el/ImportELResolver.java#L85-L92
whereas the Jakarta API does not cover it here
https://github.com/jakartaee/pages/blob/master/api/src/main/java/jakarta/servlet/jsp/el/ImportELResolver.java#L63-L71.
Not sure if this should be fixed in the implementation of Tomcat or if it's
something that should be address in the Jakarta Pages API. Any help is
appreciated, thanks in advance!!

-- 
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] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 Thread Romain Manni-Bucau
Le mar. 24 janv. 2023 à 14:48, Rémy Maucherat  a écrit :

> On Tue, Jan 24, 2023 at 2:37 PM Romain Manni-Bucau
>  wrote:
> >
> > here is the idea https://github.com/apache/tomcat/pull/576
>
> People care about stats these days and the performance benefit of
> disabling this is simply not going to be there.
>

Depends, I'd say a few will take these data from there, others will take
just grab them from other kind of instrumentation so having it on by
default is just an useless overhead and if AtomicInteger -> LongAdder perf
is significant then disabling it is close in terms of perf but also mem
(long adder perf gain is at the cost of the mem). Concretely most embedded
cases + graalvm cases generally don't care about these ones and I think
they represent quite a lot of users so even if I agree with your statement
it does not discard the PR IMHO.


>
> Rémy
>
> >
> > Romain Manni-Bucau
> > @rmannibucau  |  Blog
> >  | Old Blog
> >  | Github <
> https://github.com/rmannibucau> |
> > LinkedIn  | Book
> > <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >
> >
> > Le mar. 24 janv. 2023 à 14:24, Mark Thomas  a écrit :
> >
> > > Patches welcome if that is an itch someone wants to scratch.
> > >
> > > Mark
> > >
> > >
> > > On 24/01/2023 13:22, Romain Manni-Bucau wrote:
> > > > If you care about the (perf) diff, shouldnt tomcat have a config to
> be
> > > able
> > > > to disable stats overhead at all (using a Runnable or Counter
> {incr(),
> > > > get()} as abstraction is sufficient) when it is not used (most of the
> > > time
> > > > in dev+prod - ie not sizing/tuning phases)?
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau  |  Blog
> > > >  | Old Blog
> > > >  | Github <
> > > https://github.com/rmannibucau> |
> > > > LinkedIn  | Book
> > > > <
> > >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > > >
> > > >
> > > >
> > > > Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat  a
> écrit
> > > :
> > > >
> > > >> On Tue, Jan 24, 2023 at 1:26 PM  wrote:
> > > >>>
> > > >>> 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
> > > >>> Author: Mark Thomas 
> > > >>> AuthorDate: Tue Jan 24 12:22:01 2023 +
> > > >>>
> > > >>>  LongAdder is a better choice for statistics collection
> > > >>
> > > >> Never heard of that before, but I see it's already there in Java 8.
> > > >>
> > > >> Rémy
> > > >>
> > > >>> ---
> > > >>>   java/org/apache/catalina/webresources/Cache.java | 17
> > > +
> > > >>>   1 file changed, 9 insertions(+), 8 deletions(-)
> > > >>>
> > > >>> diff --git a/java/org/apache/catalina/webresources/Cache.java
> > > >> b/java/org/apache/catalina/webresources/Cache.java
> > > >>> index 949117f521..4893a289cb 100644
> > > >>> --- a/java/org/apache/catalina/webresources/Cache.java
> > > >>> +++ b/java/org/apache/catalina/webresources/Cache.java
> > > >>> @@ -22,6 +22,7 @@ import java.util.TreeSet;
> > > >>>   import java.util.concurrent.ConcurrentHashMap;
> > > >>>   import java.util.concurrent.ConcurrentMap;
> > > >>>   import java.util.concurrent.atomic.AtomicLong;
> > > >>> +import java.util.concurrent.atomic.LongAdder;
> > > >>>
> > > >>>   import org.apache.catalina.WebResource;
> > > >>>   import org.apache.catalina.WebResourceRoot.CacheStrategy;
> > > >>> @@ -48,8 +49,8 @@ public class Cache {
> > > >>>   private int objectMaxSize = (int) maxSize /
> > > OBJECT_MAX_SIZE_FACTOR;
> > > >>>   private CacheStrategy cacheStrategy;
> > > >>>
> > > >>> -private AtomicLong lookupCount = new AtomicLong(0);
> > > >>> -private AtomicLong hitCount = new AtomicLong(0);
> > > >>> +private LongAdder lookupCount = new LongAdder();
> > > >>> +private LongAdder hitCount = new LongAdder();
> > > >>>
> > > >>>   private final ConcurrentMap
> > > resourceCache =
> > > >> new ConcurrentHashMap<>();
> > > >>>
> > > >>> @@ -70,7 +71,7 @@ public class Cache {
> > > >>>   }
> > > >>>   }
> > > >>>
> > > >>> -lookupCount.incrementAndGet();
> > > >>> +lookupCount.increment();
> > > >>>
> > > >>>   CachedResource cacheEntry = resourceCache.get(path);
> > > >>>
> > > >>> @@ -138,14 +139,14 @@ public class Cache {
> > > >>>
>  cacheEntry.validateResource(useClassLoaderResources);
> > > >>>   }
> > > >>>   } else {
> > > >>> -hitCount.incrementAndGet();
> > > >>> +hitCount.increment();
> > > >>>   }
> > > >>>
> > > >>>   

[Bug 66392] AccessLogValve's file encoding does not correspond to the documentation

2023-01-24 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66392

Konstantin Kolinko  changed:

   What|Removed |Added

Summary|AccessLogValue's file   |AccessLogValve's file
   |encoding does not   |encoding does not
   |correspond to the   |correspond to the
   |documentation   |documentation

-- 
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] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 Thread Rémy Maucherat
On Tue, Jan 24, 2023 at 2:37 PM Romain Manni-Bucau
 wrote:
>
> here is the idea https://github.com/apache/tomcat/pull/576

People care about stats these days and the performance benefit of
disabling this is simply not going to be there.

Rémy

>
> Romain Manni-Bucau
> @rmannibucau  |  Blog
>  | Old Blog
>  | Github  |
> LinkedIn  | Book
> 
>
>
> Le mar. 24 janv. 2023 à 14:24, Mark Thomas  a écrit :
>
> > Patches welcome if that is an itch someone wants to scratch.
> >
> > Mark
> >
> >
> > On 24/01/2023 13:22, Romain Manni-Bucau wrote:
> > > If you care about the (perf) diff, shouldnt tomcat have a config to be
> > able
> > > to disable stats overhead at all (using a Runnable or Counter {incr(),
> > > get()} as abstraction is sufficient) when it is not used (most of the
> > time
> > > in dev+prod - ie not sizing/tuning phases)?
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau  |  Blog
> > >  | Old Blog
> > >  | Github <
> > https://github.com/rmannibucau> |
> > > LinkedIn  | Book
> > > <
> > https://www.packtpub.com/application-development/java-ee-8-high-performance
> > >
> > >
> > >
> > > Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat  a écrit
> > :
> > >
> > >> On Tue, Jan 24, 2023 at 1:26 PM  wrote:
> > >>>
> > >>> 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
> > >>> Author: Mark Thomas 
> > >>> AuthorDate: Tue Jan 24 12:22:01 2023 +
> > >>>
> > >>>  LongAdder is a better choice for statistics collection
> > >>
> > >> Never heard of that before, but I see it's already there in Java 8.
> > >>
> > >> Rémy
> > >>
> > >>> ---
> > >>>   java/org/apache/catalina/webresources/Cache.java | 17
> > +
> > >>>   1 file changed, 9 insertions(+), 8 deletions(-)
> > >>>
> > >>> diff --git a/java/org/apache/catalina/webresources/Cache.java
> > >> b/java/org/apache/catalina/webresources/Cache.java
> > >>> index 949117f521..4893a289cb 100644
> > >>> --- a/java/org/apache/catalina/webresources/Cache.java
> > >>> +++ b/java/org/apache/catalina/webresources/Cache.java
> > >>> @@ -22,6 +22,7 @@ import java.util.TreeSet;
> > >>>   import java.util.concurrent.ConcurrentHashMap;
> > >>>   import java.util.concurrent.ConcurrentMap;
> > >>>   import java.util.concurrent.atomic.AtomicLong;
> > >>> +import java.util.concurrent.atomic.LongAdder;
> > >>>
> > >>>   import org.apache.catalina.WebResource;
> > >>>   import org.apache.catalina.WebResourceRoot.CacheStrategy;
> > >>> @@ -48,8 +49,8 @@ public class Cache {
> > >>>   private int objectMaxSize = (int) maxSize /
> > OBJECT_MAX_SIZE_FACTOR;
> > >>>   private CacheStrategy cacheStrategy;
> > >>>
> > >>> -private AtomicLong lookupCount = new AtomicLong(0);
> > >>> -private AtomicLong hitCount = new AtomicLong(0);
> > >>> +private LongAdder lookupCount = new LongAdder();
> > >>> +private LongAdder hitCount = new LongAdder();
> > >>>
> > >>>   private final ConcurrentMap
> > resourceCache =
> > >> new ConcurrentHashMap<>();
> > >>>
> > >>> @@ -70,7 +71,7 @@ public class Cache {
> > >>>   }
> > >>>   }
> > >>>
> > >>> -lookupCount.incrementAndGet();
> > >>> +lookupCount.increment();
> > >>>
> > >>>   CachedResource cacheEntry = resourceCache.get(path);
> > >>>
> > >>> @@ -138,14 +139,14 @@ public class Cache {
> > >>>   cacheEntry.validateResource(useClassLoaderResources);
> > >>>   }
> > >>>   } else {
> > >>> -hitCount.incrementAndGet();
> > >>> +hitCount.increment();
> > >>>   }
> > >>>
> > >>>   return cacheEntry;
> > >>>   }
> > >>>
> > >>>   protected WebResource[] getResources(String path, boolean
> > >> useClassLoaderResources) {
> > >>> -lookupCount.incrementAndGet();
> > >>> +lookupCount.increment();
> > >>>
> > >>>   // Don't call noCache(path) since the class loader only
> > caches
> > >>>   // individual resources. Therefore, always cache collections
> > >> here
> > >>> @@ -196,7 +197,7 @@ public class Cache {
> > >>>
> >  cacheEntry.validateResources(useClassLoaderResources);
> > >>>   }
> > >>>   } else {
> > >>> -hitCount.incrementAndGet();
> > >>> +hitCount.increment();
> > >>>   }
> > >>>
> > >>>   return cacheEntry.getWebResources();
> > >>> @@ -291,11 +292,11 @@ public class Cache {
> > >>>   }
> > 

Re: [tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 Thread Romain Manni-Bucau
here is the idea https://github.com/apache/tomcat/pull/576

Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Blog
 | Github  |
LinkedIn  | Book



Le mar. 24 janv. 2023 à 14:24, Mark Thomas  a écrit :

> Patches welcome if that is an itch someone wants to scratch.
>
> Mark
>
>
> On 24/01/2023 13:22, Romain Manni-Bucau wrote:
> > If you care about the (perf) diff, shouldnt tomcat have a config to be
> able
> > to disable stats overhead at all (using a Runnable or Counter {incr(),
> > get()} as abstraction is sufficient) when it is not used (most of the
> time
> > in dev+prod - ie not sizing/tuning phases)?
> >
> > Romain Manni-Bucau
> > @rmannibucau  |  Blog
> >  | Old Blog
> >  | Github <
> https://github.com/rmannibucau> |
> > LinkedIn  | Book
> > <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >
> >
> > Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat  a écrit
> :
> >
> >> On Tue, Jan 24, 2023 at 1:26 PM  wrote:
> >>>
> >>> 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
> >>> Author: Mark Thomas 
> >>> AuthorDate: Tue Jan 24 12:22:01 2023 +
> >>>
> >>>  LongAdder is a better choice for statistics collection
> >>
> >> Never heard of that before, but I see it's already there in Java 8.
> >>
> >> Rémy
> >>
> >>> ---
> >>>   java/org/apache/catalina/webresources/Cache.java | 17
> +
> >>>   1 file changed, 9 insertions(+), 8 deletions(-)
> >>>
> >>> diff --git a/java/org/apache/catalina/webresources/Cache.java
> >> b/java/org/apache/catalina/webresources/Cache.java
> >>> index 949117f521..4893a289cb 100644
> >>> --- a/java/org/apache/catalina/webresources/Cache.java
> >>> +++ b/java/org/apache/catalina/webresources/Cache.java
> >>> @@ -22,6 +22,7 @@ import java.util.TreeSet;
> >>>   import java.util.concurrent.ConcurrentHashMap;
> >>>   import java.util.concurrent.ConcurrentMap;
> >>>   import java.util.concurrent.atomic.AtomicLong;
> >>> +import java.util.concurrent.atomic.LongAdder;
> >>>
> >>>   import org.apache.catalina.WebResource;
> >>>   import org.apache.catalina.WebResourceRoot.CacheStrategy;
> >>> @@ -48,8 +49,8 @@ public class Cache {
> >>>   private int objectMaxSize = (int) maxSize /
> OBJECT_MAX_SIZE_FACTOR;
> >>>   private CacheStrategy cacheStrategy;
> >>>
> >>> -private AtomicLong lookupCount = new AtomicLong(0);
> >>> -private AtomicLong hitCount = new AtomicLong(0);
> >>> +private LongAdder lookupCount = new LongAdder();
> >>> +private LongAdder hitCount = new LongAdder();
> >>>
> >>>   private final ConcurrentMap
> resourceCache =
> >> new ConcurrentHashMap<>();
> >>>
> >>> @@ -70,7 +71,7 @@ public class Cache {
> >>>   }
> >>>   }
> >>>
> >>> -lookupCount.incrementAndGet();
> >>> +lookupCount.increment();
> >>>
> >>>   CachedResource cacheEntry = resourceCache.get(path);
> >>>
> >>> @@ -138,14 +139,14 @@ public class Cache {
> >>>   cacheEntry.validateResource(useClassLoaderResources);
> >>>   }
> >>>   } else {
> >>> -hitCount.incrementAndGet();
> >>> +hitCount.increment();
> >>>   }
> >>>
> >>>   return cacheEntry;
> >>>   }
> >>>
> >>>   protected WebResource[] getResources(String path, boolean
> >> useClassLoaderResources) {
> >>> -lookupCount.incrementAndGet();
> >>> +lookupCount.increment();
> >>>
> >>>   // Don't call noCache(path) since the class loader only
> caches
> >>>   // individual resources. Therefore, always cache collections
> >> here
> >>> @@ -196,7 +197,7 @@ public class Cache {
> >>>
>  cacheEntry.validateResources(useClassLoaderResources);
> >>>   }
> >>>   } else {
> >>> -hitCount.incrementAndGet();
> >>> +hitCount.increment();
> >>>   }
> >>>
> >>>   return cacheEntry.getWebResources();
> >>> @@ -291,11 +292,11 @@ public class Cache {
> >>>   }
> >>>
> >>>   public long getLookupCount() {
> >>> -return lookupCount.get();
> >>> +return lookupCount.sum();
> >>>   }
> >>>
> >>>   public long getHitCount() {
> >>> -return hitCount.get();
> >>> +return hitCount.sum();
> >>>   }
> >>>
> >>>   public void setObjectMaxSize(int objectMaxSize) {
> >>>
> >>>
> >>> -
> 

Re: [tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 Thread Mark Thomas

Patches welcome if that is an itch someone wants to scratch.

Mark


On 24/01/2023 13:22, Romain Manni-Bucau wrote:

If you care about the (perf) diff, shouldnt tomcat have a config to be able
to disable stats overhead at all (using a Runnable or Counter {incr(),
get()} as abstraction is sufficient) when it is not used (most of the time
in dev+prod - ie not sizing/tuning phases)?

Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Blog
 | Github  |
LinkedIn  | Book



Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat  a écrit :


On Tue, Jan 24, 2023 at 1:26 PM  wrote:


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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:22:01 2023 +

 LongAdder is a better choice for statistics collection


Never heard of that before, but I see it's already there in Java 8.

Rémy


---
  java/org/apache/catalina/webresources/Cache.java | 17 +
  1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/webresources/Cache.java

b/java/org/apache/catalina/webresources/Cache.java

index 949117f521..4893a289cb 100644
--- a/java/org/apache/catalina/webresources/Cache.java
+++ b/java/org/apache/catalina/webresources/Cache.java
@@ -22,6 +22,7 @@ import java.util.TreeSet;
  import java.util.concurrent.ConcurrentHashMap;
  import java.util.concurrent.ConcurrentMap;
  import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.LongAdder;

  import org.apache.catalina.WebResource;
  import org.apache.catalina.WebResourceRoot.CacheStrategy;
@@ -48,8 +49,8 @@ public class Cache {
  private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
  private CacheStrategy cacheStrategy;

-private AtomicLong lookupCount = new AtomicLong(0);
-private AtomicLong hitCount = new AtomicLong(0);
+private LongAdder lookupCount = new LongAdder();
+private LongAdder hitCount = new LongAdder();

  private final ConcurrentMap resourceCache =

new ConcurrentHashMap<>();


@@ -70,7 +71,7 @@ public class Cache {
  }
  }

-lookupCount.incrementAndGet();
+lookupCount.increment();

  CachedResource cacheEntry = resourceCache.get(path);

@@ -138,14 +139,14 @@ public class Cache {
  cacheEntry.validateResource(useClassLoaderResources);
  }
  } else {
-hitCount.incrementAndGet();
+hitCount.increment();
  }

  return cacheEntry;
  }

  protected WebResource[] getResources(String path, boolean

useClassLoaderResources) {

-lookupCount.incrementAndGet();
+lookupCount.increment();

  // Don't call noCache(path) since the class loader only caches
  // individual resources. Therefore, always cache collections

here

@@ -196,7 +197,7 @@ public class Cache {
  cacheEntry.validateResources(useClassLoaderResources);
  }
  } else {
-hitCount.incrementAndGet();
+hitCount.increment();
  }

  return cacheEntry.getWebResources();
@@ -291,11 +292,11 @@ public class Cache {
  }

  public long getLookupCount() {
-return lookupCount.get();
+return lookupCount.sum();
  }

  public long getHitCount() {
-return hitCount.get();
+return hitCount.sum();
  }

  public void setObjectMaxSize(int objectMaxSize) {


-
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: LongAdder is a better choice for statistics collection

2023-01-24 Thread Romain Manni-Bucau
If you care about the (perf) diff, shouldnt tomcat have a config to be able
to disable stats overhead at all (using a Runnable or Counter {incr(),
get()} as abstraction is sufficient) when it is not used (most of the time
in dev+prod - ie not sizing/tuning phases)?

Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Blog
 | Github  |
LinkedIn  | Book



Le mar. 24 janv. 2023 à 14:19, Rémy Maucherat  a écrit :

> On Tue, Jan 24, 2023 at 1:26 PM  wrote:
> >
> > 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
> > Author: Mark Thomas 
> > AuthorDate: Tue Jan 24 12:22:01 2023 +
> >
> > LongAdder is a better choice for statistics collection
>
> Never heard of that before, but I see it's already there in Java 8.
>
> Rémy
>
> > ---
> >  java/org/apache/catalina/webresources/Cache.java | 17 +
> >  1 file changed, 9 insertions(+), 8 deletions(-)
> >
> > diff --git a/java/org/apache/catalina/webresources/Cache.java
> b/java/org/apache/catalina/webresources/Cache.java
> > index 949117f521..4893a289cb 100644
> > --- a/java/org/apache/catalina/webresources/Cache.java
> > +++ b/java/org/apache/catalina/webresources/Cache.java
> > @@ -22,6 +22,7 @@ import java.util.TreeSet;
> >  import java.util.concurrent.ConcurrentHashMap;
> >  import java.util.concurrent.ConcurrentMap;
> >  import java.util.concurrent.atomic.AtomicLong;
> > +import java.util.concurrent.atomic.LongAdder;
> >
> >  import org.apache.catalina.WebResource;
> >  import org.apache.catalina.WebResourceRoot.CacheStrategy;
> > @@ -48,8 +49,8 @@ public class Cache {
> >  private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
> >  private CacheStrategy cacheStrategy;
> >
> > -private AtomicLong lookupCount = new AtomicLong(0);
> > -private AtomicLong hitCount = new AtomicLong(0);
> > +private LongAdder lookupCount = new LongAdder();
> > +private LongAdder hitCount = new LongAdder();
> >
> >  private final ConcurrentMap resourceCache =
> new ConcurrentHashMap<>();
> >
> > @@ -70,7 +71,7 @@ public class Cache {
> >  }
> >  }
> >
> > -lookupCount.incrementAndGet();
> > +lookupCount.increment();
> >
> >  CachedResource cacheEntry = resourceCache.get(path);
> >
> > @@ -138,14 +139,14 @@ public class Cache {
> >  cacheEntry.validateResource(useClassLoaderResources);
> >  }
> >  } else {
> > -hitCount.incrementAndGet();
> > +hitCount.increment();
> >  }
> >
> >  return cacheEntry;
> >  }
> >
> >  protected WebResource[] getResources(String path, boolean
> useClassLoaderResources) {
> > -lookupCount.incrementAndGet();
> > +lookupCount.increment();
> >
> >  // Don't call noCache(path) since the class loader only caches
> >  // individual resources. Therefore, always cache collections
> here
> > @@ -196,7 +197,7 @@ public class Cache {
> >  cacheEntry.validateResources(useClassLoaderResources);
> >  }
> >  } else {
> > -hitCount.incrementAndGet();
> > +hitCount.increment();
> >  }
> >
> >  return cacheEntry.getWebResources();
> > @@ -291,11 +292,11 @@ public class Cache {
> >  }
> >
> >  public long getLookupCount() {
> > -return lookupCount.get();
> > +return lookupCount.sum();
> >  }
> >
> >  public long getHitCount() {
> > -return hitCount.get();
> > +return hitCount.sum();
> >  }
> >
> >  public void setObjectMaxSize(int objectMaxSize) {
> >
> >
> > -
> > 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
>
>


[tomcat] branch main updated: Switch to using LongAddr to track request/error count for servlets

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new e329ceb5c7 Switch to using LongAddr to track request/error count for 
servlets
e329ceb5c7 is described below

commit e329ceb5c7aa51c33f036b375e88d7e35cc50706
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:22:34 2023 +

Switch to using LongAddr to track request/error count for servlets
---
 java/org/apache/catalina/core/StandardContext.java | 16 -
 java/org/apache/catalina/core/StandardWrapper.java | 12 ++
 .../apache/catalina/core/StandardWrapperValve.java | 26 --
 webapps/docs/changelog.xml |  5 +
 4 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index e0ca2f97c5..be5d325a72 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -4094,14 +4094,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative request count of all servlets in this 
StandardContext.
  *
  * @return Cumulative request count of all servlets in this StandardContext
- *
- * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
- * storing the result of calls to this method in a long 
value rather than an int.
  */
-@Deprecated
-public int getRequestCount() {
+public long getRequestCount() {
 
-int result = 0;
+long result = 0;
 
 Container[] children = findChildren();
 if (children != null) {
@@ -4117,14 +4113,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative error count of all servlets in this StandardContext.
  *
  * @return Cumulative error count of all servlets in this StandardContext
- *
- * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
- * storing the result of calls to this method in a long 
value rather than an int.
  */
-@Deprecated
-public int getErrorCount() {
+public long getErrorCount() {
 
-int result = 0;
+long result = 0;
 
 Container[] children = findChildren();
 if (children != null) {
diff --git a/java/org/apache/catalina/core/StandardWrapper.java 
b/java/org/apache/catalina/core/StandardWrapper.java
index d0d89d3aec..a3006fb496 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -1178,12 +1178,8 @@ public class StandardWrapper extends ContainerBase 
implements ServletConfig, Wra
  * Returns the number of requests processed by the wrapper.
  *
  * @return the number of requests processed by the wrapper.
- *
- * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
- * storing the result of calls to this method in a long 
value rather than an int.
  */
-@Deprecated
-public int getRequestCount() {
+public long getRequestCount() {
 return swValve.getRequestCount();
 }
 
@@ -1191,12 +1187,8 @@ public class StandardWrapper extends ContainerBase 
implements ServletConfig, Wra
  * Returns the number of requests processed by the wrapper that resulted 
in an error.
  *
  * @return the number of requests processed by the wrapper that resulted 
in an error.
- *
- * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
- * storing the result of calls to this method in a long 
value rather than an int.
  */
-@Deprecated
-public int getErrorCount() {
+public long getErrorCount() {
 return swValve.getErrorCount();
 }
 
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index 5d2f0f2456..cfed5bd8ce 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -18,7 +18,7 @@ package org.apache.catalina.core;
 
 
 import java.io.IOException;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.LongAdder;
 
 import jakarta.servlet.DispatcherType;
 import jakarta.servlet.RequestDispatcher;
@@ -66,8 +66,8 @@ final class StandardWrapperValve extends ValveBase {
 private volatile long processingTime;
 private volatile long maxTime;
 private volatile long minTime = Long.MAX_VALUE;
-private final AtomicInteger requestCount 

[tomcat] branch 8.5.x updated (e9403a45ba -> 353306175b)

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from e9403a45ba Code cleanup (format). No functional change.
 new 8f55a7bc9c Code cleanup (format). No functional change.
 new 353306175b Add ALv2 headers

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:
 .../org/apache/catalina/core/AccessLogAdapter.java |2 +-
 .../apache/catalina/core/ApplicationContext.java   |  180 +--
 .../catalina/core/ApplicationContextFacade.java|  329 ++--
 .../catalina/core/ApplicationDispatcher.java   |  332 ++--
 .../catalina/core/ApplicationFilterChain.java  |  118 +-
 .../catalina/core/ApplicationFilterConfig.java |  131 +-
 .../catalina/core/ApplicationFilterFactory.java|   75 +-
 .../core/ApplicationFilterRegistration.java|   21 +-
 .../catalina/core/ApplicationHttpRequest.java  |  164 +-
 .../catalina/core/ApplicationHttpResponse.java |   59 +-
 .../catalina/core/ApplicationMappingImpl.java  |3 +-
 .../catalina/core/ApplicationMappingMatch.java |9 +-
 java/org/apache/catalina/core/ApplicationPart.java |   13 +-
 .../catalina/core/ApplicationPushBuilder.java  |   32 +-
 .../apache/catalina/core/ApplicationRequest.java   |   50 +-
 .../apache/catalina/core/ApplicationResponse.java  |   32 +-
 .../core/ApplicationServletRegistration.java   |   22 +-
 .../core/ApplicationSessionCookieConfig.java   |   58 +-
 .../apache/catalina/core/AprLifecycleListener.java |  101 +-
 .../org/apache/catalina/core/AsyncContextImpl.java |  103 +-
 .../apache/catalina/core/AsyncListenerWrapper.java |3 +-
 java/org/apache/catalina/core/ContainerBase.java   |  360 ++---
 .../catalina/core/DefaultInstanceManager.java  |  284 ++--
 .../apache/catalina/core/JniLifecycleListener.java |   12 +-
 .../core/JreMemoryLeakPreventionListener.java  |  340 ++--
 .../catalina/core/NamingContextListener.java   |  173 +--
 java/org/apache/catalina/core/StandardContext.java | 1636 
 .../apache/catalina/core/StandardContextValve.java |   27 +-
 java/org/apache/catalina/core/StandardEngine.java  |   98 +-
 .../apache/catalina/core/StandardEngineValve.java  |   20 +-
 java/org/apache/catalina/core/StandardHost.java|  176 +--
 .../apache/catalina/core/StandardHostValve.java|   81 +-
 .../org/apache/catalina/core/StandardPipeline.java |   93 +-
 java/org/apache/catalina/core/StandardServer.java  |  122 +-
 java/org/apache/catalina/core/StandardService.java |   91 +-
 .../catalina/core/StandardThreadExecutor.java  |   36 +-
 java/org/apache/catalina/core/StandardWrapper.java |  445 +++---
 .../catalina/core/StandardWrapperFacade.java   |4 +-
 .../apache/catalina/core/StandardWrapperValve.java |  119 +-
 .../core/ThreadLocalLeakPreventionListener.java|   70 +-
 res/ide-support/eclipse/clean-up-asf-tomcat.xml|   16 +
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   16 +
 42 files changed, 2427 insertions(+), 3629 deletions(-)


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



[tomcat] 02/02: Add ALv2 headers

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 353306175b031a9c7595cbea9f06958ee48d7ddc
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:20:30 2023 +

Add ALv2 headers
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 16 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 16 
 2 files changed, 32 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
index f56c6fe4d2..4a5b69aa25 100644
--- a/res/ide-support/eclipse/clean-up-asf-tomcat.xml
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 8327af9885..71f085b69d 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 


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



[tomcat] branch 9.0.x updated: Add ALv2 headers

2023-01-24 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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new adb9c8a0f2 Add ALv2 headers
adb9c8a0f2 is described below

commit adb9c8a0f28920a04aec0a10605aeb4ac14f893b
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:20:30 2023 +

Add ALv2 headers
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 16 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 16 
 2 files changed, 32 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
index f56c6fe4d2..4a5b69aa25 100644
--- a/res/ide-support/eclipse/clean-up-asf-tomcat.xml
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 8327af9885..71f085b69d 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 


-
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: Add ALv2 headers

2023-01-24 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 f747796f1e Add ALv2 headers
f747796f1e is described below

commit f747796f1efa9069d96a3c7b1fb8dc4c6cd20ba5
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:20:30 2023 +

Add ALv2 headers
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 16 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 16 
 2 files changed, 32 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
index f56c6fe4d2..4a5b69aa25 100644
--- a/res/ide-support/eclipse/clean-up-asf-tomcat.xml
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 8327af9885..71f085b69d 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 


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



[tomcat] branch main updated: Add ALv2 headers

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 92ad891c61 Add ALv2 headers
92ad891c61 is described below

commit 92ad891c61a3cefeb670229264324b1f14e83624
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:20:30 2023 +

Add ALv2 headers
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 16 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 16 
 2 files changed, 32 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
index f56c6fe4d2..4a5b69aa25 100644
--- a/res/ide-support/eclipse/clean-up-asf-tomcat.xml
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 8327af9885..71f085b69d 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -1,4 +1,20 @@
 
+
 
 
 


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



Re: [tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 Thread Rémy Maucherat
On Tue, Jan 24, 2023 at 1:26 PM  wrote:
>
> 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
> Author: Mark Thomas 
> AuthorDate: Tue Jan 24 12:22:01 2023 +
>
> LongAdder is a better choice for statistics collection

Never heard of that before, but I see it's already there in Java 8.

Rémy

> ---
>  java/org/apache/catalina/webresources/Cache.java | 17 +
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/java/org/apache/catalina/webresources/Cache.java 
> b/java/org/apache/catalina/webresources/Cache.java
> index 949117f521..4893a289cb 100644
> --- a/java/org/apache/catalina/webresources/Cache.java
> +++ b/java/org/apache/catalina/webresources/Cache.java
> @@ -22,6 +22,7 @@ import java.util.TreeSet;
>  import java.util.concurrent.ConcurrentHashMap;
>  import java.util.concurrent.ConcurrentMap;
>  import java.util.concurrent.atomic.AtomicLong;
> +import java.util.concurrent.atomic.LongAdder;
>
>  import org.apache.catalina.WebResource;
>  import org.apache.catalina.WebResourceRoot.CacheStrategy;
> @@ -48,8 +49,8 @@ public class Cache {
>  private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
>  private CacheStrategy cacheStrategy;
>
> -private AtomicLong lookupCount = new AtomicLong(0);
> -private AtomicLong hitCount = new AtomicLong(0);
> +private LongAdder lookupCount = new LongAdder();
> +private LongAdder hitCount = new LongAdder();
>
>  private final ConcurrentMap resourceCache = new 
> ConcurrentHashMap<>();
>
> @@ -70,7 +71,7 @@ public class Cache {
>  }
>  }
>
> -lookupCount.incrementAndGet();
> +lookupCount.increment();
>
>  CachedResource cacheEntry = resourceCache.get(path);
>
> @@ -138,14 +139,14 @@ public class Cache {
>  cacheEntry.validateResource(useClassLoaderResources);
>  }
>  } else {
> -hitCount.incrementAndGet();
> +hitCount.increment();
>  }
>
>  return cacheEntry;
>  }
>
>  protected WebResource[] getResources(String path, boolean 
> useClassLoaderResources) {
> -lookupCount.incrementAndGet();
> +lookupCount.increment();
>
>  // Don't call noCache(path) since the class loader only caches
>  // individual resources. Therefore, always cache collections here
> @@ -196,7 +197,7 @@ public class Cache {
>  cacheEntry.validateResources(useClassLoaderResources);
>  }
>  } else {
> -hitCount.incrementAndGet();
> +hitCount.increment();
>  }
>
>  return cacheEntry.getWebResources();
> @@ -291,11 +292,11 @@ public class Cache {
>  }
>
>  public long getLookupCount() {
> -return lookupCount.get();
> +return lookupCount.sum();
>  }
>
>  public long getHitCount() {
> -return hitCount.get();
> +return hitCount.sum();
>  }
>
>  public void setObjectMaxSize(int objectMaxSize) {
>
>
> -
> 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



[tomcat] branch 10.1.x updated (2df2a763a2 -> 9aad349b60)

2023-01-24 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 2df2a763a2 LongAdder is a better choice for statistics collection
 new fc53b9f9e9 Code cleanup (format). No functional change.
 new 9aad349b60 Deprecate in preparation for switching to LongAddr

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:
 .../org/apache/catalina/core/AccessLogAdapter.java |2 +-
 .../apache/catalina/core/ApplicationContext.java   |  176 +--
 .../catalina/core/ApplicationContextFacade.java|  315 ++--
 .../catalina/core/ApplicationDispatcher.java   |  326 ++--
 .../catalina/core/ApplicationFilterChain.java  |  113 +-
 .../catalina/core/ApplicationFilterConfig.java |  114 +-
 .../catalina/core/ApplicationFilterFactory.java|   75 +-
 .../core/ApplicationFilterRegistration.java|   21 +-
 .../catalina/core/ApplicationHttpRequest.java  |  161 +-
 .../catalina/core/ApplicationHttpResponse.java |   49 +-
 .../apache/catalina/core/ApplicationMapping.java   |7 +-
 java/org/apache/catalina/core/ApplicationPart.java |   13 +-
 .../catalina/core/ApplicationPushBuilder.java  |   32 +-
 .../apache/catalina/core/ApplicationRequest.java   |   53 +-
 .../apache/catalina/core/ApplicationResponse.java  |   32 +-
 .../core/ApplicationServletRegistration.java   |   22 +-
 .../core/ApplicationSessionCookieConfig.java   |   89 +-
 .../apache/catalina/core/AprLifecycleListener.java |   90 +-
 .../org/apache/catalina/core/AsyncContextImpl.java |  103 +-
 .../apache/catalina/core/AsyncListenerWrapper.java |3 +-
 java/org/apache/catalina/core/ContainerBase.java   |  360 ++---
 .../catalina/core/DefaultInstanceManager.java  |  284 ++--
 .../apache/catalina/core/FrameworkListener.java|   13 +-
 .../apache/catalina/core/JniLifecycleListener.java |   12 +-
 .../core/JreMemoryLeakPreventionListener.java  |  112 +-
 .../catalina/core/NamingContextListener.java   |  165 +-
 java/org/apache/catalina/core/StandardContext.java | 1630 
 .../apache/catalina/core/StandardContextValve.java |   27 +-
 java/org/apache/catalina/core/StandardEngine.java  |   96 +-
 .../apache/catalina/core/StandardEngineValve.java  |   20 +-
 java/org/apache/catalina/core/StandardHost.java|  178 +--
 .../apache/catalina/core/StandardHostValve.java|   78 +-
 .../org/apache/catalina/core/StandardPipeline.java |   93 +-
 java/org/apache/catalina/core/StandardServer.java  |  141 +-
 java/org/apache/catalina/core/StandardService.java |   76 +-
 .../catalina/core/StandardThreadExecutor.java  |   34 +-
 java/org/apache/catalina/core/StandardWrapper.java |  406 +++--
 .../catalina/core/StandardWrapperFacade.java   |4 +-
 .../apache/catalina/core/StandardWrapperValve.java |  136 +-
 .../core/ThreadLocalLeakPreventionListener.java|   49 +-
 40 files changed, 2292 insertions(+), 3418 deletions(-)


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



[tomcat] 02/02: Deprecate in preparation for switching to LongAddr

2023-01-24 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 9aad349b607d88215a3398ae0adc4d1818673ef1
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:06:08 2023 +

Deprecate in preparation for switching to LongAddr
---
 java/org/apache/catalina/core/StandardContext.java |  8 
 java/org/apache/catalina/core/StandardWrapper.java | 18 ++
 .../org/apache/catalina/core/StandardWrapperValve.java | 18 ++
 3 files changed, 44 insertions(+)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 8a24d66115..56595da4ff 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -4096,7 +4096,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative request count of all servlets in this 
StandardContext.
  *
  * @return Cumulative request count of all servlets in this StandardContext
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
  */
+@Deprecated
 public int getRequestCount() {
 
 int result = 0;
@@ -4115,7 +4119,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative error count of all servlets in this StandardContext.
  *
  * @return Cumulative error count of all servlets in this StandardContext
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
  */
+@Deprecated
 public int getErrorCount() {
 
 int result = 0;
diff --git a/java/org/apache/catalina/core/StandardWrapper.java 
b/java/org/apache/catalina/core/StandardWrapper.java
index 16b3f0e00b..5d97c7cdf1 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -1205,10 +1205,28 @@ public class StandardWrapper extends ContainerBase 
implements ServletConfig, Wra
 return swValve.getMinTime();
 }
 
+/**
+ * Returns the number of requests processed by the wrapper.
+ *
+ * @return the number of requests processed by the wrapper.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getRequestCount() {
 return swValve.getRequestCount();
 }
 
+/**
+ * Returns the number of requests processed by the wrapper that resulted 
in an error.
+ *
+ * @return the number of requests processed by the wrapper that resulted 
in an error.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getErrorCount() {
 return swValve.getErrorCount();
 }
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index e22d755e01..5d2f0f2456 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -288,10 +288,28 @@ final class StandardWrapperValve extends ValveBase {
 return minTime;
 }
 
+/**
+ * Returns the number of requests processed by the associated wrapper.
+ *
+ * @return the number of requests processed by the associated wrapper.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getRequestCount() {
 return requestCount.get();
 }
 
+/**
+ * Returns the number of requests processed by the associated wrapper that 
resulted in an error.
+ *
+ * @return the number of requests processed by the associated wrapper that 
resulted in an error.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getErrorCount() {
 return errorCount.get();
 }



[tomcat] branch main updated: Deprecation for int -> long change

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 91786da002 Deprecation for int -> long change
91786da002 is described below

commit 91786da002450cc12384a306a4e8819fff88bec7
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:10:47 2023 +

Deprecation for int -> long change
---
 java/org/apache/catalina/core/StandardContext.java |  8 
 java/org/apache/catalina/core/StandardWrapper.java | 18 ++
 2 files changed, 26 insertions(+)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 459d5b4254..e0ca2f97c5 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -4094,7 +4094,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative request count of all servlets in this 
StandardContext.
  *
  * @return Cumulative request count of all servlets in this StandardContext
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
  */
+@Deprecated
 public int getRequestCount() {
 
 int result = 0;
@@ -4113,7 +4117,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  * Gets the cumulative error count of all servlets in this StandardContext.
  *
  * @return Cumulative error count of all servlets in this StandardContext
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
  */
+@Deprecated
 public int getErrorCount() {
 
 int result = 0;
diff --git a/java/org/apache/catalina/core/StandardWrapper.java 
b/java/org/apache/catalina/core/StandardWrapper.java
index e81964ef35..d0d89d3aec 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -1174,10 +1174,28 @@ public class StandardWrapper extends ContainerBase 
implements ServletConfig, Wra
 return swValve.getMinTime();
 }
 
+/**
+ * Returns the number of requests processed by the wrapper.
+ *
+ * @return the number of requests processed by the wrapper.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getRequestCount() {
 return swValve.getRequestCount();
 }
 
+/**
+ * Returns the number of requests processed by the wrapper that resulted 
in an error.
+ *
+ * @return the number of requests processed by the wrapper that resulted 
in an error.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getErrorCount() {
 return swValve.getErrorCount();
 }


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



[tomcat] 02/02: Deprecate in preparation for switching to LongAddr

2023-01-24 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 40fcd5345826c51fd8272e4a90fdcf10c6547b18
Author: Mark Thomas 
AuthorDate: Tue Jan 24 13:06:08 2023 +

Deprecate in preparation for switching to LongAddr
---
 .../org/apache/catalina/core/StandardWrapperValve.java | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index e22d755e01..5d2f0f2456 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -288,10 +288,28 @@ final class StandardWrapperValve extends ValveBase {
 return minTime;
 }
 
+/**
+ * Returns the number of requests processed by the associated wrapper.
+ *
+ * @return the number of requests processed by the associated wrapper.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getRequestCount() {
 return requestCount.get();
 }
 
+/**
+ * Returns the number of requests processed by the associated wrapper that 
resulted in an error.
+ *
+ * @return the number of requests processed by the associated wrapper that 
resulted in an error.
+ *
+ * @deprecated The return type will change to long in Tomcat 11 onwards. 
Callers of this method should switch to
+ * storing the result of calls to this method in a long 
value rather than an int.
+ */
+@Deprecated
 public int getErrorCount() {
 return errorCount.get();
 }


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



[tomcat] branch main updated (2acb530d27 -> 40fcd53458)

2023-01-24 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 2acb530d27 LongAdder is a better choice for statistics collection
 new a7da4da743 Code cleanup (format). No functional change.
 new 40fcd53458 Deprecate in preparation for switching to LongAddr

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:
 .../org/apache/catalina/core/AccessLogAdapter.java |2 +-
 .../apache/catalina/core/ApplicationContext.java   |  173 +--
 .../catalina/core/ApplicationContextFacade.java|   48 +-
 .../catalina/core/ApplicationDispatcher.java   |  286 ++--
 .../catalina/core/ApplicationFilterChain.java  |   50 +-
 .../catalina/core/ApplicationFilterConfig.java |  110 +-
 .../catalina/core/ApplicationFilterFactory.java|   75 +-
 .../core/ApplicationFilterRegistration.java|   21 +-
 .../catalina/core/ApplicationHttpRequest.java  |  161 +-
 .../catalina/core/ApplicationHttpResponse.java |   49 +-
 .../apache/catalina/core/ApplicationMapping.java   |7 +-
 java/org/apache/catalina/core/ApplicationPart.java |   13 +-
 .../catalina/core/ApplicationPushBuilder.java  |   32 +-
 .../apache/catalina/core/ApplicationRequest.java   |   53 +-
 .../apache/catalina/core/ApplicationResponse.java  |   32 +-
 .../core/ApplicationServletRegistration.java   |   22 +-
 .../core/ApplicationSessionCookieConfig.java   |   89 +-
 .../apache/catalina/core/AprLifecycleListener.java |   90 +-
 .../org/apache/catalina/core/AsyncContextImpl.java |  103 +-
 .../apache/catalina/core/AsyncListenerWrapper.java |3 +-
 java/org/apache/catalina/core/ContainerBase.java   |  351 ++---
 .../catalina/core/DefaultInstanceManager.java  |  272 ++--
 .../apache/catalina/core/FrameworkListener.java|   13 +-
 .../apache/catalina/core/JniLifecycleListener.java |   12 +-
 .../core/JreMemoryLeakPreventionListener.java  |  112 +-
 .../catalina/core/NamingContextListener.java   |  165 +-
 java/org/apache/catalina/core/StandardContext.java | 1625 
 .../apache/catalina/core/StandardContextValve.java |   27 +-
 java/org/apache/catalina/core/StandardEngine.java  |   96 +-
 .../apache/catalina/core/StandardEngineValve.java  |   20 +-
 java/org/apache/catalina/core/StandardHost.java|  178 +--
 .../apache/catalina/core/StandardHostValve.java|   78 +-
 .../org/apache/catalina/core/StandardPipeline.java |   93 +-
 java/org/apache/catalina/core/StandardServer.java  |  141 +-
 java/org/apache/catalina/core/StandardService.java |   76 +-
 .../catalina/core/StandardThreadExecutor.java  |   34 +-
 java/org/apache/catalina/core/StandardWrapper.java |  374 ++---
 .../catalina/core/StandardWrapperFacade.java   |4 +-
 .../apache/catalina/core/StandardWrapperValve.java |  136 +-
 .../core/ThreadLocalLeakPreventionListener.java|   49 +-
 40 files changed, 2109 insertions(+), 3166 deletions(-)


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



[tomcat] branch 8.5.x updated: Code cleanup (format). No functional change.

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new e9403a45ba Code cleanup (format). No functional change.
e9403a45ba is described below

commit e9403a45ba465baf8e07b198edc4733d8a3369a0
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:25:04 2023 +

Code cleanup (format). No functional change.
---
 .../webresources/AbstractArchiveResource.java  |  22 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  69 --
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  14 +--
 java/org/apache/catalina/webresources/Cache.java   |  41 +++---
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   7 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 --
 .../apache/catalina/webresources/StandardRoot.java | 140 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../TomcatURLStreamHandlerFactory.java |  44 +++
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 26 files changed, 290 insertions(+), 457 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractArchiveResource.java 
b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
index 8e4daffddc..982d676f12 100644
--- a/java/org/apache/catalina/webresources/AbstractArchiveResource.java
+++ b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
@@ -40,8 +40,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 private boolean readCerts = false;
 private Certificate[] certificates;
 
-protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet,
-String webAppPath, String baseUrl, JarEntry jarEntry, String 
codeBaseUrl) {
+protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath, String baseUrl,
+JarEntry jarEntry, String codeBaseUrl) {
 super(archiveResourceSet.getRoot(), webAppPath);
 this.archiveResourceSet = archiveResourceSet;
 this.baseUrl = baseUrl;
@@ -53,8 +53,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 resourceName = resourceName.substring(0, resourceName.length() - 
1);
 }
 String internalPath = archiveResourceSet.getInternalPath();
-if (internalPath.length() > 0 && resourceName.equals(
-internalPath.subSequence(1, internalPath.length( {
+if (internalPath.length() > 0 && 
resourceName.equals(internalPath.subSequence(1, internalPath.length( {
 name = "";
 } else {
 int index = resourceName.lastIndexOf('/');
@@ -171,9 +170,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(sm.getString(
-"abstractResource.getContentTooLarge", getWebappPath(),
-Long.valueOf(len)));
+throw new ArrayIndexOutOfBoundsException(
+sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
 }
 
 if (len < 0) {
@@ -202,8 +200,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 readCerts = true;
 } catch (IOException ioe) {
 if (getLog().isDebugEnabled()) {
-getLog().debug(sm.getString("abstractResource.getContentFail",
-getWebappPath()), ioe);
+getLog().debug(sm.getString("abstractResource.getContentFail", 
getWebappPath()), ioe);
 }
 // Don't return corrupted content
 return null;
@@ -238,10 +235,9 @@ public abstract class 

[tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 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 a7bf4d84f753d69acb66f5e45f5bc767a1d55e49
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:22:01 2023 +

LongAdder is a better choice for statistics collection
---
 java/org/apache/catalina/webresources/Cache.java | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/webresources/Cache.java 
b/java/org/apache/catalina/webresources/Cache.java
index 949117f521..4893a289cb 100644
--- a/java/org/apache/catalina/webresources/Cache.java
+++ b/java/org/apache/catalina/webresources/Cache.java
@@ -22,6 +22,7 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.LongAdder;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot.CacheStrategy;
@@ -48,8 +49,8 @@ public class Cache {
 private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
 private CacheStrategy cacheStrategy;
 
-private AtomicLong lookupCount = new AtomicLong(0);
-private AtomicLong hitCount = new AtomicLong(0);
+private LongAdder lookupCount = new LongAdder();
+private LongAdder hitCount = new LongAdder();
 
 private final ConcurrentMap resourceCache = new 
ConcurrentHashMap<>();
 
@@ -70,7 +71,7 @@ public class Cache {
 }
 }
 
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 CachedResource cacheEntry = resourceCache.get(path);
 
@@ -138,14 +139,14 @@ public class Cache {
 cacheEntry.validateResource(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry;
 }
 
 protected WebResource[] getResources(String path, boolean 
useClassLoaderResources) {
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 // Don't call noCache(path) since the class loader only caches
 // individual resources. Therefore, always cache collections here
@@ -196,7 +197,7 @@ public class Cache {
 cacheEntry.validateResources(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry.getWebResources();
@@ -291,11 +292,11 @@ public class Cache {
 }
 
 public long getLookupCount() {
-return lookupCount.get();
+return lookupCount.sum();
 }
 
 public long getHitCount() {
-return hitCount.get();
+return hitCount.sum();
 }
 
 public void setObjectMaxSize(int objectMaxSize) {


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



[tomcat] 01/02: Code cleanup (format). No functional change.

2023-01-24 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 90b564ce38fa5d6a8894b63245330f38ae0551f4
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:24:04 2023 +

Code cleanup (format). No functional change.
---
 .../webresources/AbstractArchiveResource.java  |  22 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  14 +--
 java/org/apache/catalina/webresources/Cache.java   |  42 +++
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   7 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../TomcatURLStreamHandlerFactory.java |  44 +++
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 27 files changed, 306 insertions(+), 479 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractArchiveResource.java 
b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
index 8e4daffddc..982d676f12 100644
--- a/java/org/apache/catalina/webresources/AbstractArchiveResource.java
+++ b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
@@ -40,8 +40,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 private boolean readCerts = false;
 private Certificate[] certificates;
 
-protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet,
-String webAppPath, String baseUrl, JarEntry jarEntry, String 
codeBaseUrl) {
+protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath, String baseUrl,
+JarEntry jarEntry, String codeBaseUrl) {
 super(archiveResourceSet.getRoot(), webAppPath);
 this.archiveResourceSet = archiveResourceSet;
 this.baseUrl = baseUrl;
@@ -53,8 +53,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 resourceName = resourceName.substring(0, resourceName.length() - 
1);
 }
 String internalPath = archiveResourceSet.getInternalPath();
-if (internalPath.length() > 0 && resourceName.equals(
-internalPath.subSequence(1, internalPath.length( {
+if (internalPath.length() > 0 && 
resourceName.equals(internalPath.subSequence(1, internalPath.length( {
 name = "";
 } else {
 int index = resourceName.lastIndexOf('/');
@@ -171,9 +170,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(sm.getString(
-"abstractResource.getContentTooLarge", getWebappPath(),
-Long.valueOf(len)));
+throw new ArrayIndexOutOfBoundsException(
+sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
 }
 
 if (len < 0) {
@@ -202,8 +200,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 readCerts = true;
 } catch (IOException ioe) {
 if (getLog().isDebugEnabled()) {
-getLog().debug(sm.getString("abstractResource.getContentFail",
-getWebappPath()), ioe);
+getLog().debug(sm.getString("abstractResource.getContentFail", 
getWebappPath()), ioe);
 }
 // Don't return corrupted content
 return null;
@@ -238,10 +235,9 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 protected abstract JarInputStreamWrapper 

[tomcat] branch 9.0.x updated (3dab9abcee -> a7bf4d84f7)

2023-01-24 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 3dab9abcee Review all uses of LinkedHashMap#removeEldestEntry
 new 90b564ce38 Code cleanup (format). No functional change.
 new a7bf4d84f7 LongAdder is a better choice for statistics collection

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:
 .../webresources/AbstractArchiveResource.java  |  22 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  14 +--
 java/org/apache/catalina/webresources/Cache.java   |  59 -
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   7 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../TomcatURLStreamHandlerFactory.java |  44 +++
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 27 files changed, 315 insertions(+), 487 deletions(-)


-
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 (6551d18265 -> 2df2a763a2)

2023-01-24 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 6551d18265 Review all uses of LinkedHashMap#removeEldestEntry
 new a91a02d457 Code cleanup (format). No functional change.
 new 2df2a763a2 LongAdder is a better choice for statistics collection

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:
 .../webresources/AbstractArchiveResource.java  |  22 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  11 +-
 java/org/apache/catalina/webresources/Cache.java   |  59 -
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   7 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../TomcatURLStreamHandlerFactory.java |  48 +++-
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 27 files changed, 316 insertions(+), 487 deletions(-)


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



[tomcat] 01/02: Code cleanup (format). No functional change.

2023-01-24 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 a91a02d4575daff43bbf1b89db09a8ecad3484a3
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:22:51 2023 +

Code cleanup (format). No functional change.
---
 .../webresources/AbstractArchiveResource.java  |  22 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  11 +-
 java/org/apache/catalina/webresources/Cache.java   |  42 +++
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   7 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../TomcatURLStreamHandlerFactory.java |  48 +++-
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 27 files changed, 307 insertions(+), 479 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractArchiveResource.java 
b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
index 8e4daffddc..982d676f12 100644
--- a/java/org/apache/catalina/webresources/AbstractArchiveResource.java
+++ b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
@@ -40,8 +40,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 private boolean readCerts = false;
 private Certificate[] certificates;
 
-protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet,
-String webAppPath, String baseUrl, JarEntry jarEntry, String 
codeBaseUrl) {
+protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath, String baseUrl,
+JarEntry jarEntry, String codeBaseUrl) {
 super(archiveResourceSet.getRoot(), webAppPath);
 this.archiveResourceSet = archiveResourceSet;
 this.baseUrl = baseUrl;
@@ -53,8 +53,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 resourceName = resourceName.substring(0, resourceName.length() - 
1);
 }
 String internalPath = archiveResourceSet.getInternalPath();
-if (internalPath.length() > 0 && resourceName.equals(
-internalPath.subSequence(1, internalPath.length( {
+if (internalPath.length() > 0 && 
resourceName.equals(internalPath.subSequence(1, internalPath.length( {
 name = "";
 } else {
 int index = resourceName.lastIndexOf('/');
@@ -171,9 +170,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(sm.getString(
-"abstractResource.getContentTooLarge", getWebappPath(),
-Long.valueOf(len)));
+throw new ArrayIndexOutOfBoundsException(
+sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
 }
 
 if (len < 0) {
@@ -202,8 +200,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 readCerts = true;
 } catch (IOException ioe) {
 if (getLog().isDebugEnabled()) {
-getLog().debug(sm.getString("abstractResource.getContentFail",
-getWebappPath()), ioe);
+getLog().debug(sm.getString("abstractResource.getContentFail", 
getWebappPath()), ioe);
 }
 // Don't return corrupted content
 return null;
@@ -238,10 +235,9 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 protected abstract JarInputStreamWrapper 

[tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 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 2df2a763a2ee91c7134d51d8421203dc8e53031f
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:22:01 2023 +

LongAdder is a better choice for statistics collection
---
 java/org/apache/catalina/webresources/Cache.java | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/webresources/Cache.java 
b/java/org/apache/catalina/webresources/Cache.java
index 949117f521..4893a289cb 100644
--- a/java/org/apache/catalina/webresources/Cache.java
+++ b/java/org/apache/catalina/webresources/Cache.java
@@ -22,6 +22,7 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.LongAdder;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot.CacheStrategy;
@@ -48,8 +49,8 @@ public class Cache {
 private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
 private CacheStrategy cacheStrategy;
 
-private AtomicLong lookupCount = new AtomicLong(0);
-private AtomicLong hitCount = new AtomicLong(0);
+private LongAdder lookupCount = new LongAdder();
+private LongAdder hitCount = new LongAdder();
 
 private final ConcurrentMap resourceCache = new 
ConcurrentHashMap<>();
 
@@ -70,7 +71,7 @@ public class Cache {
 }
 }
 
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 CachedResource cacheEntry = resourceCache.get(path);
 
@@ -138,14 +139,14 @@ public class Cache {
 cacheEntry.validateResource(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry;
 }
 
 protected WebResource[] getResources(String path, boolean 
useClassLoaderResources) {
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 // Don't call noCache(path) since the class loader only caches
 // individual resources. Therefore, always cache collections here
@@ -196,7 +197,7 @@ public class Cache {
 cacheEntry.validateResources(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry.getWebResources();
@@ -291,11 +292,11 @@ public class Cache {
 }
 
 public long getLookupCount() {
-return lookupCount.get();
+return lookupCount.sum();
 }
 
 public long getHitCount() {
-return hitCount.get();
+return hitCount.sum();
 }
 
 public void setObjectMaxSize(int objectMaxSize) {


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



[tomcat] 01/02: Code cleanup (format). No functional change.

2023-01-24 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 8b8fada54056aee4c63fd27339fea47a2062b883
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:20:36 2023 +

Code cleanup (format). No functional change.
---
 .../webresources/AbstractArchiveResource.java  |  26 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  11 +-
 java/org/apache/catalina/webresources/Cache.java   |  42 +++
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   6 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 26 files changed, 290 insertions(+), 451 deletions(-)

diff --git a/java/org/apache/catalina/webresources/AbstractArchiveResource.java 
b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
index 03009670f8..aafc40f790 100644
--- a/java/org/apache/catalina/webresources/AbstractArchiveResource.java
+++ b/java/org/apache/catalina/webresources/AbstractArchiveResource.java
@@ -41,13 +41,13 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 
 
 @Deprecated
-protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath,
-String baseUrl, JarEntry jarEntry, @SuppressWarnings("unused") 
String codeBaseUrl) {
+protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath, String baseUrl,
+JarEntry jarEntry, @SuppressWarnings("unused") String codeBaseUrl) 
{
 this(archiveResourceSet, webAppPath, baseUrl, jarEntry);
 }
 
-protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath,
-String baseUrl, JarEntry jarEntry) {
+protected AbstractArchiveResource(AbstractArchiveResourceSet 
archiveResourceSet, String webAppPath, String baseUrl,
+JarEntry jarEntry) {
 super(archiveResourceSet.getRoot(), webAppPath);
 this.archiveResourceSet = archiveResourceSet;
 this.baseUrl = baseUrl;
@@ -58,8 +58,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 resourceName = resourceName.substring(0, resourceName.length() - 
1);
 }
 String internalPath = archiveResourceSet.getInternalPath();
-if (internalPath.length() > 0 && resourceName.equals(
-internalPath.subSequence(1, internalPath.length( {
+if (internalPath.length() > 0 && 
resourceName.equals(internalPath.subSequence(1, internalPath.length( {
 name = "";
 } else {
 int index = resourceName.lastIndexOf('/');
@@ -164,9 +163,8 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 
 if (len > Integer.MAX_VALUE) {
 // Can't create an array that big
-throw new ArrayIndexOutOfBoundsException(sm.getString(
-"abstractResource.getContentTooLarge", getWebappPath(),
-Long.valueOf(len)));
+throw new ArrayIndexOutOfBoundsException(
+sm.getString("abstractResource.getContentTooLarge", 
getWebappPath(), Long.valueOf(len)));
 }
 
 if (len < 0) {
@@ -195,8 +193,7 @@ public abstract class AbstractArchiveResource extends 
AbstractResource {
 readCerts = true;
 } catch (IOException ioe) {
 if (getLog().isDebugEnabled()) {
-getLog().debug(sm.getString("abstractResource.getContentFail",
-getWebappPath()), ioe);
+

[tomcat] 02/02: LongAdder is a better choice for statistics collection

2023-01-24 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 2acb530d27f87ac30acc76f54cfa13fe3f21fa4e
Author: Mark Thomas 
AuthorDate: Tue Jan 24 12:22:01 2023 +

LongAdder is a better choice for statistics collection
---
 java/org/apache/catalina/webresources/Cache.java | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/webresources/Cache.java 
b/java/org/apache/catalina/webresources/Cache.java
index 949117f521..4893a289cb 100644
--- a/java/org/apache/catalina/webresources/Cache.java
+++ b/java/org/apache/catalina/webresources/Cache.java
@@ -22,6 +22,7 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.LongAdder;
 
 import org.apache.catalina.WebResource;
 import org.apache.catalina.WebResourceRoot.CacheStrategy;
@@ -48,8 +49,8 @@ public class Cache {
 private int objectMaxSize = (int) maxSize / OBJECT_MAX_SIZE_FACTOR;
 private CacheStrategy cacheStrategy;
 
-private AtomicLong lookupCount = new AtomicLong(0);
-private AtomicLong hitCount = new AtomicLong(0);
+private LongAdder lookupCount = new LongAdder();
+private LongAdder hitCount = new LongAdder();
 
 private final ConcurrentMap resourceCache = new 
ConcurrentHashMap<>();
 
@@ -70,7 +71,7 @@ public class Cache {
 }
 }
 
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 CachedResource cacheEntry = resourceCache.get(path);
 
@@ -138,14 +139,14 @@ public class Cache {
 cacheEntry.validateResource(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry;
 }
 
 protected WebResource[] getResources(String path, boolean 
useClassLoaderResources) {
-lookupCount.incrementAndGet();
+lookupCount.increment();
 
 // Don't call noCache(path) since the class loader only caches
 // individual resources. Therefore, always cache collections here
@@ -196,7 +197,7 @@ public class Cache {
 cacheEntry.validateResources(useClassLoaderResources);
 }
 } else {
-hitCount.incrementAndGet();
+hitCount.increment();
 }
 
 return cacheEntry.getWebResources();
@@ -291,11 +292,11 @@ public class Cache {
 }
 
 public long getLookupCount() {
-return lookupCount.get();
+return lookupCount.sum();
 }
 
 public long getHitCount() {
-return hitCount.get();
+return hitCount.sum();
 }
 
 public void setObjectMaxSize(int objectMaxSize) {


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



[tomcat] branch main updated (a012d122e7 -> 2acb530d27)

2023-01-24 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 a012d122e7 Review all uses of LinkedHashMap#removeEldestEntry
 new 8b8fada540 Code cleanup (format). No functional change.
 new 2acb530d27 LongAdder is a better choice for statistics collection

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:
 .../webresources/AbstractArchiveResource.java  |  26 ++--
 .../webresources/AbstractArchiveResourceSet.java   |  73 +--
 .../webresources/AbstractFileResourceSet.java  |  21 ++--
 .../catalina/webresources/AbstractResource.java|   3 +-
 .../catalina/webresources/AbstractResourceSet.java |   8 +-
 .../AbstractSingleArchiveResource.java |   4 +-
 .../AbstractSingleArchiveResourceSet.java  |  11 +-
 java/org/apache/catalina/webresources/Cache.java   |  59 -
 .../catalina/webresources/CachedResource.java  |  63 --
 .../webresources/ClasspathURLStreamHandler.java|   3 +-
 .../catalina/webresources/DirResourceSet.java  |  45 +++
 .../catalina/webresources/EmptyResourceSet.java|  10 +-
 .../catalina/webresources/ExtractingRoot.java  |  15 +--
 .../apache/catalina/webresources/FileResource.java |  32 ++---
 .../catalina/webresources/FileResourceSet.java |  38 +++---
 .../apache/catalina/webresources/JarContents.java  |  37 +++---
 .../apache/catalina/webresources/JarResource.java  |   7 +-
 .../catalina/webresources/JarResourceRoot.java |   6 +-
 .../catalina/webresources/JarResourceSet.java  |  33 ++---
 .../catalina/webresources/JarWarResource.java  |  16 +--
 .../catalina/webresources/JarWarResourceSet.java   |  69 ---
 .../apache/catalina/webresources/StandardRoot.java | 136 -
 .../webresources/TomcatJarInputStream.java |   5 +-
 .../catalina/webresources/VirtualResource.java |   3 +-
 .../apache/catalina/webresources/WarResource.java  |  10 +-
 .../catalina/webresources/WarResourceSet.java  |  25 ++--
 26 files changed, 299 insertions(+), 459 deletions(-)


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



[tomcat] 05/07: Code cleanup (format). No functional change.

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit ee5ea89617c2f5f8e1c55e8538adb892b4f016e3
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:19:04 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/juli/AsyncFileHandler.java  |  57 --
 java/org/apache/juli/ClassLoaderLogManager.java | 120 
 java/org/apache/juli/DateFormatCache.java   |  59 +-
 java/org/apache/juli/FileHandler.java   | 141 ++--
 java/org/apache/juli/JdkLoggerFormatter.java|  80 --
 java/org/apache/juli/OneLineFormatter.java  |  43 +++-
 java/org/apache/juli/VerbatimFormatter.java |   8 +-
 java/org/apache/juli/WebappProperties.java  |  38 +++
 8 files changed, 245 insertions(+), 301 deletions(-)

diff --git a/java/org/apache/juli/AsyncFileHandler.java 
b/java/org/apache/juli/AsyncFileHandler.java
index 0d74079ec9..20b08942cb 100644
--- a/java/org/apache/juli/AsyncFileHandler.java
+++ b/java/org/apache/juli/AsyncFileHandler.java
@@ -26,42 +26,37 @@ import java.util.logging.LogRecord;
 
 /**
  * A {@link FileHandler} implementation that uses a queue of log entries.
- *
- * Configuration properties are inherited from the {@link FileHandler}
- * class. This class does not add its own configuration properties for the
- * logging configuration, but relies on the following system properties
- * instead:
- *
+ * 
+ * Configuration properties are inherited from the {@link FileHandler} class. 
This class does not add its own
+ * configuration properties for the logging configuration, but relies on the 
following system properties instead:
+ * 
  * 
- *   org.apache.juli.AsyncOverflowDropType
- *Default value: 1
- *   org.apache.juli.AsyncMaxRecordCount
- *Default value: 1
+ * org.apache.juli.AsyncOverflowDropType Default value: 
1
+ * org.apache.juli.AsyncMaxRecordCount Default value: 
1
  * 
- *
- * See the System Properties page in the configuration reference of 
Tomcat.
+ * 
+ * See the System Properties page in the configuration reference of Tomcat.
+ * 
  */
 public class AsyncFileHandler extends FileHandler {
 
 static final String THREAD_PREFIX = "AsyncFileHandlerWriter-";
 
-public static final int OVERFLOW_DROP_LAST= 1;
-public static final int OVERFLOW_DROP_FIRST   = 2;
-public static final int OVERFLOW_DROP_FLUSH   = 3;
+public static final int OVERFLOW_DROP_LAST = 1;
+public static final int OVERFLOW_DROP_FIRST = 2;
+public static final int OVERFLOW_DROP_FLUSH = 3;
 public static final int OVERFLOW_DROP_CURRENT = 4;
 
 public static final int DEFAULT_OVERFLOW_DROP_TYPE = 1;
-public static final int DEFAULT_MAX_RECORDS= 1;
+public static final int DEFAULT_MAX_RECORDS = 1;
 
 public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncOverflowDropType",
-   Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
-public static final int MAX_RECORDS = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncMaxRecordCount",
-   Integer.toString(DEFAULT_MAX_RECORDS)));
+System.getProperty("org.apache.juli.AsyncOverflowDropType", 
Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
+public static final int MAX_RECORDS = Integer
+
.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount", 
Integer.toString(DEFAULT_MAX_RECORDS)));
 
-private static final LoggerExecutorService LOGGER_SERVICE =
-new LoggerExecutorService(OVERFLOW_DROP_TYPE, MAX_RECORDS);
+private static final LoggerExecutorService LOGGER_SERVICE = new 
LoggerExecutorService(OVERFLOW_DROP_TYPE,
+MAX_RECORDS);
 
 private final Object closeLock = new Object();
 protected volatile boolean closed = false;
@@ -79,8 +74,7 @@ public class AsyncFileHandler extends FileHandler {
 this(directory, prefix, suffix, maxDays, LOGGER_SERVICE);
 }
 
-AsyncFileHandler(String directory, String prefix, String suffix, int 
maxDays,
-LoggerExecutorService loggerService) {
+AsyncFileHandler(String directory, String prefix, String suffix, int 
maxDays, LoggerExecutorService loggerService) {
 super(directory, prefix, suffix, maxDays);
 this.loggerService = loggerService;
 open();
@@ -129,9 +123,8 @@ public class AsyncFileHandler extends FileHandler {
 @Override
 public void run() {
 /*
- * During Tomcat shutdown, the Handlers are closed before the
- * executor queue is flushed therefore the closed flag is
- * ignored if the executor is shutting down.
+ * During Tomcat shutdown, the Handlers are closed before the 

[tomcat] branch 8.5.x updated (9d205a71af -> 3840fd3ecf)

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from 9d205a71af Add initial Eclipse format configurations
 new 6d4f2c20c9 Code cleanup (format). No functional change.
 new 820ee010aa Code cleanup (format). No functional change.
 new c513a5ad77 Code cleanup (format). No functional change.
 new 7cabce9b2b Code cleanup (format). No functional change.
 new ee5ea89617 Code cleanup (format). No functional change.
 new a5fed4938b Code cleanup (format). No functional change.
 new 3840fd3ecf Review all uses of LinkedHashMap#removeEldestEntry

The 7 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/authenticator/AuthenticatorBase.java  | 453 +--
 .../catalina/authenticator/BasicAuthenticator.java |  87 +--
 .../apache/catalina/authenticator/Constants.java   |  26 +-
 .../authenticator/DigestAuthenticator.java | 138 ++--
 .../catalina/authenticator/FormAuthenticator.java  | 144 ++--
 .../authenticator/NonLoginAuthenticator.java   |  68 +-
 .../catalina/authenticator/SSLAuthenticator.java   |  44 +-
 .../catalina/authenticator/SavedRequest.java   |  19 +-
 .../catalina/authenticator/SingleSignOn.java   | 257 +++
 .../catalina/authenticator/SingleSignOnEntry.java  |  82 +-
 .../authenticator/SingleSignOnSessionKey.java  |  17 +-
 .../authenticator/SpnegoAuthenticator.java | 115 ++-
 .../catalina/filters/AddDefaultCharsetFilter.java  |  34 +-
 java/org/apache/catalina/filters/Constants.java|  37 +-
 java/org/apache/catalina/filters/CorsFilter.java   | 556 ++
 .../catalina/filters/CsrfPreventionFilter.java | 129 ++--
 .../catalina/filters/CsrfPreventionFilterBase.java |  34 +-
 .../org/apache/catalina/filters/ExpiresFilter.java | 438 +--
 .../catalina/filters/FailedRequestFilter.java  |  25 +-
 java/org/apache/catalina/filters/FilterBase.java   |  30 +-
 .../catalina/filters/HttpHeaderSecurityFilter.java |  15 +-
 .../apache/catalina/filters/RemoteAddrFilter.java  |  17 +-
 .../apache/catalina/filters/RemoteCIDRFilter.java  |  27 +-
 .../apache/catalina/filters/RemoteHostFilter.java  |  16 +-
 .../apache/catalina/filters/RemoteIpFilter.java| 261 ---
 .../catalina/filters/RequestDumperFilter.java  |  67 +-
 .../org/apache/catalina/filters/RequestFilter.java |  91 +--
 .../catalina/filters/RestCsrfPreventionFilter.java |  69 +-
 .../catalina/filters/SessionInitializerFilter.java |  23 +-
 .../filters/SetCharacterEncodingFilter.java|  88 ++-
 .../apache/catalina/filters/WebdavFixFilter.java   |  58 +-
 java/org/apache/catalina/realm/CombinedRealm.java  | 159 ++--
 .../org/apache/catalina/realm/DataSourceRealm.java | 103 ++-
 .../realm/DigestCredentialHandlerBase.java | 147 ++--
 .../apache/catalina/realm/GenericPrincipal.java| 103 ++-
 .../apache/catalina/realm/JAASCallbackHandler.java | 110 ++-
 .../catalina/realm/JAASMemoryLoginModule.java  | 116 ++-
 java/org/apache/catalina/realm/JAASRealm.java  | 338 
 java/org/apache/catalina/realm/JDBCRealm.java  | 169 ++--
 java/org/apache/catalina/realm/JNDIRealm.java  | 855 +
 java/org/apache/catalina/realm/LockOutRealm.java   | 165 ++--
 java/org/apache/catalina/realm/MemoryRealm.java|  53 +-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  31 +-
 .../realm/MessageDigestCredentialHandler.java  |  34 +-
 .../catalina/realm/NestedCredentialHandler.java|   7 +-
 java/org/apache/catalina/realm/NullRealm.java  |   5 +-
 java/org/apache/catalina/realm/RealmBase.java  | 522 ++---
 .../apache/catalina/realm/UserDatabaseRealm.java   |  47 +-
 .../catalina/realm/X509SubjectDnRetriever.java |   3 +-
 .../catalina/realm/X509UsernameRetriever.java  |   4 +-
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  47 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 111 ++-
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +-
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 +-
 java/org/apache/juli/AsyncFileHandler.java |  57 +-
 java/org/apache/juli/ClassLoaderLogManager.java| 120 ++-
 java/org/apache/juli/DateFormatCache.java  |  59 +-
 java/org/apache/juli/FileHandler.java  | 141 ++--
 java/org/apache/juli/JdkLoggerFormatter.java   |  80 +-
 java/org/apache/juli/OneLineFormatter.java |  47 +-
 java/org/apache/juli/VerbatimFormatter.java|   8 +-
 java/org/apache/juli/WebappProperties.java 

[tomcat] 07/07: Review all uses of LinkedHashMap#removeEldestEntry

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 3840fd3ecf648ddec3f862c9e43a0cd3003175c4
Author: Mark Thomas 
AuthorDate: Tue Jan 24 10:16:41 2023 +

Review all uses of LinkedHashMap#removeEldestEntry

Ensure FIFO or LRU is used as appropriate.
Add/expand existing comments to make intentions clearer.
Don't override default load factor to retain size/performance balance.
---
 java/org/apache/catalina/authenticator/DigestAuthenticator.java | 4 
 java/org/apache/catalina/filters/CsrfPreventionFilter.java  | 6 ++
 java/org/apache/catalina/realm/LockOutRealm.java| 7 +--
 java/org/apache/catalina/tribes/util/StringManager.java | 9 -
 java/org/apache/juli/OneLineFormatter.java  | 4 
 java/org/apache/tomcat/util/res/StringManager.java  | 9 -
 6 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index e43fabd244..5588119787 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -376,6 +376,10 @@ public class DigestAuthenticator extends AuthenticatorBase 
{
 setOpaque(sessionIdGenerator.generateSessionId());
 }
 
+/*
+ * This is a FIFO cache as using an older nonce should not delay its 
removal from the cache in favour of more
+ * recent values.
+ */
 nonces = new LinkedHashMap() {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index 5568c4cc6d..9c2d7549c1 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -343,6 +343,12 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
 }
 
 
+/**
+ * Despite its name, this is a FIFO cache not an LRU cache. Using an older 
nonce should not delay its removal from
+ * the cache in favour of more recent values.
+ *
+ * @param  The type held by this cache.
+ */
 protected static class LruCache implements NonceCache {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java 
b/java/org/apache/catalina/realm/LockOutRealm.java
index 296aac7915..fe220e6c7b 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -86,8 +86,11 @@ public class LockOutRealm extends CombinedRealm {
  */
 @Override
 protected synchronized void startInternal() throws LifecycleException {
-// Configure the list of failed users to delete the oldest entry once 
it
-// exceeds the specified size
+/*
+ * Configure the list of failed users to delete the oldest entry once 
it exceeds the specified size. This is an
+ * LRU cache so if the cache size is exceeded the users who most 
recently failed authentication will be
+ * retained.
+ */
 failedUsers = new LinkedHashMap(cacheSize, 0.75f, 
true) {
 private static final long serialVersionUID = 1L;
 
diff --git a/java/org/apache/catalina/tribes/util/StringManager.java 
b/java/org/apache/catalina/tribes/util/StringManager.java
index fc4b8b5b21..4e349233bd 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -213,12 +213,11 @@ public class StringManager {
 Map map = managers.get(packageName);
 if (map == null) {
 /*
- * Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds
- * capacity. Therefore keep size at or below capacity. 
removeEldestEntry() executes after insertion
- * therefore the test for removal needs to use one less than the 
maximum desired size
- *
+ * Don't want the HashMap size to exceed LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds capacity.
+ * Therefore keep size at or below capacity. removeEldestEntry() 
executes after insertion therefore the test
+ * for removal needs to use one less than the maximum desired 
size. Note this is an LRU cache.
  */
-map = new LinkedHashMap(LOCALE_CACHE_SIZE, 
1, true) {
+map = new LinkedHashMap(LOCALE_CACHE_SIZE, 
0.75f, true) {
 private static final long serialVersionUID = 1L;
 
 @Override
diff --git a/java/org/apache/juli/OneLineFormatter.java 

[tomcat] 04/07: Code cleanup (format). No functional change.

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 7cabce9b2bafa1726edf1669646623185f6a5a6b
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:18:50 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  47 +
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 110 +
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +--
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 ---
 7 files changed, 124 insertions(+), 138 deletions(-)

diff --git a/java/org/apache/catalina/tribes/util/Arrays.java 
b/java/org/apache/catalina/tribes/util/Arrays.java
index 6813aacc24..bb6c1a5da1 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -31,38 +31,38 @@ public class Arrays {
 protected static final StringManager sm = 
StringManager.getManager(Arrays.class);
 
 public static boolean contains(byte[] source, int srcoffset, byte[] key, 
int keyoffset, int length) {
-if ( srcoffset < 0 || srcoffset >= source.length) {
+if (srcoffset < 0 || srcoffset >= source.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.srcoffset.outOfBounds"));
 }
-if ( keyoffset < 0 || keyoffset >= key.length) {
+if (keyoffset < 0 || keyoffset >= key.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.keyoffset.outOfBounds"));
 }
-if ( length > (key.length-keyoffset) ) {
+if (length > (key.length - keyoffset)) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.length.outOfBounds"));
 }
-//we don't have enough data to validate it
-if ( length > (source.length-srcoffset) ) {
+// we don't have enough data to validate it
+if (length > (source.length - srcoffset)) {
 return false;
 }
 boolean match = true;
 int pos = keyoffset;
-for ( int i=srcoffset; match && i 0 ) {
+if (data != null && length > 0) {
 int i = offset;
 if (unsigned) {
 buf.append(data[i++] & 0xff);
@@ -81,12 +81,12 @@ public class Arrays {
 }
 
 public static String toString(Object[] data) {
-return toString(data,0,data!=null?data.length:0);
+return toString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toString(Object[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++]);
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i]);
@@ -97,12 +97,12 @@ public class Arrays {
 }
 
 public static String toNameString(Member[] data) {
-return toNameString(data,0,data!=null?data.length:0);
+return toNameString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toNameString(Member[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++].getName());
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i].getName());
@@ -129,13 +129,13 @@ public class Arrays {
 }
 
 public static boolean equals(byte[] o1, byte[] o2) {
-return java.util.Arrays.equals(o1,o2);
+return java.util.Arrays.equals(o1, o2);
 }
 
 public static boolean equals(Object[] o1, Object[] o2) {
 boolean result = o1.length == o2.length;
-if ( result ) {
-for (int i=0; i= members.length ) {
-idx = ((members.length>0)?0:-1);
+int idx = indexOf(member, members) + 1;
+if (idx >= members.length) {
+idx = ((members.length > 0) ? 0 : -1);
 }
 
 return idx;
@@ -227,15 +227,15 @@ public class Arrays {
 }
 
 public static byte[] fromString(String value) {
-if ( value == null ) {
+if (value == null) {
 return null;
 }
-if ( !value.startsWith("{") ) {
+if (!value.startsWith("{")) {
 throw new 
RuntimeException(sm.getString("arrays.malformed.arrays"));
 }
-StringTokenizer t = new StringTokenizer(value,"{,}",false);
+StringTokenizer t = new StringTokenizer(value, "{,}", false);
 byte[] result = new byte[t.countTokens()];
-for (int i=0; i 

[tomcat] 06/07: Code cleanup (format). No functional change.

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit a5fed4938b0a6e000cf94a86553de41021794ddc
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:19:22 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/tomcat/util/res/StringManager.java | 121 +
 1 file changed, 50 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/tomcat/util/res/StringManager.java 
b/java/org/apache/tomcat/util/res/StringManager.java
index 91b39b48d7..094c93727a 100644
--- a/java/org/apache/tomcat/util/res/StringManager.java
+++ b/java/org/apache/tomcat/util/res/StringManager.java
@@ -26,27 +26,22 @@ import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 /**
- * An internationalization / localization helper class which reduces
- * the bother of handling ResourceBundles and takes care of the
- * common cases of message formatting which otherwise require the
- * creation of Object arrays and such.
- *
- * The StringManager operates on a package basis. One StringManager
- * per package can be created and accessed via the getManager method
- * call.
- *
- * The StringManager will look for a ResourceBundle named by
- * the package name given plus the suffix of "LocalStrings". In
- * practice, this means that the localized information will be contained
- * in a LocalStrings.properties file located in the package
- * directory of the class path.
- *
- * Please see the documentation for java.util.ResourceBundle for
- * more information.
+ * An internationalization / localization helper class which reduces the 
bother of handling ResourceBundles and takes
+ * care of the common cases of message formatting which otherwise require the 
creation of Object arrays and such.
+ * 
+ * The StringManager operates on a package basis. One StringManager per 
package can be created and accessed via the
+ * getManager method call.
+ * 
+ * The StringManager will look for a ResourceBundle named by the package name 
given plus the suffix of "LocalStrings".
+ * In practice, this means that the localized information will be contained in 
a LocalStrings.properties file located in
+ * the package directory of the class path.
+ * 
+ * Please see the documentation for java.util.ResourceBundle for more 
information.
  *
  * @author James Duncan Davidson [dun...@eng.sun.com]
  * @author James Todd [go...@eng.sun.com]
  * @author Mel Martinez [mmarti...@g1440.com]
+ *
  * @see java.util.ResourceBundle
  */
 public class StringManager {
@@ -61,10 +56,8 @@ public class StringManager {
 
 
 /**
- * Creates a new StringManager for a given package. This is a
- * private method and all access to it is arbitrated by the
- * static getManager method call so that only one StringManager
- * per package will be created.
+ * Creates a new StringManager for a given package. This is a private 
method and all access to it is arbitrated by
+ * the static getManager method call so that only one StringManager per 
package will be created.
  *
  * @param packageName Name of package to create StringManager for.
  */
@@ -109,18 +102,16 @@ public class StringManager {
 
 
 /**
- * Get a string from the underlying resource bundle or return null if the
- * String is not found.
+ * Get a string from the underlying resource bundle or return null if the 
String is not found.
  *
  * @param key to desired resource String
  *
- * @return resource String matching key from underlying bundle or
- * null if not found.
+ * @return resource String matching key from underlying bundle or 
null if not found.
  *
  * @throws IllegalArgumentException if key is null
  */
 public String getString(String key) {
-if (key == null){
+if (key == null) {
 String msg = "key may not have a null value";
 throw new IllegalArgumentException(msg);
 }
@@ -133,17 +124,17 @@ public class StringManager {
 str = bundle.getString(key);
 }
 } catch (MissingResourceException mre) {
-//bad: shouldn't mask an exception the following way:
-//   str = "[cannot find message associated with key '" + key +
-// "' due to " + mre + "]";
-// because it hides the fact that the String was missing
-// from the calling code.
-//good: could just throw the exception (or wrap it in another)
-//  but that would probably cause much havoc on existing
-//  code.
-//better: consistent with container pattern to
-//  simply return null.  Calling code can then do
-//  a null check.
+// bad: shouldn't mask an exception the following way:
+// str = "[cannot find message associated with 

[tomcat] 07/07: Review all uses of LinkedHashMap#removeEldestEntry

2023-01-24 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 3dab9abcee4fe8675089af8f94ff5c927635cf7e
Author: Mark Thomas 
AuthorDate: Tue Jan 24 10:16:41 2023 +

Review all uses of LinkedHashMap#removeEldestEntry

Ensure FIFO or LRU is used as appropriate.
Add/expand existing comments to make intentions clearer.
Don't override default load factor to retain size/performance balance.
---
 java/org/apache/catalina/authenticator/DigestAuthenticator.java | 4 
 java/org/apache/catalina/filters/CsrfPreventionFilter.java  | 6 ++
 java/org/apache/catalina/realm/LockOutRealm.java| 7 +--
 java/org/apache/catalina/tribes/util/StringManager.java | 9 -
 java/org/apache/juli/OneLineFormatter.java  | 4 
 java/org/apache/tomcat/util/res/StringManager.java  | 9 -
 6 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index e43fabd244..5588119787 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -376,6 +376,10 @@ public class DigestAuthenticator extends AuthenticatorBase 
{
 setOpaque(sessionIdGenerator.generateSessionId());
 }
 
+/*
+ * This is a FIFO cache as using an older nonce should not delay its 
removal from the cache in favour of more
+ * recent values.
+ */
 nonces = new LinkedHashMap() {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index 5568c4cc6d..9c2d7549c1 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -343,6 +343,12 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
 }
 
 
+/**
+ * Despite its name, this is a FIFO cache not an LRU cache. Using an older 
nonce should not delay its removal from
+ * the cache in favour of more recent values.
+ *
+ * @param  The type held by this cache.
+ */
 protected static class LruCache implements NonceCache {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java 
b/java/org/apache/catalina/realm/LockOutRealm.java
index d061fb30cf..7bdee4fab2 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -81,8 +81,11 @@ public class LockOutRealm extends CombinedRealm {
  */
 @Override
 protected synchronized void startInternal() throws LifecycleException {
-// Configure the list of failed users to delete the oldest entry once 
it
-// exceeds the specified size
+/*
+ * Configure the list of failed users to delete the oldest entry once 
it exceeds the specified size. This is an
+ * LRU cache so if the cache size is exceeded the users who most 
recently failed authentication will be
+ * retained.
+ */
 failedUsers = new LinkedHashMap(cacheSize, 0.75f, 
true) {
 private static final long serialVersionUID = 1L;
 
diff --git a/java/org/apache/catalina/tribes/util/StringManager.java 
b/java/org/apache/catalina/tribes/util/StringManager.java
index fc4b8b5b21..4e349233bd 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -213,12 +213,11 @@ public class StringManager {
 Map map = managers.get(packageName);
 if (map == null) {
 /*
- * Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds
- * capacity. Therefore keep size at or below capacity. 
removeEldestEntry() executes after insertion
- * therefore the test for removal needs to use one less than the 
maximum desired size
- *
+ * Don't want the HashMap size to exceed LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds capacity.
+ * Therefore keep size at or below capacity. removeEldestEntry() 
executes after insertion therefore the test
+ * for removal needs to use one less than the maximum desired 
size. Note this is an LRU cache.
  */
-map = new LinkedHashMap(LOCALE_CACHE_SIZE, 
1, true) {
+map = new LinkedHashMap(LOCALE_CACHE_SIZE, 
0.75f, true) {
 private static final long serialVersionUID = 1L;
 
 @Override
diff --git a/java/org/apache/juli/OneLineFormatter.java 

[tomcat] 06/07: Code cleanup (format). No functional change.

2023-01-24 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 2d6f8fc2c090dab230bbdba505ccd4436049f904
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:15:23 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/tomcat/util/res/StringManager.java | 121 +
 1 file changed, 50 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/tomcat/util/res/StringManager.java 
b/java/org/apache/tomcat/util/res/StringManager.java
index 91b39b48d7..094c93727a 100644
--- a/java/org/apache/tomcat/util/res/StringManager.java
+++ b/java/org/apache/tomcat/util/res/StringManager.java
@@ -26,27 +26,22 @@ import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 /**
- * An internationalization / localization helper class which reduces
- * the bother of handling ResourceBundles and takes care of the
- * common cases of message formatting which otherwise require the
- * creation of Object arrays and such.
- *
- * The StringManager operates on a package basis. One StringManager
- * per package can be created and accessed via the getManager method
- * call.
- *
- * The StringManager will look for a ResourceBundle named by
- * the package name given plus the suffix of "LocalStrings". In
- * practice, this means that the localized information will be contained
- * in a LocalStrings.properties file located in the package
- * directory of the class path.
- *
- * Please see the documentation for java.util.ResourceBundle for
- * more information.
+ * An internationalization / localization helper class which reduces the 
bother of handling ResourceBundles and takes
+ * care of the common cases of message formatting which otherwise require the 
creation of Object arrays and such.
+ * 
+ * The StringManager operates on a package basis. One StringManager per 
package can be created and accessed via the
+ * getManager method call.
+ * 
+ * The StringManager will look for a ResourceBundle named by the package name 
given plus the suffix of "LocalStrings".
+ * In practice, this means that the localized information will be contained in 
a LocalStrings.properties file located in
+ * the package directory of the class path.
+ * 
+ * Please see the documentation for java.util.ResourceBundle for more 
information.
  *
  * @author James Duncan Davidson [dun...@eng.sun.com]
  * @author James Todd [go...@eng.sun.com]
  * @author Mel Martinez [mmarti...@g1440.com]
+ *
  * @see java.util.ResourceBundle
  */
 public class StringManager {
@@ -61,10 +56,8 @@ public class StringManager {
 
 
 /**
- * Creates a new StringManager for a given package. This is a
- * private method and all access to it is arbitrated by the
- * static getManager method call so that only one StringManager
- * per package will be created.
+ * Creates a new StringManager for a given package. This is a private 
method and all access to it is arbitrated by
+ * the static getManager method call so that only one StringManager per 
package will be created.
  *
  * @param packageName Name of package to create StringManager for.
  */
@@ -109,18 +102,16 @@ public class StringManager {
 
 
 /**
- * Get a string from the underlying resource bundle or return null if the
- * String is not found.
+ * Get a string from the underlying resource bundle or return null if the 
String is not found.
  *
  * @param key to desired resource String
  *
- * @return resource String matching key from underlying bundle or
- * null if not found.
+ * @return resource String matching key from underlying bundle or 
null if not found.
  *
  * @throws IllegalArgumentException if key is null
  */
 public String getString(String key) {
-if (key == null){
+if (key == null) {
 String msg = "key may not have a null value";
 throw new IllegalArgumentException(msg);
 }
@@ -133,17 +124,17 @@ public class StringManager {
 str = bundle.getString(key);
 }
 } catch (MissingResourceException mre) {
-//bad: shouldn't mask an exception the following way:
-//   str = "[cannot find message associated with key '" + key +
-// "' due to " + mre + "]";
-// because it hides the fact that the String was missing
-// from the calling code.
-//good: could just throw the exception (or wrap it in another)
-//  but that would probably cause much havoc on existing
-//  code.
-//better: consistent with container pattern to
-//  simply return null.  Calling code can then do
-//  a null check.
+// bad: shouldn't mask an exception the following way:
+// str = "[cannot find message associated with 

[tomcat] 05/07: Code cleanup (format). No functional change.

2023-01-24 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 91ca309136533aff96e3323843e2dae29ea4c5d6
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:15:08 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/juli/AsyncFileHandler.java  |  54 +--
 java/org/apache/juli/ClassLoaderLogManager.java | 114 ++--
 java/org/apache/juli/DateFormatCache.java   |  59 ++--
 java/org/apache/juli/FileHandler.java   | 111 ++-
 java/org/apache/juli/JdkLoggerFormatter.java|  80 ++---
 java/org/apache/juli/OneLineFormatter.java  |  50 +--
 java/org/apache/juli/VerbatimFormatter.java |   8 +-
 java/org/apache/juli/WebappProperties.java  |  38 
 8 files changed, 231 insertions(+), 283 deletions(-)

diff --git a/java/org/apache/juli/AsyncFileHandler.java 
b/java/org/apache/juli/AsyncFileHandler.java
index d180dc738b..d2f3b2d919 100644
--- a/java/org/apache/juli/AsyncFileHandler.java
+++ b/java/org/apache/juli/AsyncFileHandler.java
@@ -26,42 +26,37 @@ import java.util.logging.LogRecord;
 
 /**
  * A {@link FileHandler} implementation that uses a queue of log entries.
- *
- * Configuration properties are inherited from the {@link FileHandler}
- * class. This class does not add its own configuration properties for the
- * logging configuration, but relies on the following system properties
- * instead:
- *
+ * 
+ * Configuration properties are inherited from the {@link FileHandler} class. 
This class does not add its own
+ * configuration properties for the logging configuration, but relies on the 
following system properties instead:
+ * 
  * 
- *   org.apache.juli.AsyncOverflowDropType
- *Default value: 1
- *   org.apache.juli.AsyncMaxRecordCount
- *Default value: 1
+ * org.apache.juli.AsyncOverflowDropType Default value: 
1
+ * org.apache.juli.AsyncMaxRecordCount Default value: 
1
  * 
- *
- * See the System Properties page in the configuration reference of 
Tomcat.
+ * 
+ * See the System Properties page in the configuration reference of Tomcat.
+ * 
  */
 public class AsyncFileHandler extends FileHandler {
 
 static final String THREAD_PREFIX = "AsyncFileHandlerWriter-";
 
-public static final int OVERFLOW_DROP_LAST= 1;
-public static final int OVERFLOW_DROP_FIRST   = 2;
-public static final int OVERFLOW_DROP_FLUSH   = 3;
+public static final int OVERFLOW_DROP_LAST = 1;
+public static final int OVERFLOW_DROP_FIRST = 2;
+public static final int OVERFLOW_DROP_FLUSH = 3;
 public static final int OVERFLOW_DROP_CURRENT = 4;
 
 public static final int DEFAULT_OVERFLOW_DROP_TYPE = 1;
-public static final int DEFAULT_MAX_RECORDS= 1;
+public static final int DEFAULT_MAX_RECORDS = 1;
 
 public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncOverflowDropType",
-   Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
-public static final int MAX_RECORDS = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncMaxRecordCount",
-   Integer.toString(DEFAULT_MAX_RECORDS)));
+System.getProperty("org.apache.juli.AsyncOverflowDropType", 
Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
+public static final int MAX_RECORDS = Integer
+
.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount", 
Integer.toString(DEFAULT_MAX_RECORDS)));
 
-private static final LoggerExecutorService LOGGER_SERVICE =
-new LoggerExecutorService(OVERFLOW_DROP_TYPE, MAX_RECORDS);
+private static final LoggerExecutorService LOGGER_SERVICE = new 
LoggerExecutorService(OVERFLOW_DROP_TYPE,
+MAX_RECORDS);
 
 private final Object closeLock = new Object();
 protected volatile boolean closed = false;
@@ -129,9 +124,8 @@ public class AsyncFileHandler extends FileHandler {
 @Override
 public void run() {
 /*
- * During Tomcat shutdown, the Handlers are closed before the
- * executor queue is flushed therefore the closed flag is
- * ignored if the executor is shutting down.
+ * During Tomcat shutdown, the Handlers are closed before the 
executor queue is flushed therefore the
+ * closed flag is ignored if the executor is shutting down.
  */
 if (!closed || loggerService.isTerminating()) {
 publishInternal(record);
@@ -150,11 +144,9 @@ public class AsyncFileHandler extends FileHandler {
 private static final ThreadFactory THREAD_FACTORY = new 
ThreadFactory(THREAD_PREFIX);
 
 /*
- * Implementation note: Use of this count could be extended to
-

[tomcat] 04/07: Code cleanup (format). No functional change.

2023-01-24 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 74c9ebf14f5af2e5a5f202a2f0fd08f30e7479ea
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:14:51 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 110 +
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +--
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 ---
 7 files changed, 122 insertions(+), 136 deletions(-)

diff --git a/java/org/apache/catalina/tribes/util/Arrays.java 
b/java/org/apache/catalina/tribes/util/Arrays.java
index dfe79bd481..9998f6e5d4 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -31,38 +31,38 @@ public class Arrays {
 protected static final StringManager sm = 
StringManager.getManager(Arrays.class);
 
 public static boolean contains(byte[] source, int srcoffset, byte[] key, 
int keyoffset, int length) {
-if ( srcoffset < 0 || srcoffset >= source.length) {
+if (srcoffset < 0 || srcoffset >= source.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.srcoffset.outOfBounds"));
 }
-if ( keyoffset < 0 || keyoffset >= key.length) {
+if (keyoffset < 0 || keyoffset >= key.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.keyoffset.outOfBounds"));
 }
-if ( length > (key.length-keyoffset) ) {
+if (length > (key.length - keyoffset)) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.length.outOfBounds"));
 }
-//we don't have enough data to validate it
-if ( length > (source.length-srcoffset) ) {
+// we don't have enough data to validate it
+if (length > (source.length - srcoffset)) {
 return false;
 }
 boolean match = true;
 int pos = keyoffset;
-for ( int i=srcoffset; match && i 0 ) {
+if (data != null && length > 0) {
 int i = offset;
 if (unsigned) {
 buf.append(data[i++] & 0xff);
@@ -81,12 +81,12 @@ public class Arrays {
 }
 
 public static String toString(Object[] data) {
-return toString(data,0,data!=null?data.length:0);
+return toString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toString(Object[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++]);
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i]);
@@ -97,12 +97,12 @@ public class Arrays {
 }
 
 public static String toNameString(Member[] data) {
-return toNameString(data,0,data!=null?data.length:0);
+return toNameString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toNameString(Member[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++].getName());
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i].getName());
@@ -129,13 +129,13 @@ public class Arrays {
 }
 
 public static boolean equals(byte[] o1, byte[] o2) {
-return java.util.Arrays.equals(o1,o2);
+return java.util.Arrays.equals(o1, o2);
 }
 
 public static boolean equals(Object[] o1, Object[] o2) {
 boolean result = o1.length == o2.length;
-if ( result ) {
-for (int i=0; i= members.length ) {
-idx = ((members.length>0)?0:-1);
+int idx = indexOf(member, members) + 1;
+if (idx >= members.length) {
+idx = ((members.length > 0) ? 0 : -1);
 }
 
 return idx;
@@ -227,15 +227,15 @@ public class Arrays {
 }
 
 public static byte[] fromString(String value) {
-if ( value == null ) {
+if (value == null) {
 return null;
 }
-if ( !value.startsWith("{") ) {
+if (!value.startsWith("{")) {
 throw new 
RuntimeException(sm.getString("arrays.malformed.arrays"));
 }
-StringTokenizer t = new StringTokenizer(value,"{,}",false);
+StringTokenizer t = new StringTokenizer(value, "{,}", false);
 byte[] result = new byte[t.countTokens()];
-for (int i=0; i workQueue, 

[tomcat] branch 9.0.x updated (b922d9c780 -> 3dab9abcee)

2023-01-24 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 b922d9c780 Add initial Eclipse format configurations
 new 636e19f2a3 Code cleanup (format). No functional change.
 new 3c8ee6e86b Code cleanup (format). No functional change.
 new fe204bd18d Code cleanup (format). No functional change.
 new 74c9ebf14f Code cleanup (format). No functional change.
 new 91ca309136 Code cleanup (format). No functional change.
 new 2d6f8fc2c0 Code cleanup (format). No functional change.
 new 3dab9abcee Review all uses of LinkedHashMap#removeEldestEntry

The 7 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/authenticator/AuthenticatorBase.java  | 456 +--
 .../catalina/authenticator/BasicAuthenticator.java |  87 +--
 .../apache/catalina/authenticator/Constants.java   |  26 +-
 .../authenticator/DigestAuthenticator.java | 138 ++--
 .../catalina/authenticator/FormAuthenticator.java  | 144 ++--
 .../authenticator/NonLoginAuthenticator.java   |  68 +-
 .../catalina/authenticator/SSLAuthenticator.java   |  44 +-
 .../catalina/authenticator/SavedRequest.java   |  19 +-
 .../catalina/authenticator/SingleSignOn.java   | 257 +++
 .../catalina/authenticator/SingleSignOnEntry.java  |  82 +-
 .../authenticator/SingleSignOnSessionKey.java  |  17 +-
 .../authenticator/SpnegoAuthenticator.java | 105 +--
 .../catalina/filters/AddDefaultCharsetFilter.java  |  34 +-
 java/org/apache/catalina/filters/Constants.java|  37 +-
 java/org/apache/catalina/filters/CorsFilter.java   | 550 ++---
 .../catalina/filters/CsrfPreventionFilter.java | 129 ++--
 .../catalina/filters/CsrfPreventionFilterBase.java |  34 +-
 .../org/apache/catalina/filters/ExpiresFilter.java | 438 +--
 .../catalina/filters/FailedRequestFilter.java  |  25 +-
 java/org/apache/catalina/filters/FilterBase.java   |  30 +-
 .../catalina/filters/HttpHeaderSecurityFilter.java |  15 +-
 .../apache/catalina/filters/RemoteAddrFilter.java  |  17 +-
 .../apache/catalina/filters/RemoteCIDRFilter.java  |  27 +-
 .../apache/catalina/filters/RemoteHostFilter.java  |  16 +-
 .../apache/catalina/filters/RemoteIpFilter.java| 263 ---
 .../catalina/filters/RequestDumperFilter.java  |  69 +-
 .../org/apache/catalina/filters/RequestFilter.java |  91 +--
 .../catalina/filters/RestCsrfPreventionFilter.java |  71 +-
 .../catalina/filters/SessionInitializerFilter.java |  23 +-
 .../filters/SetCharacterEncodingFilter.java|  88 ++-
 .../apache/catalina/filters/WebdavFixFilter.java   |  58 +-
 .../catalina/realm/AuthenticatedUserRealm.java |  10 +-
 java/org/apache/catalina/realm/CombinedRealm.java  | 155 ++--
 .../org/apache/catalina/realm/DataSourceRealm.java | 102 ++-
 .../realm/DigestCredentialHandlerBase.java | 147 ++--
 .../apache/catalina/realm/GenericPrincipal.java|  99 ++-
 .../apache/catalina/realm/JAASCallbackHandler.java | 110 ++-
 .../catalina/realm/JAASMemoryLoginModule.java  | 116 ++-
 java/org/apache/catalina/realm/JAASRealm.java  | 338 
 java/org/apache/catalina/realm/JDBCRealm.java  | 163 ++--
 java/org/apache/catalina/realm/JNDIRealm.java  | 854 +
 java/org/apache/catalina/realm/LockOutRealm.java   | 165 ++--
 java/org/apache/catalina/realm/MemoryRealm.java|  52 +-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  31 +-
 .../realm/MessageDigestCredentialHandler.java  |  34 +-
 .../catalina/realm/NestedCredentialHandler.java|   7 +-
 java/org/apache/catalina/realm/NullRealm.java  |   5 +-
 java/org/apache/catalina/realm/RealmBase.java  | 504 ++--
 .../apache/catalina/realm/UserDatabaseRealm.java   |  52 +-
 .../catalina/realm/X509SubjectDnRetriever.java |   3 +-
 .../catalina/realm/X509UsernameRetriever.java  |   4 +-
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 111 ++-
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +-
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 +-
 java/org/apache/juli/AsyncFileHandler.java |  54 +-
 java/org/apache/juli/ClassLoaderLogManager.java| 114 ++-
 java/org/apache/juli/DateFormatCache.java  |  59 +-
 java/org/apache/juli/FileHandler.java  | 111 ++-
 java/org/apache/juli/JdkLoggerFormatter.java   |  80 +-
 java/org/apache/juli/OneLineFormatter.java |  54 +-
 java/org/apache/juli/VerbatimFormatter.java   

[tomcat] 07/07: Review all uses of LinkedHashMap#removeEldestEntry

2023-01-24 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 6551d182658269a55ed9f2f9ffd7c0e8a66c6d3d
Author: Mark Thomas 
AuthorDate: Tue Jan 24 10:16:41 2023 +

Review all uses of LinkedHashMap#removeEldestEntry

Ensure FIFO or LRU is used as appropriate.
Add/expand existing comments to make intentions clearer.
Don't override default load factor to retain size/performance balance.
---
 java/org/apache/catalina/authenticator/DigestAuthenticator.java | 4 
 java/org/apache/catalina/filters/CsrfPreventionFilter.java  | 6 ++
 java/org/apache/catalina/realm/LockOutRealm.java| 7 +--
 java/org/apache/catalina/tribes/util/StringManager.java | 9 -
 java/org/apache/juli/OneLineFormatter.java  | 4 
 java/org/apache/tomcat/util/res/StringManager.java  | 9 -
 6 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index 9775705447..9ef3dd8b40 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -376,6 +376,10 @@ public class DigestAuthenticator extends AuthenticatorBase 
{
 setOpaque(sessionIdGenerator.generateSessionId());
 }
 
+/*
+ * This is a FIFO cache as using an older nonce should not delay its 
removal from the cache in favour of more
+ * recent values.
+ */
 nonces = new LinkedHashMap<>() {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index e018d62989..349e755c14 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -331,6 +331,12 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
 }
 
 
+/**
+ * Despite its name, this is a FIFO cache not an LRU cache. Using an older 
nonce should not delay its removal from
+ * the cache in favour of more recent values.
+ *
+ * @param  The type held by this cache.
+ */
 protected static class LruCache implements NonceCache {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java 
b/java/org/apache/catalina/realm/LockOutRealm.java
index ab09da9811..fc79bee747 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -81,8 +81,11 @@ public class LockOutRealm extends CombinedRealm {
  */
 @Override
 protected synchronized void startInternal() throws LifecycleException {
-// Configure the list of failed users to delete the oldest entry once 
it
-// exceeds the specified size
+/*
+ * Configure the list of failed users to delete the oldest entry once 
it exceeds the specified size. This is an
+ * LRU cache so if the cache size is exceeded the users who most 
recently failed authentication will be
+ * retained.
+ */
 failedUsers = new LinkedHashMap<>(cacheSize, 0.75f, true) {
 private static final long serialVersionUID = 1L;
 
diff --git a/java/org/apache/catalina/tribes/util/StringManager.java 
b/java/org/apache/catalina/tribes/util/StringManager.java
index 32a69e6e39..c3096263f7 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -213,12 +213,11 @@ public class StringManager {
 Map map = managers.get(packageName);
 if (map == null) {
 /*
- * Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds
- * capacity. Therefore keep size at or below capacity. 
removeEldestEntry() executes after insertion
- * therefore the test for removal needs to use one less than the 
maximum desired size
- *
+ * Don't want the HashMap size to exceed LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds capacity.
+ * Therefore keep size at or below capacity. removeEldestEntry() 
executes after insertion therefore the test
+ * for removal needs to use one less than the maximum desired 
size. Note this is an LRU cache.
  */
-map = new LinkedHashMap<>(LOCALE_CACHE_SIZE, 1, true) {
+map = new LinkedHashMap<>(LOCALE_CACHE_SIZE, 0.75f, true) {
 private static final long serialVersionUID = 1L;
 
 @Override
diff --git a/java/org/apache/juli/OneLineFormatter.java 

[tomcat] 05/07: Code cleanup (format). No functional change.

2023-01-24 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 5947f318bbbe0f1de77b51e3a23db914ede88dd0
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:10:45 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/juli/AsyncFileHandler.java  |  54 +---
 java/org/apache/juli/ClassLoaderLogManager.java | 112 ++--
 java/org/apache/juli/DateFormatCache.java   |  59 +++--
 java/org/apache/juli/FileHandler.java   | 111 ++-
 java/org/apache/juli/JdkLoggerFormatter.java|  80 ++---
 java/org/apache/juli/OneLineFormatter.java  |  50 +--
 java/org/apache/juli/VerbatimFormatter.java |   8 +-
 java/org/apache/juli/WebappProperties.java  |  38 
 8 files changed, 230 insertions(+), 282 deletions(-)

diff --git a/java/org/apache/juli/AsyncFileHandler.java 
b/java/org/apache/juli/AsyncFileHandler.java
index 03af375e29..7f8b065d61 100644
--- a/java/org/apache/juli/AsyncFileHandler.java
+++ b/java/org/apache/juli/AsyncFileHandler.java
@@ -26,42 +26,37 @@ import java.util.logging.LogRecord;
 
 /**
  * A {@link FileHandler} implementation that uses a queue of log entries.
- *
- * Configuration properties are inherited from the {@link FileHandler}
- * class. This class does not add its own configuration properties for the
- * logging configuration, but relies on the following system properties
- * instead:
- *
+ * 
+ * Configuration properties are inherited from the {@link FileHandler} class. 
This class does not add its own
+ * configuration properties for the logging configuration, but relies on the 
following system properties instead:
+ * 
  * 
- *   org.apache.juli.AsyncOverflowDropType
- *Default value: 1
- *   org.apache.juli.AsyncMaxRecordCount
- *Default value: 1
+ * org.apache.juli.AsyncOverflowDropType Default value: 
1
+ * org.apache.juli.AsyncMaxRecordCount Default value: 
1
  * 
- *
- * See the System Properties page in the configuration reference of 
Tomcat.
+ * 
+ * See the System Properties page in the configuration reference of Tomcat.
+ * 
  */
 public class AsyncFileHandler extends FileHandler {
 
 static final String THREAD_PREFIX = "AsyncFileHandlerWriter-";
 
-public static final int OVERFLOW_DROP_LAST= 1;
-public static final int OVERFLOW_DROP_FIRST   = 2;
-public static final int OVERFLOW_DROP_FLUSH   = 3;
+public static final int OVERFLOW_DROP_LAST = 1;
+public static final int OVERFLOW_DROP_FIRST = 2;
+public static final int OVERFLOW_DROP_FLUSH = 3;
 public static final int OVERFLOW_DROP_CURRENT = 4;
 
 public static final int DEFAULT_OVERFLOW_DROP_TYPE = 1;
-public static final int DEFAULT_MAX_RECORDS= 1;
+public static final int DEFAULT_MAX_RECORDS = 1;
 
 public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncOverflowDropType",
-   Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
-public static final int MAX_RECORDS = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncMaxRecordCount",
-   Integer.toString(DEFAULT_MAX_RECORDS)));
+System.getProperty("org.apache.juli.AsyncOverflowDropType", 
Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
+public static final int MAX_RECORDS = Integer
+
.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount", 
Integer.toString(DEFAULT_MAX_RECORDS)));
 
-private static final LoggerExecutorService LOGGER_SERVICE =
-new LoggerExecutorService(OVERFLOW_DROP_TYPE, MAX_RECORDS);
+private static final LoggerExecutorService LOGGER_SERVICE = new 
LoggerExecutorService(OVERFLOW_DROP_TYPE,
+MAX_RECORDS);
 
 private final Object closeLock = new Object();
 protected volatile boolean closed = false;
@@ -129,9 +124,8 @@ public class AsyncFileHandler extends FileHandler {
 @Override
 public void run() {
 /*
- * During Tomcat shutdown, the Handlers are closed before the
- * executor queue is flushed therefore the closed flag is
- * ignored if the executor is shutting down.
+ * During Tomcat shutdown, the Handlers are closed before the 
executor queue is flushed therefore the
+ * closed flag is ignored if the executor is shutting down.
  */
 if (!closed || loggerService.isTerminating()) {
 publishInternal(record);
@@ -150,11 +144,9 @@ public class AsyncFileHandler extends FileHandler {
 private static final ThreadFactory THREAD_FACTORY = new 
ThreadFactory(THREAD_PREFIX);
 
 /*
- * Implementation note: Use of this count could be extended to
- 

[tomcat] 04/07: Code cleanup (format). No functional change.

2023-01-24 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 256f3df18757488bbfef58e3763b676af3c35334
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:10:27 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +--
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 
 .../apache/catalina/tribes/util/Jre14Compat.java   |   3 +-
 .../org/apache/catalina/tribes/util/JreCompat.java |   8 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 108 +
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +--
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 ---
 9 files changed, 125 insertions(+), 142 deletions(-)

diff --git a/java/org/apache/catalina/tribes/util/Arrays.java 
b/java/org/apache/catalina/tribes/util/Arrays.java
index dfe79bd481..9998f6e5d4 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -31,38 +31,38 @@ public class Arrays {
 protected static final StringManager sm = 
StringManager.getManager(Arrays.class);
 
 public static boolean contains(byte[] source, int srcoffset, byte[] key, 
int keyoffset, int length) {
-if ( srcoffset < 0 || srcoffset >= source.length) {
+if (srcoffset < 0 || srcoffset >= source.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.srcoffset.outOfBounds"));
 }
-if ( keyoffset < 0 || keyoffset >= key.length) {
+if (keyoffset < 0 || keyoffset >= key.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.keyoffset.outOfBounds"));
 }
-if ( length > (key.length-keyoffset) ) {
+if (length > (key.length - keyoffset)) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.length.outOfBounds"));
 }
-//we don't have enough data to validate it
-if ( length > (source.length-srcoffset) ) {
+// we don't have enough data to validate it
+if (length > (source.length - srcoffset)) {
 return false;
 }
 boolean match = true;
 int pos = keyoffset;
-for ( int i=srcoffset; match && i 0 ) {
+if (data != null && length > 0) {
 int i = offset;
 if (unsigned) {
 buf.append(data[i++] & 0xff);
@@ -81,12 +81,12 @@ public class Arrays {
 }
 
 public static String toString(Object[] data) {
-return toString(data,0,data!=null?data.length:0);
+return toString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toString(Object[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++]);
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i]);
@@ -97,12 +97,12 @@ public class Arrays {
 }
 
 public static String toNameString(Member[] data) {
-return toNameString(data,0,data!=null?data.length:0);
+return toNameString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toNameString(Member[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++].getName());
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i].getName());
@@ -129,13 +129,13 @@ public class Arrays {
 }
 
 public static boolean equals(byte[] o1, byte[] o2) {
-return java.util.Arrays.equals(o1,o2);
+return java.util.Arrays.equals(o1, o2);
 }
 
 public static boolean equals(Object[] o1, Object[] o2) {
 boolean result = o1.length == o2.length;
-if ( result ) {
-for (int i=0; i= members.length ) {
-idx = ((members.length>0)?0:-1);
+int idx = indexOf(member, members) + 1;
+if (idx >= members.length) {
+idx = ((members.length > 0) ? 0 : -1);
 }
 
 return idx;
@@ -227,15 +227,15 @@ public class Arrays {
 }
 
 public static byte[] fromString(String value) {
-if ( value == null ) {
+if (value == null) {
 return null;
 }
-if ( !value.startsWith("{") ) {
+if (!value.startsWith("{")) {
 throw new 
RuntimeException(sm.getString("arrays.malformed.arrays"));
 }
-StringTokenizer t = new StringTokenizer(value,"{,}",false);
+StringTokenizer t = new 

[tomcat] 06/07: Code cleanup (format). No functional change.

2023-01-24 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 92ad2363b2fa836d0bc5443272c00507a3fe4573
Author: Mark Thomas 
AuthorDate: Tue Jan 24 11:11:08 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/tomcat/util/res/StringManager.java | 119 +
 1 file changed, 49 insertions(+), 70 deletions(-)

diff --git a/java/org/apache/tomcat/util/res/StringManager.java 
b/java/org/apache/tomcat/util/res/StringManager.java
index ce68dc9827..8abff4dc71 100644
--- a/java/org/apache/tomcat/util/res/StringManager.java
+++ b/java/org/apache/tomcat/util/res/StringManager.java
@@ -26,27 +26,22 @@ import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 /**
- * An internationalization / localization helper class which reduces
- * the bother of handling ResourceBundles and takes care of the
- * common cases of message formatting which otherwise require the
- * creation of Object arrays and such.
- *
- * The StringManager operates on a package basis. One StringManager
- * per package can be created and accessed via the getManager method
- * call.
- *
- * The StringManager will look for a ResourceBundle named by
- * the package name given plus the suffix of "LocalStrings". In
- * practice, this means that the localized information will be contained
- * in a LocalStrings.properties file located in the package
- * directory of the class path.
- *
- * Please see the documentation for java.util.ResourceBundle for
- * more information.
+ * An internationalization / localization helper class which reduces the 
bother of handling ResourceBundles and takes
+ * care of the common cases of message formatting which otherwise require the 
creation of Object arrays and such.
+ * 
+ * The StringManager operates on a package basis. One StringManager per 
package can be created and accessed via the
+ * getManager method call.
+ * 
+ * The StringManager will look for a ResourceBundle named by the package name 
given plus the suffix of "LocalStrings".
+ * In practice, this means that the localized information will be contained in 
a LocalStrings.properties file located in
+ * the package directory of the class path.
+ * 
+ * Please see the documentation for java.util.ResourceBundle for more 
information.
  *
  * @author James Duncan Davidson [dun...@eng.sun.com]
  * @author James Todd [go...@eng.sun.com]
  * @author Mel Martinez [mmarti...@g1440.com]
+ *
  * @see java.util.ResourceBundle
  */
 public class StringManager {
@@ -61,10 +56,8 @@ public class StringManager {
 
 
 /**
- * Creates a new StringManager for a given package. This is a
- * private method and all access to it is arbitrated by the
- * static getManager method call so that only one StringManager
- * per package will be created.
+ * Creates a new StringManager for a given package. This is a private 
method and all access to it is arbitrated by
+ * the static getManager method call so that only one StringManager per 
package will be created.
  *
  * @param packageName Name of package to create StringManager for.
  */
@@ -109,18 +102,16 @@ public class StringManager {
 
 
 /**
- * Get a string from the underlying resource bundle or return null if the
- * String is not found.
+ * Get a string from the underlying resource bundle or return null if the 
String is not found.
  *
  * @param key to desired resource String
  *
- * @return resource String matching key from underlying bundle or
- * null if not found.
+ * @return resource String matching key from underlying bundle or 
null if not found.
  *
  * @throws IllegalArgumentException if key is null
  */
 public String getString(String key) {
-if (key == null){
+if (key == null) {
 String msg = "key may not have a null value";
 throw new IllegalArgumentException(msg);
 }
@@ -133,17 +124,17 @@ public class StringManager {
 str = bundle.getString(key);
 }
 } catch (MissingResourceException mre) {
-//bad: shouldn't mask an exception the following way:
-//   str = "[cannot find message associated with key '" + key +
-// "' due to " + mre + "]";
-// because it hides the fact that the String was missing
-// from the calling code.
-//good: could just throw the exception (or wrap it in another)
-//  but that would probably cause much havoc on existing
-//  code.
-//better: consistent with container pattern to
-//  simply return null.  Calling code can then do
-//  a null check.
+// bad: shouldn't mask an exception the following way:
+// str = "[cannot find message associated with 

[tomcat] branch 10.1.x updated (908c7b2f73 -> 6551d18265)

2023-01-24 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 908c7b2f73 Add initial Eclipse format configurations
 new a943f46772 Code cleanup (format). No functional change.
 new cd433bfe16 Code cleanup (format). No functional change.
 new 9e7b9ff358 Code cleanup (format). No functional change.
 new 256f3df187 Code cleanup (format). No functional change.
 new 5947f318bb Code cleanup (format). No functional change.
 new 92ad2363b2 Code cleanup (format). No functional change.
 new 6551d18265 Review all uses of LinkedHashMap#removeEldestEntry

The 7 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/authenticator/AuthenticatorBase.java  | 456 +--
 .../catalina/authenticator/BasicAuthenticator.java |  75 +-
 .../apache/catalina/authenticator/Constants.java   |  22 +-
 .../authenticator/DigestAuthenticator.java | 138 ++--
 .../catalina/authenticator/FormAuthenticator.java  | 144 ++--
 .../authenticator/NonLoginAuthenticator.java   |  68 +-
 .../catalina/authenticator/SSLAuthenticator.java   |  44 +-
 .../catalina/authenticator/SavedRequest.java   |  19 +-
 .../catalina/authenticator/SingleSignOn.java   | 257 +++
 .../catalina/authenticator/SingleSignOnEntry.java  |  82 +-
 .../authenticator/SingleSignOnSessionKey.java  |  17 +-
 .../authenticator/SpnegoAuthenticator.java | 105 +--
 .../catalina/filters/AddDefaultCharsetFilter.java  |  34 +-
 java/org/apache/catalina/filters/Constants.java|  37 +-
 java/org/apache/catalina/filters/CorsFilter.java   | 542 ++---
 .../catalina/filters/CsrfPreventionFilter.java | 127 ++--
 .../catalina/filters/CsrfPreventionFilterBase.java |  25 +-
 .../org/apache/catalina/filters/ExpiresFilter.java | 428 +--
 .../catalina/filters/FailedRequestFilter.java  |  25 +-
 java/org/apache/catalina/filters/FilterBase.java   |  30 +-
 .../catalina/filters/HttpHeaderSecurityFilter.java |  15 +-
 .../apache/catalina/filters/RemoteAddrFilter.java  |  17 +-
 .../apache/catalina/filters/RemoteCIDRFilter.java  |  27 +-
 .../apache/catalina/filters/RemoteHostFilter.java  |  16 +-
 .../apache/catalina/filters/RemoteIpFilter.java| 263 ---
 .../catalina/filters/RequestDumperFilter.java  |  69 +-
 .../org/apache/catalina/filters/RequestFilter.java |  91 +--
 .../catalina/filters/RestCsrfPreventionFilter.java |  74 +-
 .../catalina/filters/SessionInitializerFilter.java |  23 +-
 .../filters/SetCharacterEncodingFilter.java|  88 ++-
 .../apache/catalina/filters/WebdavFixFilter.java   |  58 +-
 .../catalina/realm/AuthenticatedUserRealm.java |  10 +-
 java/org/apache/catalina/realm/CombinedRealm.java  | 155 ++--
 .../org/apache/catalina/realm/DataSourceRealm.java | 102 ++-
 .../realm/DigestCredentialHandlerBase.java | 147 ++--
 .../apache/catalina/realm/GenericPrincipal.java| 153 ++--
 .../apache/catalina/realm/JAASCallbackHandler.java | 110 ++-
 .../catalina/realm/JAASMemoryLoginModule.java  | 116 ++-
 java/org/apache/catalina/realm/JAASRealm.java  | 338 -
 java/org/apache/catalina/realm/JNDIRealm.java  | 843 +
 java/org/apache/catalina/realm/LockOutRealm.java   | 165 ++--
 java/org/apache/catalina/realm/MemoryRealm.java|  47 +-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  31 +-
 .../realm/MessageDigestCredentialHandler.java  |  34 +-
 .../catalina/realm/NestedCredentialHandler.java|   7 +-
 java/org/apache/catalina/realm/NullRealm.java  |   5 +-
 java/org/apache/catalina/realm/RealmBase.java  | 494 ++--
 .../apache/catalina/realm/UserDatabaseRealm.java   |  52 +-
 .../catalina/realm/X509SubjectDnRetriever.java |   3 +-
 .../catalina/realm/X509UsernameRetriever.java  |   4 +-
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 +-
 .../apache/catalina/tribes/util/Jre14Compat.java   |   3 +-
 .../org/apache/catalina/tribes/util/JreCompat.java |   8 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 111 ++-
 .../catalina/tribes/util/TcclThreadFactory.java|  11 +-
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 +-
 java/org/apache/juli/AsyncFileHandler.java |  54 +-
 java/org/apache/juli/ClassLoaderLogManager.java| 112 ++-
 java/org/apache/juli/DateFormatCache.java  |  59 +-
 java/org/apache/juli/FileHandler.java  | 111 ++-
 java/org/apache/juli/JdkLoggerFormatter.java   |  80 +-
 java/org/apache/juli/OneLineFormatter.java

[tomcat] 07/07: Review all uses of LinkedHashMap#removeEldestEntry

2023-01-24 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 a012d122e7941434281e29bd76113a9755e1cc63
Author: Mark Thomas 
AuthorDate: Tue Jan 24 10:16:41 2023 +

Review all uses of LinkedHashMap#removeEldestEntry

Ensure FIFO or LRU is used as appropriate.
Add/expand existing comments to make intentions clearer.
Don't override default load factor to retain size/performance balance.
---
 java/org/apache/catalina/authenticator/DigestAuthenticator.java | 4 
 java/org/apache/catalina/filters/CsrfPreventionFilter.java  | 6 ++
 java/org/apache/catalina/realm/LockOutRealm.java| 7 +--
 java/org/apache/catalina/tribes/util/StringManager.java | 9 -
 java/org/apache/juli/OneLineFormatter.java  | 4 
 java/org/apache/tomcat/util/res/StringManager.java  | 9 -
 6 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index 9775705447..9ef3dd8b40 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -376,6 +376,10 @@ public class DigestAuthenticator extends AuthenticatorBase 
{
 setOpaque(sessionIdGenerator.generateSessionId());
 }
 
+/*
+ * This is a FIFO cache as using an older nonce should not delay its 
removal from the cache in favour of more
+ * recent values.
+ */
 nonces = new LinkedHashMap<>() {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index e018d62989..349e755c14 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -331,6 +331,12 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
 }
 
 
+/**
+ * Despite its name, this is a FIFO cache not an LRU cache. Using an older 
nonce should not delay its removal from
+ * the cache in favour of more recent values.
+ *
+ * @param  The type held by this cache.
+ */
 protected static class LruCache implements NonceCache {
 
 private static final long serialVersionUID = 1L;
diff --git a/java/org/apache/catalina/realm/LockOutRealm.java 
b/java/org/apache/catalina/realm/LockOutRealm.java
index ab09da9811..fc79bee747 100644
--- a/java/org/apache/catalina/realm/LockOutRealm.java
+++ b/java/org/apache/catalina/realm/LockOutRealm.java
@@ -81,8 +81,11 @@ public class LockOutRealm extends CombinedRealm {
  */
 @Override
 protected synchronized void startInternal() throws LifecycleException {
-// Configure the list of failed users to delete the oldest entry once 
it
-// exceeds the specified size
+/*
+ * Configure the list of failed users to delete the oldest entry once 
it exceeds the specified size. This is an
+ * LRU cache so if the cache size is exceeded the users who most 
recently failed authentication will be
+ * retained.
+ */
 failedUsers = new LinkedHashMap<>(cacheSize, 0.75f, true) {
 private static final long serialVersionUID = 1L;
 
diff --git a/java/org/apache/catalina/tribes/util/StringManager.java 
b/java/org/apache/catalina/tribes/util/StringManager.java
index 32a69e6e39..c3096263f7 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -213,12 +213,11 @@ public class StringManager {
 Map map = managers.get(packageName);
 if (map == null) {
 /*
- * Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds
- * capacity. Therefore keep size at or below capacity. 
removeEldestEntry() executes after insertion
- * therefore the test for removal needs to use one less than the 
maximum desired size
- *
+ * Don't want the HashMap size to exceed LOCALE_CACHE_SIZE. 
Expansion occurs when size() exceeds capacity.
+ * Therefore keep size at or below capacity. removeEldestEntry() 
executes after insertion therefore the test
+ * for removal needs to use one less than the maximum desired 
size. Note this is an LRU cache.
  */
-map = new LinkedHashMap<>(LOCALE_CACHE_SIZE, 1, true) {
+map = new LinkedHashMap<>(LOCALE_CACHE_SIZE, 0.75f, true) {
 private static final long serialVersionUID = 1L;
 
 @Override
diff --git a/java/org/apache/juli/OneLineFormatter.java 

[tomcat] 05/07: Code cleanup (format). No functional change.

2023-01-24 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 52bac033b91a062ce22ae36c47c3a3efa2b0fb53
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:57:35 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/juli/AsyncFileHandler.java  |  54 +---
 java/org/apache/juli/ClassLoaderLogManager.java | 102 +-
 java/org/apache/juli/DateFormatCache.java   |  59 +++--
 java/org/apache/juli/FileHandler.java   | 111 ++--
 java/org/apache/juli/JdkLoggerFormatter.java|  80 +
 java/org/apache/juli/OneLineFormatter.java  |  37 
 java/org/apache/juli/VerbatimFormatter.java |   8 +-
 java/org/apache/juli/WebappProperties.java  |  38 
 8 files changed, 219 insertions(+), 270 deletions(-)

diff --git a/java/org/apache/juli/AsyncFileHandler.java 
b/java/org/apache/juli/AsyncFileHandler.java
index 03af375e29..7f8b065d61 100644
--- a/java/org/apache/juli/AsyncFileHandler.java
+++ b/java/org/apache/juli/AsyncFileHandler.java
@@ -26,42 +26,37 @@ import java.util.logging.LogRecord;
 
 /**
  * A {@link FileHandler} implementation that uses a queue of log entries.
- *
- * Configuration properties are inherited from the {@link FileHandler}
- * class. This class does not add its own configuration properties for the
- * logging configuration, but relies on the following system properties
- * instead:
- *
+ * 
+ * Configuration properties are inherited from the {@link FileHandler} class. 
This class does not add its own
+ * configuration properties for the logging configuration, but relies on the 
following system properties instead:
+ * 
  * 
- *   org.apache.juli.AsyncOverflowDropType
- *Default value: 1
- *   org.apache.juli.AsyncMaxRecordCount
- *Default value: 1
+ * org.apache.juli.AsyncOverflowDropType Default value: 
1
+ * org.apache.juli.AsyncMaxRecordCount Default value: 
1
  * 
- *
- * See the System Properties page in the configuration reference of 
Tomcat.
+ * 
+ * See the System Properties page in the configuration reference of Tomcat.
+ * 
  */
 public class AsyncFileHandler extends FileHandler {
 
 static final String THREAD_PREFIX = "AsyncFileHandlerWriter-";
 
-public static final int OVERFLOW_DROP_LAST= 1;
-public static final int OVERFLOW_DROP_FIRST   = 2;
-public static final int OVERFLOW_DROP_FLUSH   = 3;
+public static final int OVERFLOW_DROP_LAST = 1;
+public static final int OVERFLOW_DROP_FIRST = 2;
+public static final int OVERFLOW_DROP_FLUSH = 3;
 public static final int OVERFLOW_DROP_CURRENT = 4;
 
 public static final int DEFAULT_OVERFLOW_DROP_TYPE = 1;
-public static final int DEFAULT_MAX_RECORDS= 1;
+public static final int DEFAULT_MAX_RECORDS = 1;
 
 public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncOverflowDropType",
-   Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
-public static final int MAX_RECORDS = Integer.parseInt(
-System.getProperty("org.apache.juli.AsyncMaxRecordCount",
-   Integer.toString(DEFAULT_MAX_RECORDS)));
+System.getProperty("org.apache.juli.AsyncOverflowDropType", 
Integer.toString(DEFAULT_OVERFLOW_DROP_TYPE)));
+public static final int MAX_RECORDS = Integer
+
.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount", 
Integer.toString(DEFAULT_MAX_RECORDS)));
 
-private static final LoggerExecutorService LOGGER_SERVICE =
-new LoggerExecutorService(OVERFLOW_DROP_TYPE, MAX_RECORDS);
+private static final LoggerExecutorService LOGGER_SERVICE = new 
LoggerExecutorService(OVERFLOW_DROP_TYPE,
+MAX_RECORDS);
 
 private final Object closeLock = new Object();
 protected volatile boolean closed = false;
@@ -129,9 +124,8 @@ public class AsyncFileHandler extends FileHandler {
 @Override
 public void run() {
 /*
- * During Tomcat shutdown, the Handlers are closed before the
- * executor queue is flushed therefore the closed flag is
- * ignored if the executor is shutting down.
+ * During Tomcat shutdown, the Handlers are closed before the 
executor queue is flushed therefore the
+ * closed flag is ignored if the executor is shutting down.
  */
 if (!closed || loggerService.isTerminating()) {
 publishInternal(record);
@@ -150,11 +144,9 @@ public class AsyncFileHandler extends FileHandler {
 private static final ThreadFactory THREAD_FACTORY = new 
ThreadFactory(THREAD_PREFIX);
 
 /*
- * Implementation note: Use of this count could be extended to
-   

[tomcat] 04/07: Code cleanup (format). No functional change.

2023-01-24 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 ab552fd3fbdfc8091b5338c3129c3472e882d9bf
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:57:08 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +--
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 
 .../apache/catalina/tribes/util/Jre14Compat.java   |   3 +-
 .../org/apache/catalina/tribes/util/JreCompat.java |   8 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 108 +
 .../catalina/tribes/util/TcclThreadFactory.java|   8 +-
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 ---
 9 files changed, 124 insertions(+), 140 deletions(-)

diff --git a/java/org/apache/catalina/tribes/util/Arrays.java 
b/java/org/apache/catalina/tribes/util/Arrays.java
index dfe79bd481..9998f6e5d4 100644
--- a/java/org/apache/catalina/tribes/util/Arrays.java
+++ b/java/org/apache/catalina/tribes/util/Arrays.java
@@ -31,38 +31,38 @@ public class Arrays {
 protected static final StringManager sm = 
StringManager.getManager(Arrays.class);
 
 public static boolean contains(byte[] source, int srcoffset, byte[] key, 
int keyoffset, int length) {
-if ( srcoffset < 0 || srcoffset >= source.length) {
+if (srcoffset < 0 || srcoffset >= source.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.srcoffset.outOfBounds"));
 }
-if ( keyoffset < 0 || keyoffset >= key.length) {
+if (keyoffset < 0 || keyoffset >= key.length) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.keyoffset.outOfBounds"));
 }
-if ( length > (key.length-keyoffset) ) {
+if (length > (key.length - keyoffset)) {
 throw new 
ArrayIndexOutOfBoundsException(sm.getString("arrays.length.outOfBounds"));
 }
-//we don't have enough data to validate it
-if ( length > (source.length-srcoffset) ) {
+// we don't have enough data to validate it
+if (length > (source.length - srcoffset)) {
 return false;
 }
 boolean match = true;
 int pos = keyoffset;
-for ( int i=srcoffset; match && i 0 ) {
+if (data != null && length > 0) {
 int i = offset;
 if (unsigned) {
 buf.append(data[i++] & 0xff);
@@ -81,12 +81,12 @@ public class Arrays {
 }
 
 public static String toString(Object[] data) {
-return toString(data,0,data!=null?data.length:0);
+return toString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toString(Object[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++]);
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i]);
@@ -97,12 +97,12 @@ public class Arrays {
 }
 
 public static String toNameString(Member[] data) {
-return toNameString(data,0,data!=null?data.length:0);
+return toNameString(data, 0, data != null ? data.length : 0);
 }
 
 public static String toNameString(Member[] data, int offset, int length) {
 StringBuilder buf = new StringBuilder("{");
-if ( data != null && length > 0 ) {
+if (data != null && length > 0) {
 buf.append(data[offset++].getName());
 for (int i = offset; i < length; i++) {
 buf.append(", ").append(data[i].getName());
@@ -129,13 +129,13 @@ public class Arrays {
 }
 
 public static boolean equals(byte[] o1, byte[] o2) {
-return java.util.Arrays.equals(o1,o2);
+return java.util.Arrays.equals(o1, o2);
 }
 
 public static boolean equals(Object[] o1, Object[] o2) {
 boolean result = o1.length == o2.length;
-if ( result ) {
-for (int i=0; i= members.length ) {
-idx = ((members.length>0)?0:-1);
+int idx = indexOf(member, members) + 1;
+if (idx >= members.length) {
+idx = ((members.length > 0) ? 0 : -1);
 }
 
 return idx;
@@ -227,15 +227,15 @@ public class Arrays {
 }
 
 public static byte[] fromString(String value) {
-if ( value == null ) {
+if (value == null) {
 return null;
 }
-if ( !value.startsWith("{") ) {
+if (!value.startsWith("{")) {
 throw new 
RuntimeException(sm.getString("arrays.malformed.arrays"));
 }
-StringTokenizer t = new StringTokenizer(value,"{,}",false);
+StringTokenizer t = new 

[tomcat] 06/07: Code cleanup (format). No functional change.

2023-01-24 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 223c0ba457afc62e77edf1fd10d98d61880fac7f
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:58:00 2023 +

Code cleanup (format). No functional change.
---
 java/org/apache/tomcat/util/res/StringManager.java | 119 +
 1 file changed, 49 insertions(+), 70 deletions(-)

diff --git a/java/org/apache/tomcat/util/res/StringManager.java 
b/java/org/apache/tomcat/util/res/StringManager.java
index ce68dc9827..8abff4dc71 100644
--- a/java/org/apache/tomcat/util/res/StringManager.java
+++ b/java/org/apache/tomcat/util/res/StringManager.java
@@ -26,27 +26,22 @@ import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 /**
- * An internationalization / localization helper class which reduces
- * the bother of handling ResourceBundles and takes care of the
- * common cases of message formatting which otherwise require the
- * creation of Object arrays and such.
- *
- * The StringManager operates on a package basis. One StringManager
- * per package can be created and accessed via the getManager method
- * call.
- *
- * The StringManager will look for a ResourceBundle named by
- * the package name given plus the suffix of "LocalStrings". In
- * practice, this means that the localized information will be contained
- * in a LocalStrings.properties file located in the package
- * directory of the class path.
- *
- * Please see the documentation for java.util.ResourceBundle for
- * more information.
+ * An internationalization / localization helper class which reduces the 
bother of handling ResourceBundles and takes
+ * care of the common cases of message formatting which otherwise require the 
creation of Object arrays and such.
+ * 
+ * The StringManager operates on a package basis. One StringManager per 
package can be created and accessed via the
+ * getManager method call.
+ * 
+ * The StringManager will look for a ResourceBundle named by the package name 
given plus the suffix of "LocalStrings".
+ * In practice, this means that the localized information will be contained in 
a LocalStrings.properties file located in
+ * the package directory of the class path.
+ * 
+ * Please see the documentation for java.util.ResourceBundle for more 
information.
  *
  * @author James Duncan Davidson [dun...@eng.sun.com]
  * @author James Todd [go...@eng.sun.com]
  * @author Mel Martinez [mmarti...@g1440.com]
+ *
  * @see java.util.ResourceBundle
  */
 public class StringManager {
@@ -61,10 +56,8 @@ public class StringManager {
 
 
 /**
- * Creates a new StringManager for a given package. This is a
- * private method and all access to it is arbitrated by the
- * static getManager method call so that only one StringManager
- * per package will be created.
+ * Creates a new StringManager for a given package. This is a private 
method and all access to it is arbitrated by
+ * the static getManager method call so that only one StringManager per 
package will be created.
  *
  * @param packageName Name of package to create StringManager for.
  */
@@ -109,18 +102,16 @@ public class StringManager {
 
 
 /**
- * Get a string from the underlying resource bundle or return null if the
- * String is not found.
+ * Get a string from the underlying resource bundle or return null if the 
String is not found.
  *
  * @param key to desired resource String
  *
- * @return resource String matching key from underlying bundle or
- * null if not found.
+ * @return resource String matching key from underlying bundle or 
null if not found.
  *
  * @throws IllegalArgumentException if key is null
  */
 public String getString(String key) {
-if (key == null){
+if (key == null) {
 String msg = "key may not have a null value";
 throw new IllegalArgumentException(msg);
 }
@@ -133,17 +124,17 @@ public class StringManager {
 str = bundle.getString(key);
 }
 } catch (MissingResourceException mre) {
-//bad: shouldn't mask an exception the following way:
-//   str = "[cannot find message associated with key '" + key +
-// "' due to " + mre + "]";
-// because it hides the fact that the String was missing
-// from the calling code.
-//good: could just throw the exception (or wrap it in another)
-//  but that would probably cause much havoc on existing
-//  code.
-//better: consistent with container pattern to
-//  simply return null.  Calling code can then do
-//  a null check.
+// bad: shouldn't mask an exception the following way:
+// str = "[cannot find message associated with key 

[tomcat] branch main updated (b76e18c6e3 -> a012d122e7)

2023-01-24 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 b76e18c6e3 Add initial Eclipse format configurations
 new b6607520d3 Code cleanup (format). No functional change.
 new 045743367b Code cleanup (format). No functional change.
 new 851d88e1b4 Code cleanup (format). No functional change.
 new ab552fd3fb Code cleanup (format). No functional change.
 new 52bac033b9 Code cleanup (format). No functional change.
 new 223c0ba457 Code cleanup (format). No functional change.
 new a012d122e7 Review all uses of LinkedHashMap#removeEldestEntry

The 7 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/authenticator/AuthenticatorBase.java  | 456 +--
 .../catalina/authenticator/BasicAuthenticator.java |  75 +-
 .../apache/catalina/authenticator/Constants.java   |  22 +-
 .../authenticator/DigestAuthenticator.java | 138 ++--
 .../catalina/authenticator/FormAuthenticator.java  | 144 ++--
 .../authenticator/NonLoginAuthenticator.java   |  68 +-
 .../catalina/authenticator/SSLAuthenticator.java   |  44 +-
 .../catalina/authenticator/SavedRequest.java   |  19 +-
 .../catalina/authenticator/SingleSignOn.java   | 257 +++
 .../catalina/authenticator/SingleSignOnEntry.java  |  82 +-
 .../authenticator/SingleSignOnSessionKey.java  |  17 +-
 .../authenticator/SpnegoAuthenticator.java | 105 +--
 .../catalina/filters/AddDefaultCharsetFilter.java  |  34 +-
 java/org/apache/catalina/filters/Constants.java|  37 +-
 java/org/apache/catalina/filters/CorsFilter.java   | 542 ++---
 .../catalina/filters/CsrfPreventionFilter.java | 127 ++--
 .../catalina/filters/CsrfPreventionFilterBase.java |  25 +-
 .../org/apache/catalina/filters/ExpiresFilter.java | 428 +--
 .../catalina/filters/FailedRequestFilter.java  |  25 +-
 java/org/apache/catalina/filters/FilterBase.java   |  30 +-
 .../catalina/filters/HttpHeaderSecurityFilter.java |  15 +-
 .../apache/catalina/filters/RemoteAddrFilter.java  |  17 +-
 .../apache/catalina/filters/RemoteCIDRFilter.java  |  27 +-
 .../apache/catalina/filters/RemoteHostFilter.java  |  16 +-
 .../apache/catalina/filters/RemoteIpFilter.java| 262 ---
 .../catalina/filters/RequestDumperFilter.java  |  69 +-
 .../org/apache/catalina/filters/RequestFilter.java |  91 +--
 .../catalina/filters/RestCsrfPreventionFilter.java |  74 +-
 .../catalina/filters/SessionInitializerFilter.java |  23 +-
 .../filters/SetCharacterEncodingFilter.java|  88 ++-
 .../apache/catalina/filters/WebdavFixFilter.java   |  58 +-
 .../catalina/realm/AuthenticatedUserRealm.java |  10 +-
 java/org/apache/catalina/realm/CombinedRealm.java  | 155 ++--
 .../org/apache/catalina/realm/DataSourceRealm.java | 102 ++-
 .../realm/DigestCredentialHandlerBase.java | 147 ++--
 .../apache/catalina/realm/GenericPrincipal.java|  83 +-
 .../apache/catalina/realm/JAASCallbackHandler.java | 110 ++-
 .../catalina/realm/JAASMemoryLoginModule.java  | 116 ++-
 java/org/apache/catalina/realm/JAASRealm.java  | 338 -
 java/org/apache/catalina/realm/JNDIRealm.java  | 843 +
 java/org/apache/catalina/realm/LockOutRealm.java   | 165 ++--
 java/org/apache/catalina/realm/MemoryRealm.java|  47 +-
 java/org/apache/catalina/realm/MemoryRuleSet.java  |  31 +-
 .../realm/MessageDigestCredentialHandler.java  |  34 +-
 .../catalina/realm/NestedCredentialHandler.java|   7 +-
 java/org/apache/catalina/realm/NullRealm.java  |   5 +-
 java/org/apache/catalina/realm/RealmBase.java  | 494 ++--
 .../apache/catalina/realm/UserDatabaseRealm.java   |  52 +-
 .../catalina/realm/X509SubjectDnRetriever.java |   3 +-
 .../catalina/realm/X509UsernameRetriever.java  |   4 +-
 java/org/apache/catalina/tribes/util/Arrays.java   |  54 +-
 .../catalina/tribes/util/ExceptionUtils.java   |   4 +-
 .../catalina/tribes/util/ExecutorFactory.java  |  43 +-
 .../apache/catalina/tribes/util/Jre14Compat.java   |   3 +-
 .../org/apache/catalina/tribes/util/JreCompat.java |   8 +-
 java/org/apache/catalina/tribes/util/Logs.java |   1 +
 .../apache/catalina/tribes/util/StringManager.java | 111 ++-
 .../catalina/tribes/util/TcclThreadFactory.java|   8 +-
 .../apache/catalina/tribes/util/UUIDGenerator.java |  35 +-
 java/org/apache/juli/AsyncFileHandler.java |  54 +-
 java/org/apache/juli/ClassLoaderLogManager.java| 102 +--
 java/org/apache/juli/DateFormatCache.java  |  59 +-
 java/org/apache/juli/FileHandler.java  | 111 ++-
 java/org/apache/juli/JdkLoggerFormatter.java   |  80 +-
 java/org/apache/juli/OneLineFormatter.java |  

[tomcat] branch 8.5.x updated: Add initial Eclipse format configurations

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 9d205a71af Add initial Eclipse format configurations
9d205a71af is described below

commit 9d205a71afe1979de4ba7da6ec96da341cbdbe2f
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:54:19 2023 +

Add initial Eclipse format configurations
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 144 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 399 ++
 2 files changed, 543 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
new file mode 100644
index 00..f56c6fe4d2
--- /dev/null
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
new file mode 100644
index 00..8327af9885
--- /dev/null
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[tomcat] branch main updated: Add initial Eclipse format configurations

2023-01-24 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new b76e18c6e3 Add initial Eclipse format configurations
b76e18c6e3 is described below

commit b76e18c6e32ce2d448bd35871b55db1404522408
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:54:19 2023 +

Add initial Eclipse format configurations
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 144 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 399 ++
 2 files changed, 543 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
new file mode 100644
index 00..f56c6fe4d2
--- /dev/null
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
new file mode 100644
index 00..8327af9885
--- /dev/null
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  

[tomcat] branch 9.0.x updated: Add initial Eclipse format configurations

2023-01-24 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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new b922d9c780 Add initial Eclipse format configurations
b922d9c780 is described below

commit b922d9c7808d51d9dc399513706d80880da7c587
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:54:19 2023 +

Add initial Eclipse format configurations
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 144 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 399 ++
 2 files changed, 543 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
new file mode 100644
index 00..f56c6fe4d2
--- /dev/null
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
new file mode 100644
index 00..8327af9885
--- /dev/null
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[tomcat] branch 10.1.x updated: Add initial Eclipse format configurations

2023-01-24 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 908c7b2f73 Add initial Eclipse format configurations
908c7b2f73 is described below

commit 908c7b2f739da3d79ef16f48989a04e4e065f15e
Author: Mark Thomas 
AuthorDate: Tue Jan 24 09:54:19 2023 +

Add initial Eclipse format configurations
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 144 
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 399 ++
 2 files changed, 543 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml 
b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
new file mode 100644
index 00..f56c6fe4d2
--- /dev/null
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
new file mode 100644
index 00..8327af9885
--- /dev/null
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+