(tomcat) branch main updated: Security related filter so invalid config should be fatal

2024-10-06 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 9944533256 Security related filter so invalid config should be fatal
9944533256 is described below

commit 9944533256152cd27bfe5109fd721da70df18a32
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:40:21 2024 +0100

Security related filter so invalid config should be fatal
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index efcedca0ff..6a6e9d67a8 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -154,6 +154,12 @@ public class RateLimitFilter extends FilterBase {
 }
 
 
+@Override
+protected boolean isConfigProblemFatal() {
+return true;
+}
+
+
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
 super.init(filterConfig);


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



(tomcat) branch 11.0.x updated: Security related filter so invalid config should be fatal

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new 9757027e82 Security related filter so invalid config should be fatal
9757027e82 is described below

commit 9757027e82f48a44f592fc2b364f9244f4bcab09
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:40:21 2024 +0100

Security related filter so invalid config should be fatal
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index efcedca0ff..6a6e9d67a8 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -154,6 +154,12 @@ public class RateLimitFilter extends FilterBase {
 }
 
 
+@Override
+protected boolean isConfigProblemFatal() {
+return true;
+}
+
+
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
 super.init(filterConfig);


-
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: Security related filter so invalid config should be fatal

2024-10-06 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 91c4c14b95 Security related filter so invalid config should be fatal
91c4c14b95 is described below

commit 91c4c14b95e1a601d5cfb4361790c7d9b6d71199
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:40:21 2024 +0100

Security related filter so invalid config should be fatal
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index efcedca0ff..6a6e9d67a8 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -154,6 +154,12 @@ public class RateLimitFilter extends FilterBase {
 }
 
 
+@Override
+protected boolean isConfigProblemFatal() {
+return true;
+}
+
+
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
 super.init(filterConfig);


-
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: Security related filter so invalid config should be fatal

2024-10-06 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 82cbb1a1f6 Security related filter so invalid config should be fatal
82cbb1a1f6 is described below

commit 82cbb1a1f62bd91632e0f10a1cb6f0d71a523322
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:40:21 2024 +0100

Security related filter so invalid config should be fatal
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 4aaa35bbc3..8b323b136d 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -154,6 +154,12 @@ public class RateLimitFilter extends FilterBase {
 }
 
 
+@Override
+protected boolean isConfigProblemFatal() {
+return true;
+}
+
+
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
 super.init(filterConfig);


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



Re: (tomcat) branch main updated: Allow different implementations for RateLimitFilter

2024-10-06 Thread Mark Thomas

On 06/10/2024 16:09, Igal Sapir wrote:

On Sun, Oct 6, 2024, 06:43 Mark Thomas  wrote:





I think this needs to be renamed for consistency. Generally, we use
className to define the implementing class of the component being
defined. For sub-components, we use something like rateLimiterClassName.
For an example, have a look at the Manager class where we have className
and secureRandomClass.



Sounds good. I was looking for example in the Connector configuration in
server.xml and was unaware of the distinction between a component and a
subcomponent.

Are these rules/conventions documented anywhere?  I'd be happy to start it
if not but I'm not sure where would be a good place.


I don't think they are documented. The wiki is probably the place for that.




Thank you. I will apply the changes above ASAP.


Tx.

FYI, I am currently looking at all of the Filters to see if any 
can/should take advantage of the init-param setting provided by the base 
class. This looks like a candidate for that but I should be able to take 
care of it (just as soon as I figure out what I have done wrong that has 
broken the test).


Mark

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



[Bug 69379] New: HEAD request behavior change does no adhere to RFC 9110

2024-10-06 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69379

Bug ID: 69379
   Summary: HEAD request behavior change does no adhere to RFC
9110
   Product: Tomcat 10
   Version: 10.1.30
  Hardware: PC
OS: Mac OS X 10.1
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: m...@jfrog.com
  Target Milestone: --

The behavioral change is part of the following commit:
https://github.com/apache/tomcat/commit/8b5d5ee1fe8c47e3b80b591fedaddc81e5c51a24#diff-8463f112788fc24163560009476ac4509e4fbfb9d970ea4fc9e57de7bcc3f304

According to: https://www.rfc-editor.org/rfc/rfc9110.html#name-head
```
The server SHOULD send the same header fields in response to a HEAD request as
it would have sent if the request method had been GET. However, a server MAY
omit header fields for which a value is determined only while generating the
content.
...
Such a response to GET might contain Content-Length and Vary fields, for
example, that are not generated within a HEAD response
```

`Content-Length: 0` is now set for a HEAD request, while this header should
either be omitted (if the real content length cannot be calculated) or contain
the actual content length of the resource, the same as if a GET request has
been made.

-- 
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 69379] HEAD request behavior change does no adhere to RFC 9110

2024-10-06 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69379

m...@jfrog.com changed:

   What|Removed |Added

 OS|Mac OS X 10.1   |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: (tomcat) branch main updated: Allow different implementations for RateLimitFilter

2024-10-06 Thread Mark Thomas

On 06/10/2024 06:54, isa...@apache.org wrote:

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

isapir 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 9cc44dcca2 Allow different implementations for RateLimitFilter
9cc44dcca2 is described below

commit 9cc44dcca224ebc5fc4f8c835e3c64f42ab04fc1
Author: Igal Sapir 
AuthorDate: Sat Oct 5 22:54:21 2024 -0700

 Allow different implementations for RateLimitFilter


Overall, big +1 to this sort of extensibility.


+/**
+ * init-param to set a class name that implements RateLimiter
+ */
+public static final String PARAM_CLASS_NAME = "className";


I think this needs to be renamed for consistency. Generally, we use 
className to define the implementing class of the component being 
defined. For sub-components, we use something like rateLimiterClassName. 
For an example, have a look at the Manager class where we have className 
and secureRandomClass.




+try {
+rateLimiter = 
(RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
+} catch (InstantiationException | IllegalAccessException | 
InvocationTargetException |
+ NoSuchMethodException | ClassNotFoundException e) {


You can catch ReflectiveOperationException here and simplify the above.


diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 0d918285c7..ff9bdbf351 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -24,6 +24,7 @@ import jakarta.servlet.FilterChain;
  import jakarta.servlet.FilterConfig;
  import jakarta.servlet.ServletException;
  
+import org.apache.catalina.util.FastRateLimiter;

  import org.junit.Assert;
  import org.junit.Test;
  
@@ -55,9 +56,11 @@ public class TestRateLimitFilter extends TomcatBaseTest {

  MockFilterChain filterChain = new MockFilterChain();
  RateLimitFilter rateLimitFilter = testRateLimitFilter(filterDef, 
root);
  
-int allowedRequests = (int) Math.round(rateLimitFilter.bucketCounter.getRatio() * bucketRequests);

+FastRateLimiter tbc = (FastRateLimiter) rateLimitFilter.rateLimiter;


tbc? Looks like "To Be Confirmed". Maybe expand this name.

It is great you were able to address this so promptly.

Mark

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



Buildbot success in on tomcat-12.0.x

2024-10-06 Thread buildbot
Build status: Build succeeded!
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/120/builds/116
Blamelist: Igal Sapir , Mark Thomas 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch main] 25d80e93a5fc0ef076d0239c8a844c8a24f22c8f


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  shell_6: 0

  compile: 1

  shell_7: 0

  shell_8: 0

  shell_9: 0

  shell_10: 0

  Rsync docs to nightlies.apache.org: 0

  shell_11: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_12: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



Re: (tomcat) branch main updated: Security related filter so invalid config should be fatal

2024-10-06 Thread Mark Thomas

On 06/10/2024 17:40, ma...@apache.org wrote:

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 9944533256 Security related filter so invalid config should be fatal
9944533256 is described below

commit 9944533256152cd27bfe5109fd721da70df18a32
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:40:21 2024 +0100

 Security related filter so invalid config should be fatal


Just a note that this means that as well as failing for invalid values 
for valid init-params (which triggered a failure before) this now 
triggers a failure if an init-param name is mis-typed - i.e. the 
init-param name is not known.


Mark

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



Re: (tomcat) branch 11.0.x updated: Improve HTML output of DefaultServlet

2024-10-06 Thread Michael Osipov
On 2024/10/06 14:18:34 Mark Thomas wrote:
> On 05/10/2024 18:23, micha...@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> > 
> > michaelo pushed a commit to branch 11.0.x
> > in repository https://gitbox.apache.org/repos/asf/tomcat.git
> > 
> > 
> > The following commit(s) were added to refs/heads/11.0.x by this push:
> >   new 4108bf15b5 Improve HTML output of DefaultServlet
> > 4108bf15b5 is described below
> > 
> > commit 4108bf15b54cc82b56736edf07cff4561e8d457c
> > Author: Michael Osipov 
> > AuthorDate: Sat Oct 5 19:18:17 2024 +0200
> > 
> >  Improve HTML output of DefaultServlet
> 
> How does this improve the output? It appears to just be adding 
> (unnecessary) new lines in the HTML source.

I agree with you so far that my wording is bad on the summary. It does not 
change the HTML code, but simply makes line breaks consistent. No functional 
change.

M

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



Re: (tomcat) branch 11.0.x updated: Improve HTML output of DefaultServlet

2024-10-06 Thread Mark Thomas

On 05/10/2024 18:23, micha...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
  new 4108bf15b5 Improve HTML output of DefaultServlet
4108bf15b5 is described below

commit 4108bf15b54cc82b56736edf07cff4561e8d457c
Author: Michael Osipov 
AuthorDate: Sat Oct 5 19:18:17 2024 +0200

 Improve HTML output of DefaultServlet


How does this improve the output? It appears to just be adding 
(unnecessary) new lines in the HTML source.


Mark

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



Re: (tomcat) branch 11.0.x updated: Improve HTML output of DefaultServlet

2024-10-06 Thread Michael Osipov
On 2024/10/06 18:43:27 Mark Thomas wrote:
> On 06/10/2024 19:04, Michael Osipov wrote:
> > On 2024/10/06 14:18:34 Mark Thomas wrote:
> >> On 05/10/2024 18:23, micha...@apache.org wrote:
> >>> This is an automated email from the ASF dual-hosted git repository.
> >>>
> >>> michaelo pushed a commit to branch 11.0.x
> >>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >>>
> >>>
> >>> The following commit(s) were added to refs/heads/11.0.x by this push:
> >>>new 4108bf15b5 Improve HTML output of DefaultServlet
> >>> 4108bf15b5 is described below
> >>>
> >>> commit 4108bf15b54cc82b56736edf07cff4561e8d457c
> >>> Author: Michael Osipov 
> >>> AuthorDate: Sat Oct 5 19:18:17 2024 +0200
> >>>
> >>>   Improve HTML output of DefaultServlet
> >>
> >> How does this improve the output? It appears to just be adding
> >> (unnecessary) new lines in the HTML source.
> > 
> > I agree with you so far that my wording is bad on the summary. It does not 
> > change the HTML code, but simply makes line breaks consistent. No 
> > functional change.
> 
> OK. Not something that is high on my list of priotities but since we are 
> here...
> 
> Should the priority be to make the source clear / readable or should we 
> be aiming to minimise it (remove line breaks, comments etc) for 
> (marginally) better response time. I can see arguments for both.

Both objectives are valid.

> While bandwidth is certainly more plentiful than it was 20 years ago, it 
> still pains me to see any of it wasted. Although looking at a typical 
> website I might be the only one that feels that way.
> 
> If the source is readable then it makes it easier for us to work with if 
> we ever want to change anything. It is also easier for contributors to 
> patch.
> 
> Given the small scale of the potential reduction, the maintenance 
> benefits and the (relatively) small resources concerned I think I am 
> leaning towards readable but what does everyone else think?

Personally, I prefer readability over compactness because it makes maintenance 
and contributions easier. I don't mind a flag for this, but those few bytes 
saved are negligiable. One still can use GZIP compression if the client 
requests it or even a filter to compact the source. I really often use Ctrl+U 
to look at source code and often I need to format it to make it reviewable :-(

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



Re: (tomcat) branch 11.0.x updated: Improve HTML output of DefaultServlet

2024-10-06 Thread Mark Thomas

On 06/10/2024 19:04, Michael Osipov wrote:

On 2024/10/06 14:18:34 Mark Thomas wrote:

On 05/10/2024 18:23, micha...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
   new 4108bf15b5 Improve HTML output of DefaultServlet
4108bf15b5 is described below

commit 4108bf15b54cc82b56736edf07cff4561e8d457c
Author: Michael Osipov 
AuthorDate: Sat Oct 5 19:18:17 2024 +0200

  Improve HTML output of DefaultServlet


How does this improve the output? It appears to just be adding
(unnecessary) new lines in the HTML source.


I agree with you so far that my wording is bad on the summary. It does not 
change the HTML code, but simply makes line breaks consistent. No functional 
change.


OK. Not something that is high on my list of priotities but since we are 
here...


Should the priority be to make the source clear / readable or should we 
be aiming to minimise it (remove line breaks, comments etc) for 
(marginally) better response time. I can see arguments for both.


While bandwidth is certainly more plentiful than it was 20 years ago, it 
still pains me to see any of it wasted. Although looking at a typical 
website I might be the only one that feels that way.


If the source is readable then it makes it easier for us to work with if 
we ever want to change anything. It is also easier for contributors to 
patch.


Given the small scale of the potential reduction, the maintenance 
benefits and the (relatively) small resources concerned I think I am 
leaning towards readable but what does everyone else think?


Mark

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



(tomcat) branch 11.0.x updated: Gitignore modules target directories

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new ae36867d55 Gitignore modules target directories
ae36867d55 is described below

commit ae36867d5595c960223331578a375b06fcd6d811
Author: Igal Sapir 
AuthorDate: Sun Oct 6 14:41:52 2024 -0700

Gitignore modules target directories

Ignore the current modules/openssl-java21/target and similar past and 
future versions
---
 .gitignore | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3993b03abf..18c361ce84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,7 @@ thumbs.db
 Thumbs.db
 bin/setenv.*
 java/org/apache/catalina/startup/catalina.properties
+modules/**/target
 modules/jdbc-pool/bin
 modules/jdbc-pool/includes
-modules/openssl-java17/target
-modules/openssl-foreign/target
 webapps/docs/jdbc-pool.xml


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



Re: (tomcat) branch main updated: Allow different implementations for RateLimitFilter

2024-10-06 Thread Igal Sapir
Mark,

On Sun, Oct 6, 2024, 06:43 Mark Thomas  wrote:

> On 06/10/2024 06:54, isa...@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > isapir 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 9cc44dcca2 Allow different implementations for RateLimitFilter
> > 9cc44dcca2 is described below
> >
> > commit 9cc44dcca224ebc5fc4f8c835e3c64f42ab04fc1
> > Author: Igal Sapir 
> > AuthorDate: Sat Oct 5 22:54:21 2024 -0700
> >
> >  Allow different implementations for RateLimitFilter
>
> Overall, big +1 to this sort of extensibility.
>
> > +/**
> > + * init-param to set a class name that implements RateLimiter
> > + */
> > +public static final String PARAM_CLASS_NAME = "className";
>
> I think this needs to be renamed for consistency. Generally, we use
> className to define the implementing class of the component being
> defined. For sub-components, we use something like rateLimiterClassName.
> For an example, have a look at the Manager class where we have className
> and secureRandomClass.
>

Sounds good. I was looking for example in the Connector configuration in
server.xml and was unaware of the distinction between a component and a
subcomponent.

Are these rules/conventions documented anywhere?  I'd be happy to start it
if not but I'm not sure where would be a good place.

Otherwise there is a risk that the next time I do something like that I
will forget and use the wrong convention again.


> > +try {
> > +rateLimiter =
> (RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
> > +} catch (InstantiationException | IllegalAccessException |
> InvocationTargetException |
> > + NoSuchMethodException | ClassNotFoundException e) {
>
> You can catch ReflectiveOperationException here and simplify the above.
>

Ack


> > diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java
> b/test/org/apache/catalina/filters/TestRateLimitFilter.java
> > index 0d918285c7..ff9bdbf351 100644
> > --- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
> > +++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
> > @@ -24,6 +24,7 @@ import jakarta.servlet.FilterChain;
> >   import jakarta.servlet.FilterConfig;
> >   import jakarta.servlet.ServletException;
> >
> > +import org.apache.catalina.util.FastRateLimiter;
> >   import org.junit.Assert;
> >   import org.junit.Test;
> >
> > @@ -55,9 +56,11 @@ public class TestRateLimitFilter extends
> TomcatBaseTest {
> >   MockFilterChain filterChain = new MockFilterChain();
> >   RateLimitFilter rateLimitFilter =
> testRateLimitFilter(filterDef, root);
> >
> > -int allowedRequests = (int)
> Math.round(rateLimitFilter.bucketCounter.getRatio() * bucketRequests);
> > +FastRateLimiter tbc = (FastRateLimiter)
> rateLimitFilter.rateLimiter;
>
> tbc? Looks like "To Be Confirmed". Maybe expand this name.
>

Understood and agreed


> It is great you were able to address this so promptly.
>

Thank you. I will apply the changes above ASAP.

Igal



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


Re: (tomcat) branch main updated: Allow different implementations for RateLimitFilter

2024-10-06 Thread Igal Sapir
Mark,


>
>> On Sun, Oct 6, 2024 at 8:48 AM Mark Thomas  wrote:
>>
>>> On 06/10/2024 16:09, Igal Sapir wrote:
>>> > On Sun, Oct 6, 2024, 06:43 Mark Thomas  wrote:
>>>
>>> 
>>>
>>> >> I think this needs to be renamed for consistency. Generally, we use
>>> >> className to define the implementing class of the component being
>>> >> defined. For sub-components, we use something like
>>> rateLimiterClassName.
>>> >> For an example, have a look at the Manager class where we have
>>> className
>>> >> and secureRandomClass.
>>> >>
>>> >
>>> > Sounds good. I was looking for example in the Connector configuration
>>> in
>>> > server.xml and was unaware of the distinction between a component and a
>>> > subcomponent.
>>> >
>>> > Are these rules/conventions documented anywhere?  I'd be happy to
>>> start it
>>> > if not but I'm not sure where would be a good place.
>>>
>>> I don't think they are documented. The wiki is probably the place for
>>> that.
>>>
>>> 
>>>
>>> > Thank you. I will apply the changes above ASAP.
>>>
>>> Tx.
>>>
>>> FYI, I am currently looking at all of the Filters to see if any
>>> can/should take advantage of the init-param setting provided by the base
>>> class. This looks like a candidate for that but I should be able to take
>>
>> care of it (just as soon as I figure out what I have done wrong that has
>>> broken the test).
>>>
>>
I saw that you updated the init-param name.

I applied the two other changes that you pointed out.

Thank you,


Igal



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


(tomcat) branch main updated: Gitignore modules target directories

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 b3c5e1bc14 Gitignore modules target directories
b3c5e1bc14 is described below

commit b3c5e1bc142ddcd906c944b1360e10e2b4ad5f67
Author: Igal Sapir 
AuthorDate: Sun Oct 6 14:41:52 2024 -0700

Gitignore modules target directories

Ignore the current modules/openssl-java21/target and similar past and 
future versions
---
 .gitignore | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3993b03abf..18c361ce84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,7 @@ thumbs.db
 Thumbs.db
 bin/setenv.*
 java/org/apache/catalina/startup/catalina.properties
+modules/**/target
 modules/jdbc-pool/bin
 modules/jdbc-pool/includes
-modules/openssl-java17/target
-modules/openssl-foreign/target
 webapps/docs/jdbc-pool.xml


-
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: Gitignore modules target directories

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 adb586e966 Gitignore modules target directories
adb586e966 is described below

commit adb586e9668a45548b331719f0a4f7b7daaccc98
Author: Igal Sapir 
AuthorDate: Sun Oct 6 14:41:52 2024 -0700

Gitignore modules target directories

Ignore the current modules/openssl-java21/target and similar past and 
future versions
---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index d2f1ac409f..81171124ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,7 +46,7 @@ thumbs.db
 Thumbs.db
 bin/setenv.*
 java/org/apache/catalina/startup/catalina.properties
+modules/**/target
 modules/jdbc-pool/bin
 modules/jdbc-pool/includes
-modules/openssl-foreign/target
 webapps/docs/jdbc-pool.xml


-
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: Gitignore modules target directories

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 148f88d22f Gitignore modules target directories
148f88d22f is described below

commit 148f88d22fc1fa3421ba91d7fdf62443390bea82
Author: Igal Sapir 
AuthorDate: Sun Oct 6 14:41:52 2024 -0700

Gitignore modules target directories

Ignore the current modules/openssl-java21/target and similar past and 
future versions
---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index d2f1ac409f..81171124ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,7 +46,7 @@ thumbs.db
 Thumbs.db
 bin/setenv.*
 java/org/apache/catalina/startup/catalina.properties
+modules/**/target
 modules/jdbc-pool/bin
 modules/jdbc-pool/includes
-modules/openssl-foreign/target
 webapps/docs/jdbc-pool.xml


-
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: Refactor RateLimitFilter to use FilterBase as the base class.

2024-10-06 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 a187122dbe Refactor RateLimitFilter to use FilterBase as the base 
class.
a187122dbe is described below

commit a187122dbeb64d514290a58ff05a928113189a51
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:07:41 2024 +0100

Refactor RateLimitFilter to use FilterBase as the base class.

The primary advantage for doing this is less code to process init-param
values.
---
 .../apache/catalina/filters/RateLimitFilter.java   | 106 -
 .../catalina/filters/TestRateLimitFilter.java  |   4 +-
 webapps/docs/changelog.xml |   5 +
 webapps/docs/config/filter.xml |   9 +-
 4 files changed, 53 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 688b54bda9..4aaa35bbc3 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException;
 
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
-import javax.servlet.GenericFilter;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -72,9 +71,7 @@ import org.apache.tomcat.util.res.StringManager;
  * requests from different IPs in the same bucket and will result in a self 
inflicted DoS attack.
  * 
  */
-public class RateLimitFilter extends GenericFilter {
-
-private static final long serialVersionUID = 1L;
+public class RateLimitFilter extends FilterBase {
 
 /**
  * default duration in seconds
@@ -106,36 +103,6 @@ public class RateLimitFilter extends GenericFilter {
  */
 public static final String RATE_LIMIT_ATTRIBUTE_COUNT = 
"org.apache.catalina.filters.RateLimitFilter.Count";
 
-/**
- * init-param to set the bucket duration in seconds
- */
-public static final String PARAM_BUCKET_DURATION = "bucketDuration";
-
-/**
- * init-param to set the bucket number of requests
- */
-public static final String PARAM_BUCKET_REQUESTS = "bucketRequests";
-
-/**
- * init-param to set the enforce flag
- */
-public static final String PARAM_ENFORCE = "enforce";
-
-/**
- * init-param to set a custom status code if requests per duration exceeded
- */
-public static final String PARAM_STATUS_CODE = "statusCode";
-
-/**
- * init-param to set a class name that implements RateLimiter
- */
-public static final String PARAM_CLASS_NAME = "className";
-
-/**
- * init-param to set a custom status message if requests per duration 
exceeded
- */
-public static final String PARAM_STATUS_MESSAGE = "statusMessage";
-
 transient RateLimiter rateLimiter;
 
 private String rateLimitClassName = 
"org.apache.catalina.util.FastRateLimiter";
@@ -150,45 +117,46 @@ public class RateLimitFilter extends GenericFilter {
 
 private String statusMessage = DEFAULT_STATUS_MESSAGE;
 
+private String filterName;
+
 private transient Log log = LogFactory.getLog(RateLimitFilter.class);
 
 private static final StringManager sm = 
StringManager.getManager(RateLimitFilter.class);
 
-@Override
-public void init() throws ServletException {
 
-FilterConfig config = getFilterConfig();
+public void setBucketDuration(int bucketDuration) {
+this.bucketDuration = bucketDuration;
+}
 
-String param;
-param = config.getInitParameter(PARAM_BUCKET_DURATION);
-if (param != null) {
-bucketDuration = Integer.parseInt(param);
-}
 
-param = config.getInitParameter(PARAM_BUCKET_REQUESTS);
-if (param != null) {
-bucketRequests = Integer.parseInt(param);
-}
+public void setBucketRequests(int bucketRequests) {
+this.bucketRequests = bucketRequests;
+}
 
-param = config.getInitParameter(PARAM_ENFORCE);
-if (param != null) {
-enforce = Boolean.parseBoolean(param);
-}
 
-param = config.getInitParameter(PARAM_STATUS_CODE);
-if (param != null) {
-statusCode = Integer.parseInt(param);
-}
+public void setEnforce(boolean enforce) {
+this.enforce = enforce;
+}
 
-param = config.getInitParameter(PARAM_STATUS_MESSAGE);
-if (param != null) {
-statusMessage = param;
-}
 
-param = config.getInitParameter(PARAM_CLASS_NAME);
-if (param != null) {
-rateLimitClassName = param;
-}
+public void setStatusCode(int statusCode) {
+this.statusCode = statusCode;
+}
+
+
+public void setStatusMessage

(tomcat) branch 10.1.x updated: Fix checkstyle warnings

2024-10-06 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 18e84c632b Fix checkstyle warnings
18e84c632b is described below

commit 18e84c632bfe2a670885abb48d9d1a7e1ca062f9
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:20:40 2024 +0100

Fix checkstyle warnings
---
 java/org/apache/catalina/util/FastRateLimiter.java  |  7 ---
 java/org/apache/catalina/util/RateLimiter.java  | 17 +
 .../apache/catalina/filters/TestRateLimitFilter.java|  2 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/util/FastRateLimiter.java 
b/java/org/apache/catalina/util/FastRateLimiter.java
index bf2404ed1b..25c6546663 100644
--- a/java/org/apache/catalina/util/FastRateLimiter.java
+++ b/java/org/apache/catalina/util/FastRateLimiter.java
@@ -17,13 +17,14 @@
 
 package org.apache.catalina.util;
 
+import java.util.concurrent.ScheduledExecutorService;
+
 import jakarta.servlet.FilterConfig;
-import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
-import java.util.concurrent.ScheduledExecutorService;
+import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
 /**
- * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput
+ * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput.
  */
 public class FastRateLimiter implements RateLimiter {
 
diff --git a/java/org/apache/catalina/util/RateLimiter.java 
b/java/org/apache/catalina/util/RateLimiter.java
index fb3bb0d855..c13f794fbc 100644
--- a/java/org/apache/catalina/util/RateLimiter.java
+++ b/java/org/apache/catalina/util/RateLimiter.java
@@ -27,9 +27,9 @@ public interface RateLimiter {
 int getDuration();
 
 /**
- * sets the configured duration value in seconds
+ * Sets the configured duration value in seconds.
  *
- * @param duration
+ * @param duration The duration of the time window in seconds
  */
 void setDuration(int duration);
 
@@ -39,29 +39,30 @@ public interface RateLimiter {
 int getRequests();
 
 /**
- * sets the configured number of requests allowed per time window
+ * Sets the configured number of requests allowed per time window.
  *
- * @param requests
+ * @param requests The number of requests per time window
  */
 void setRequests(int requests);
 
 /**
- * increments the number of requests by the given ipAddress in the current 
time window
+ * Increments the number of requests by the given ipAddress in the current 
time window.
  *
  * @param ipAddress the ip address
+ *
  * @return the new value after incrementing
  */
 int increment(String ipAddress);
 
 /**
- * cleanup no longer needed resources
+ * Cleanup no longer needed resources.
  */
 void destroy();
 
 /**
- * pass the FilterConfig to configure the filter
+ * Pass the FilterConfig to configure the filter.
  *
- * @param filterConfig
+ * @param filterConfig The FilterConfig used to configure the associated 
filter
  */
 void setFilterConfig(FilterConfig filterConfig);
 }
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 57d02307f3..d07389c58c 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -24,7 +24,6 @@ import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
 import jakarta.servlet.ServletException;
 
-import org.apache.catalina.util.FastRateLimiter;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -33,6 +32,7 @@ import 
org.apache.catalina.filters.TestRemoteIpFilter.MockFilterChain;
 import org.apache.catalina.filters.TestRemoteIpFilter.MockHttpServletRequest;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.FastRateLimiter;
 import org.apache.tomcat.unittest.TesterResponse;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;


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



(tomcat) branch 11.0.x updated: Fix checkstyle warnings

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new f36a2c0d7f Fix checkstyle warnings
f36a2c0d7f is described below

commit f36a2c0d7f8c321b94867c90db71f3d55d5826bb
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:20:40 2024 +0100

Fix checkstyle warnings
---
 java/org/apache/catalina/util/FastRateLimiter.java  |  7 ---
 java/org/apache/catalina/util/RateLimiter.java  | 17 +
 .../apache/catalina/filters/TestRateLimitFilter.java|  2 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/util/FastRateLimiter.java 
b/java/org/apache/catalina/util/FastRateLimiter.java
index bf2404ed1b..25c6546663 100644
--- a/java/org/apache/catalina/util/FastRateLimiter.java
+++ b/java/org/apache/catalina/util/FastRateLimiter.java
@@ -17,13 +17,14 @@
 
 package org.apache.catalina.util;
 
+import java.util.concurrent.ScheduledExecutorService;
+
 import jakarta.servlet.FilterConfig;
-import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
-import java.util.concurrent.ScheduledExecutorService;
+import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
 /**
- * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput
+ * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput.
  */
 public class FastRateLimiter implements RateLimiter {
 
diff --git a/java/org/apache/catalina/util/RateLimiter.java 
b/java/org/apache/catalina/util/RateLimiter.java
index fb3bb0d855..c13f794fbc 100644
--- a/java/org/apache/catalina/util/RateLimiter.java
+++ b/java/org/apache/catalina/util/RateLimiter.java
@@ -27,9 +27,9 @@ public interface RateLimiter {
 int getDuration();
 
 /**
- * sets the configured duration value in seconds
+ * Sets the configured duration value in seconds.
  *
- * @param duration
+ * @param duration The duration of the time window in seconds
  */
 void setDuration(int duration);
 
@@ -39,29 +39,30 @@ public interface RateLimiter {
 int getRequests();
 
 /**
- * sets the configured number of requests allowed per time window
+ * Sets the configured number of requests allowed per time window.
  *
- * @param requests
+ * @param requests The number of requests per time window
  */
 void setRequests(int requests);
 
 /**
- * increments the number of requests by the given ipAddress in the current 
time window
+ * Increments the number of requests by the given ipAddress in the current 
time window.
  *
  * @param ipAddress the ip address
+ *
  * @return the new value after incrementing
  */
 int increment(String ipAddress);
 
 /**
- * cleanup no longer needed resources
+ * Cleanup no longer needed resources.
  */
 void destroy();
 
 /**
- * pass the FilterConfig to configure the filter
+ * Pass the FilterConfig to configure the filter.
  *
- * @param filterConfig
+ * @param filterConfig The FilterConfig used to configure the associated 
filter
  */
 void setFilterConfig(FilterConfig filterConfig);
 }
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 57d02307f3..d07389c58c 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -24,7 +24,6 @@ import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
 import jakarta.servlet.ServletException;
 
-import org.apache.catalina.util.FastRateLimiter;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -33,6 +32,7 @@ import 
org.apache.catalina.filters.TestRemoteIpFilter.MockFilterChain;
 import org.apache.catalina.filters.TestRemoteIpFilter.MockHttpServletRequest;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.FastRateLimiter;
 import org.apache.tomcat.unittest.TesterResponse;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;


-
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: Fix checkstyle warnings

2024-10-06 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 17844b05d6 Fix checkstyle warnings
17844b05d6 is described below

commit 17844b05d6bf73ae30c9f3310f9ef1b9833c60e1
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:20:40 2024 +0100

Fix checkstyle warnings
---
 java/org/apache/catalina/util/FastRateLimiter.java  |  7 ---
 java/org/apache/catalina/util/RateLimiter.java  | 17 +
 .../apache/catalina/filters/TestRateLimitFilter.java|  2 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/util/FastRateLimiter.java 
b/java/org/apache/catalina/util/FastRateLimiter.java
index 7ebf6a9079..13cc6a2b59 100644
--- a/java/org/apache/catalina/util/FastRateLimiter.java
+++ b/java/org/apache/catalina/util/FastRateLimiter.java
@@ -17,13 +17,14 @@
 
 package org.apache.catalina.util;
 
-import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
-
 import java.util.concurrent.ScheduledExecutorService;
+
 import javax.servlet.FilterConfig;
 
+import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
+
 /**
- * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput
+ * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput.
  */
 public class FastRateLimiter implements RateLimiter {
 
diff --git a/java/org/apache/catalina/util/RateLimiter.java 
b/java/org/apache/catalina/util/RateLimiter.java
index 338985d827..f9d63a3d42 100644
--- a/java/org/apache/catalina/util/RateLimiter.java
+++ b/java/org/apache/catalina/util/RateLimiter.java
@@ -27,9 +27,9 @@ public interface RateLimiter {
 int getDuration();
 
 /**
- * sets the configured duration value in seconds
+ * Sets the configured duration value in seconds.
  *
- * @param duration
+ * @param duration The duration of the time window in seconds
  */
 void setDuration(int duration);
 
@@ -39,29 +39,30 @@ public interface RateLimiter {
 int getRequests();
 
 /**
- * sets the configured number of requests allowed per time window
+ * Sets the configured number of requests allowed per time window.
  *
- * @param requests
+ * @param requests The number of requests per time window
  */
 void setRequests(int requests);
 
 /**
- * increments the number of requests by the given ipAddress in the current 
time window
+ * Increments the number of requests by the given ipAddress in the current 
time window.
  *
  * @param ipAddress the ip address
+ *
  * @return the new value after incrementing
  */
 int increment(String ipAddress);
 
 /**
- * cleanup no longer needed resources
+ * Cleanup no longer needed resources.
  */
 void destroy();
 
 /**
- * pass the FilterConfig to configure the filter
+ * Pass the FilterConfig to configure the filter.
  *
- * @param filterConfig
+ * @param filterConfig The FilterConfig used to configure the associated 
filter
  */
 void setFilterConfig(FilterConfig filterConfig);
 }
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 530b392d64..c43a85b395 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -24,7 +24,6 @@ import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.util.FastRateLimiter;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -33,6 +32,7 @@ import 
org.apache.catalina.filters.TestRemoteIpFilter.MockFilterChain;
 import org.apache.catalina.filters.TestRemoteIpFilter.MockHttpServletRequest;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.FastRateLimiter;
 import org.apache.tomcat.unittest.TesterResponse;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;


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



(tomcat) branch main updated: Refactor RateLimitFilter to use FilterBase as the base class.

2024-10-06 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 25d80e93a5 Refactor RateLimitFilter to use FilterBase as the base 
class.
25d80e93a5 is described below

commit 25d80e93a5fc0ef076d0239c8a844c8a24f22c8f
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:07:41 2024 +0100

Refactor RateLimitFilter to use FilterBase as the base class.

The primary advantage for doing this is less code to process init-param
values.
---
 .../apache/catalina/filters/RateLimitFilter.java   | 106 -
 .../catalina/filters/TestRateLimitFilter.java  |   4 +-
 webapps/docs/config/filter.xml |   9 +-
 3 files changed, 48 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index a6cccbea30..efcedca0ff 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
-import jakarta.servlet.GenericFilter;
 import jakarta.servlet.ServletException;
 import jakarta.servlet.ServletRequest;
 import jakarta.servlet.ServletResponse;
@@ -72,9 +71,7 @@ import org.apache.tomcat.util.res.StringManager;
  * requests from different IPs in the same bucket and will result in a self 
inflicted DoS attack.
  * 
  */
-public class RateLimitFilter extends GenericFilter {
-
-private static final long serialVersionUID = 1L;
+public class RateLimitFilter extends FilterBase {
 
 /**
  * default duration in seconds
@@ -106,36 +103,6 @@ public class RateLimitFilter extends GenericFilter {
  */
 public static final String RATE_LIMIT_ATTRIBUTE_COUNT = 
"org.apache.catalina.filters.RateLimitFilter.Count";
 
-/**
- * init-param to set the bucket duration in seconds
- */
-public static final String PARAM_BUCKET_DURATION = "bucketDuration";
-
-/**
- * init-param to set the bucket number of requests
- */
-public static final String PARAM_BUCKET_REQUESTS = "bucketRequests";
-
-/**
- * init-param to set the enforce flag
- */
-public static final String PARAM_ENFORCE = "enforce";
-
-/**
- * init-param to set a custom status code if requests per duration exceeded
- */
-public static final String PARAM_STATUS_CODE = "statusCode";
-
-/**
- * init-param to set a class name that implements RateLimiter
- */
-public static final String PARAM_CLASS_NAME = "className";
-
-/**
- * init-param to set a custom status message if requests per duration 
exceeded
- */
-public static final String PARAM_STATUS_MESSAGE = "statusMessage";
-
 transient RateLimiter rateLimiter;
 
 private String rateLimitClassName = 
"org.apache.catalina.util.FastRateLimiter";
@@ -150,45 +117,46 @@ public class RateLimitFilter extends GenericFilter {
 
 private String statusMessage = DEFAULT_STATUS_MESSAGE;
 
+private String filterName;
+
 private transient Log log = LogFactory.getLog(RateLimitFilter.class);
 
 private static final StringManager sm = 
StringManager.getManager(RateLimitFilter.class);
 
-@Override
-public void init() throws ServletException {
 
-FilterConfig config = getFilterConfig();
+public void setBucketDuration(int bucketDuration) {
+this.bucketDuration = bucketDuration;
+}
 
-String param;
-param = config.getInitParameter(PARAM_BUCKET_DURATION);
-if (param != null) {
-bucketDuration = Integer.parseInt(param);
-}
 
-param = config.getInitParameter(PARAM_BUCKET_REQUESTS);
-if (param != null) {
-bucketRequests = Integer.parseInt(param);
-}
+public void setBucketRequests(int bucketRequests) {
+this.bucketRequests = bucketRequests;
+}
 
-param = config.getInitParameter(PARAM_ENFORCE);
-if (param != null) {
-enforce = Boolean.parseBoolean(param);
-}
 
-param = config.getInitParameter(PARAM_STATUS_CODE);
-if (param != null) {
-statusCode = Integer.parseInt(param);
-}
+public void setEnforce(boolean enforce) {
+this.enforce = enforce;
+}
 
-param = config.getInitParameter(PARAM_STATUS_MESSAGE);
-if (param != null) {
-statusMessage = param;
-}
 
-param = config.getInitParameter(PARAM_CLASS_NAME);
-if (param != null) {
-rateLimitClassName = param;
-}
+public void setStatusCode(int statusCode) {
+this.statusCode = statusCode;
+}
+
+
+public void setStatusMessage(String statusMessage) {
+this.statusMessa

(tomcat) branch 11.0.x updated: Refactor RateLimitFilter to use FilterBase as the base class.

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new 20ac54a54f Refactor RateLimitFilter to use FilterBase as the base 
class.
20ac54a54f is described below

commit 20ac54a54fdc0062448afbbe8e5c2164a8ce8097
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:07:41 2024 +0100

Refactor RateLimitFilter to use FilterBase as the base class.

The primary advantage for doing this is less code to process init-param
values.
---
 .../apache/catalina/filters/RateLimitFilter.java   | 106 -
 .../catalina/filters/TestRateLimitFilter.java  |   4 +-
 webapps/docs/changelog.xml |   5 +
 webapps/docs/config/filter.xml |   9 +-
 4 files changed, 53 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index a6cccbea30..efcedca0ff 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
-import jakarta.servlet.GenericFilter;
 import jakarta.servlet.ServletException;
 import jakarta.servlet.ServletRequest;
 import jakarta.servlet.ServletResponse;
@@ -72,9 +71,7 @@ import org.apache.tomcat.util.res.StringManager;
  * requests from different IPs in the same bucket and will result in a self 
inflicted DoS attack.
  * 
  */
-public class RateLimitFilter extends GenericFilter {
-
-private static final long serialVersionUID = 1L;
+public class RateLimitFilter extends FilterBase {
 
 /**
  * default duration in seconds
@@ -106,36 +103,6 @@ public class RateLimitFilter extends GenericFilter {
  */
 public static final String RATE_LIMIT_ATTRIBUTE_COUNT = 
"org.apache.catalina.filters.RateLimitFilter.Count";
 
-/**
- * init-param to set the bucket duration in seconds
- */
-public static final String PARAM_BUCKET_DURATION = "bucketDuration";
-
-/**
- * init-param to set the bucket number of requests
- */
-public static final String PARAM_BUCKET_REQUESTS = "bucketRequests";
-
-/**
- * init-param to set the enforce flag
- */
-public static final String PARAM_ENFORCE = "enforce";
-
-/**
- * init-param to set a custom status code if requests per duration exceeded
- */
-public static final String PARAM_STATUS_CODE = "statusCode";
-
-/**
- * init-param to set a class name that implements RateLimiter
- */
-public static final String PARAM_CLASS_NAME = "className";
-
-/**
- * init-param to set a custom status message if requests per duration 
exceeded
- */
-public static final String PARAM_STATUS_MESSAGE = "statusMessage";
-
 transient RateLimiter rateLimiter;
 
 private String rateLimitClassName = 
"org.apache.catalina.util.FastRateLimiter";
@@ -150,45 +117,46 @@ public class RateLimitFilter extends GenericFilter {
 
 private String statusMessage = DEFAULT_STATUS_MESSAGE;
 
+private String filterName;
+
 private transient Log log = LogFactory.getLog(RateLimitFilter.class);
 
 private static final StringManager sm = 
StringManager.getManager(RateLimitFilter.class);
 
-@Override
-public void init() throws ServletException {
 
-FilterConfig config = getFilterConfig();
+public void setBucketDuration(int bucketDuration) {
+this.bucketDuration = bucketDuration;
+}
 
-String param;
-param = config.getInitParameter(PARAM_BUCKET_DURATION);
-if (param != null) {
-bucketDuration = Integer.parseInt(param);
-}
 
-param = config.getInitParameter(PARAM_BUCKET_REQUESTS);
-if (param != null) {
-bucketRequests = Integer.parseInt(param);
-}
+public void setBucketRequests(int bucketRequests) {
+this.bucketRequests = bucketRequests;
+}
 
-param = config.getInitParameter(PARAM_ENFORCE);
-if (param != null) {
-enforce = Boolean.parseBoolean(param);
-}
 
-param = config.getInitParameter(PARAM_STATUS_CODE);
-if (param != null) {
-statusCode = Integer.parseInt(param);
-}
+public void setEnforce(boolean enforce) {
+this.enforce = enforce;
+}
 
-param = config.getInitParameter(PARAM_STATUS_MESSAGE);
-if (param != null) {
-statusMessage = param;
-}
 
-param = config.getInitParameter(PARAM_CLASS_NAME);
-if (param != null) {
-rateLimitClassName = param;
-}
+public void setStatusCode(int statusCode) {
+this.statusCode = statusCode;
+}
+
+
+public void se

(tomcat) branch main updated: Fix checkstyle warnings

2024-10-06 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 9530374e59 Fix checkstyle warnings
9530374e59 is described below

commit 9530374e59b38a173c1f996d57980c34bc182925
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:20:40 2024 +0100

Fix checkstyle warnings
---
 java/org/apache/catalina/util/FastRateLimiter.java  |  7 ---
 java/org/apache/catalina/util/RateLimiter.java  | 17 +
 .../apache/catalina/filters/TestRateLimitFilter.java|  2 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/util/FastRateLimiter.java 
b/java/org/apache/catalina/util/FastRateLimiter.java
index bf2404ed1b..25c6546663 100644
--- a/java/org/apache/catalina/util/FastRateLimiter.java
+++ b/java/org/apache/catalina/util/FastRateLimiter.java
@@ -17,13 +17,14 @@
 
 package org.apache.catalina.util;
 
+import java.util.concurrent.ScheduledExecutorService;
+
 import jakarta.servlet.FilterConfig;
-import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
-import java.util.concurrent.ScheduledExecutorService;
+import org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor;
 
 /**
- * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput
+ * A RateLimiter that compromises accuracy for speed in order to provide 
maximum throughput.
  */
 public class FastRateLimiter implements RateLimiter {
 
diff --git a/java/org/apache/catalina/util/RateLimiter.java 
b/java/org/apache/catalina/util/RateLimiter.java
index fb3bb0d855..c13f794fbc 100644
--- a/java/org/apache/catalina/util/RateLimiter.java
+++ b/java/org/apache/catalina/util/RateLimiter.java
@@ -27,9 +27,9 @@ public interface RateLimiter {
 int getDuration();
 
 /**
- * sets the configured duration value in seconds
+ * Sets the configured duration value in seconds.
  *
- * @param duration
+ * @param duration The duration of the time window in seconds
  */
 void setDuration(int duration);
 
@@ -39,29 +39,30 @@ public interface RateLimiter {
 int getRequests();
 
 /**
- * sets the configured number of requests allowed per time window
+ * Sets the configured number of requests allowed per time window.
  *
- * @param requests
+ * @param requests The number of requests per time window
  */
 void setRequests(int requests);
 
 /**
- * increments the number of requests by the given ipAddress in the current 
time window
+ * Increments the number of requests by the given ipAddress in the current 
time window.
  *
  * @param ipAddress the ip address
+ *
  * @return the new value after incrementing
  */
 int increment(String ipAddress);
 
 /**
- * cleanup no longer needed resources
+ * Cleanup no longer needed resources.
  */
 void destroy();
 
 /**
- * pass the FilterConfig to configure the filter
+ * Pass the FilterConfig to configure the filter.
  *
- * @param filterConfig
+ * @param filterConfig The FilterConfig used to configure the associated 
filter
  */
 void setFilterConfig(FilterConfig filterConfig);
 }
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 57d02307f3..d07389c58c 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -24,7 +24,6 @@ import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
 import jakarta.servlet.ServletException;
 
-import org.apache.catalina.util.FastRateLimiter;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -33,6 +32,7 @@ import 
org.apache.catalina.filters.TestRemoteIpFilter.MockFilterChain;
 import org.apache.catalina.filters.TestRemoteIpFilter.MockHttpServletRequest;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.FastRateLimiter;
 import org.apache.tomcat.unittest.TesterResponse;
 import org.apache.tomcat.util.descriptor.web.FilterDef;
 import org.apache.tomcat.util.descriptor.web.FilterMap;


-
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: Refactor RateLimitFilter to use FilterBase as the base class.

2024-10-06 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 1e6888623b Refactor RateLimitFilter to use FilterBase as the base 
class.
1e6888623b is described below

commit 1e6888623b4764932c761baaebf66f6fab379dd3
Author: Mark Thomas 
AuthorDate: Sun Oct 6 17:07:41 2024 +0100

Refactor RateLimitFilter to use FilterBase as the base class.

The primary advantage for doing this is less code to process init-param
values.
---
 .../apache/catalina/filters/RateLimitFilter.java   | 106 -
 .../catalina/filters/TestRateLimitFilter.java  |   4 +-
 webapps/docs/changelog.xml |   5 +
 webapps/docs/config/filter.xml |   9 +-
 4 files changed, 53 insertions(+), 71 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index a6cccbea30..efcedca0ff 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
-import jakarta.servlet.GenericFilter;
 import jakarta.servlet.ServletException;
 import jakarta.servlet.ServletRequest;
 import jakarta.servlet.ServletResponse;
@@ -72,9 +71,7 @@ import org.apache.tomcat.util.res.StringManager;
  * requests from different IPs in the same bucket and will result in a self 
inflicted DoS attack.
  * 
  */
-public class RateLimitFilter extends GenericFilter {
-
-private static final long serialVersionUID = 1L;
+public class RateLimitFilter extends FilterBase {
 
 /**
  * default duration in seconds
@@ -106,36 +103,6 @@ public class RateLimitFilter extends GenericFilter {
  */
 public static final String RATE_LIMIT_ATTRIBUTE_COUNT = 
"org.apache.catalina.filters.RateLimitFilter.Count";
 
-/**
- * init-param to set the bucket duration in seconds
- */
-public static final String PARAM_BUCKET_DURATION = "bucketDuration";
-
-/**
- * init-param to set the bucket number of requests
- */
-public static final String PARAM_BUCKET_REQUESTS = "bucketRequests";
-
-/**
- * init-param to set the enforce flag
- */
-public static final String PARAM_ENFORCE = "enforce";
-
-/**
- * init-param to set a custom status code if requests per duration exceeded
- */
-public static final String PARAM_STATUS_CODE = "statusCode";
-
-/**
- * init-param to set a class name that implements RateLimiter
- */
-public static final String PARAM_CLASS_NAME = "className";
-
-/**
- * init-param to set a custom status message if requests per duration 
exceeded
- */
-public static final String PARAM_STATUS_MESSAGE = "statusMessage";
-
 transient RateLimiter rateLimiter;
 
 private String rateLimitClassName = 
"org.apache.catalina.util.FastRateLimiter";
@@ -150,45 +117,46 @@ public class RateLimitFilter extends GenericFilter {
 
 private String statusMessage = DEFAULT_STATUS_MESSAGE;
 
+private String filterName;
+
 private transient Log log = LogFactory.getLog(RateLimitFilter.class);
 
 private static final StringManager sm = 
StringManager.getManager(RateLimitFilter.class);
 
-@Override
-public void init() throws ServletException {
 
-FilterConfig config = getFilterConfig();
+public void setBucketDuration(int bucketDuration) {
+this.bucketDuration = bucketDuration;
+}
 
-String param;
-param = config.getInitParameter(PARAM_BUCKET_DURATION);
-if (param != null) {
-bucketDuration = Integer.parseInt(param);
-}
 
-param = config.getInitParameter(PARAM_BUCKET_REQUESTS);
-if (param != null) {
-bucketRequests = Integer.parseInt(param);
-}
+public void setBucketRequests(int bucketRequests) {
+this.bucketRequests = bucketRequests;
+}
 
-param = config.getInitParameter(PARAM_ENFORCE);
-if (param != null) {
-enforce = Boolean.parseBoolean(param);
-}
 
-param = config.getInitParameter(PARAM_STATUS_CODE);
-if (param != null) {
-statusCode = Integer.parseInt(param);
-}
+public void setEnforce(boolean enforce) {
+this.enforce = enforce;
+}
 
-param = config.getInitParameter(PARAM_STATUS_MESSAGE);
-if (param != null) {
-statusMessage = param;
-}
 
-param = config.getInitParameter(PARAM_CLASS_NAME);
-if (param != null) {
-rateLimitClassName = param;
-}
+public void setStatusCode(int statusCode) {
+this.statusCode = statusCode;
+}
+
+
+public void se

(tomcat) branch 11.0.x updated: RateLimitFilter code cleanup per commit feedback

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/11.0.x by this push:
 new 40c827edfe RateLimitFilter code cleanup per commit feedback
40c827edfe is described below

commit 40c827edfeef991538d4f2e60c1d48ee2771d227
Author: Igal Sapir 
AuthorDate: Sun Oct 6 12:36:37 2024 -0700

RateLimitFilter code cleanup per commit feedback
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 4 +---
 test/org/apache/catalina/filters/TestRateLimitFilter.java | 7 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 6a6e9d67a8..c9f5c83c7c 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -18,7 +18,6 @@
 package org.apache.catalina.filters;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
@@ -166,8 +165,7 @@ public class RateLimitFilter extends FilterBase {
 
 try {
 rateLimiter = 
(RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
-} catch (InstantiationException | IllegalAccessException | 
InvocationTargetException |
- NoSuchMethodException | ClassNotFoundException e) {
+} catch (ReflectiveOperationException e) {
 throw new ServletException(e);
 }
 
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index d07389c58c..693c41642b 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -56,11 +56,10 @@ public class TestRateLimitFilter extends TomcatBaseTest {
 MockFilterChain filterChain = new MockFilterChain();
 RateLimitFilter rateLimitFilter = testRateLimitFilter(filterDef, root);
 
-FastRateLimiter tbc = (FastRateLimiter) rateLimitFilter.rateLimiter;
+FastRateLimiter fastRateLimiter = (FastRateLimiter) 
rateLimitFilter.rateLimiter;
 
-int allowedRequests = (int) 
Math.round(tbc.getBucketCounter().getRatio() * bucketRequests);
-
-long sleepTime = tbc.getBucketCounter().getMillisUntilNextBucket();
+int allowedRequests = fastRateLimiter.getRequests();
+long sleepTime = 
fastRateLimiter.getBucketCounter().getMillisUntilNextBucket();
 System.out.printf("Sleeping %d millis for the next time bucket to 
start\n", Long.valueOf(sleepTime));
 Thread.sleep(sleepTime);
 


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



(tomcat) branch main updated: RateLimitFilter code cleanup per commit feedback

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 529964c209 RateLimitFilter code cleanup per commit feedback
529964c209 is described below

commit 529964c20945445e281110a214627d71480e4588
Author: Igal Sapir 
AuthorDate: Sun Oct 6 12:22:52 2024 -0700

RateLimitFilter code cleanup per commit feedback
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 4 +---
 test/org/apache/catalina/filters/TestRateLimitFilter.java | 7 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 6a6e9d67a8..c9f5c83c7c 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -18,7 +18,6 @@
 package org.apache.catalina.filters;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
@@ -166,8 +165,7 @@ public class RateLimitFilter extends FilterBase {
 
 try {
 rateLimiter = 
(RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
-} catch (InstantiationException | IllegalAccessException | 
InvocationTargetException |
- NoSuchMethodException | ClassNotFoundException e) {
+} catch (ReflectiveOperationException e) {
 throw new ServletException(e);
 }
 
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index d07389c58c..693c41642b 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -56,11 +56,10 @@ public class TestRateLimitFilter extends TomcatBaseTest {
 MockFilterChain filterChain = new MockFilterChain();
 RateLimitFilter rateLimitFilter = testRateLimitFilter(filterDef, root);
 
-FastRateLimiter tbc = (FastRateLimiter) rateLimitFilter.rateLimiter;
+FastRateLimiter fastRateLimiter = (FastRateLimiter) 
rateLimitFilter.rateLimiter;
 
-int allowedRequests = (int) 
Math.round(tbc.getBucketCounter().getRatio() * bucketRequests);
-
-long sleepTime = tbc.getBucketCounter().getMillisUntilNextBucket();
+int allowedRequests = fastRateLimiter.getRequests();
+long sleepTime = 
fastRateLimiter.getBucketCounter().getMillisUntilNextBucket();
 System.out.printf("Sleeping %d millis for the next time bucket to 
start\n", Long.valueOf(sleepTime));
 Thread.sleep(sleepTime);
 


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



Buildbot success in on tomcat-9.0.x

2024-10-06 Thread buildbot
Build status: Build succeeded!
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/37/builds/1115
Blamelist: Igal Sapir , Mark Thomas , 
Michael Osipov 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch 9.0.x] 82cbb1a1f62bd91632e0f10a1cb6f0d71a523322


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


-
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: RateLimitFilter code cleanup per commit feedback

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 ec6d300738 RateLimitFilter code cleanup per commit feedback
ec6d300738 is described below

commit ec6d3007380076664435d85c66c5f05473f36d3e
Author: Igal Sapir 
AuthorDate: Sun Oct 6 13:24:23 2024 -0700

RateLimitFilter code cleanup per commit feedback
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 4 +---
 test/org/apache/catalina/filters/TestRateLimitFilter.java | 7 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 6a6e9d67a8..c9f5c83c7c 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -18,7 +18,6 @@
 package org.apache.catalina.filters;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
@@ -166,8 +165,7 @@ public class RateLimitFilter extends FilterBase {
 
 try {
 rateLimiter = 
(RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
-} catch (InstantiationException | IllegalAccessException | 
InvocationTargetException |
- NoSuchMethodException | ClassNotFoundException e) {
+} catch (ReflectiveOperationException e) {
 throw new ServletException(e);
 }
 
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index d07389c58c..693c41642b 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -56,11 +56,10 @@ public class TestRateLimitFilter extends TomcatBaseTest {
 MockFilterChain filterChain = new MockFilterChain();
 RateLimitFilter rateLimitFilter = testRateLimitFilter(filterDef, root);
 
-FastRateLimiter tbc = (FastRateLimiter) rateLimitFilter.rateLimiter;
+FastRateLimiter fastRateLimiter = (FastRateLimiter) 
rateLimitFilter.rateLimiter;
 
-int allowedRequests = (int) 
Math.round(tbc.getBucketCounter().getRatio() * bucketRequests);
-
-long sleepTime = tbc.getBucketCounter().getMillisUntilNextBucket();
+int allowedRequests = fastRateLimiter.getRequests();
+long sleepTime = 
fastRateLimiter.getBucketCounter().getMillisUntilNextBucket();
 System.out.printf("Sleeping %d millis for the next time bucket to 
start\n", Long.valueOf(sleepTime));
 Thread.sleep(sleepTime);
 


-
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: RateLimitFilter code cleanup per commit feedback

2024-10-06 Thread isapir
This is an automated email from the ASF dual-hosted git repository.

isapir 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 77c4d2c5ff RateLimitFilter code cleanup per commit feedback
77c4d2c5ff is described below

commit 77c4d2c5fff7451c67c717fa6a2368e7e3f73a4b
Author: Igal Sapir 
AuthorDate: Sun Oct 6 13:33:42 2024 -0700

RateLimitFilter code cleanup per commit feedback
---
 java/org/apache/catalina/filters/RateLimitFilter.java | 4 +---
 test/org/apache/catalina/filters/TestRateLimitFilter.java | 7 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/filters/RateLimitFilter.java 
b/java/org/apache/catalina/filters/RateLimitFilter.java
index 8b323b136d..44d70add50 100644
--- a/java/org/apache/catalina/filters/RateLimitFilter.java
+++ b/java/org/apache/catalina/filters/RateLimitFilter.java
@@ -18,7 +18,6 @@
 package org.apache.catalina.filters;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
@@ -166,8 +165,7 @@ public class RateLimitFilter extends FilterBase {
 
 try {
 rateLimiter = 
(RateLimiter)Class.forName(rateLimitClassName).getConstructor().newInstance();
-} catch (InstantiationException | IllegalAccessException | 
InvocationTargetException |
- NoSuchMethodException | ClassNotFoundException e) {
+} catch (ReflectiveOperationException e) {
 throw new ServletException(e);
 }
 
diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index c43a85b395..92005cf403 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -56,11 +56,10 @@ public class TestRateLimitFilter extends TomcatBaseTest {
 MockFilterChain filterChain = new MockFilterChain();
 RateLimitFilter rateLimitFilter = testRateLimitFilter(filterDef, root);
 
-FastRateLimiter tbc = (FastRateLimiter) rateLimitFilter.rateLimiter;
+FastRateLimiter fastRateLimiter = (FastRateLimiter) 
rateLimitFilter.rateLimiter;
 
-int allowedRequests = (int) 
Math.round(tbc.getBucketCounter().getRatio() * bucketRequests);
-
-long sleepTime = tbc.getBucketCounter().getMillisUntilNextBucket();
+int allowedRequests = fastRateLimiter.getRequests();
+long sleepTime = 
fastRateLimiter.getBucketCounter().getMillisUntilNextBucket();
 System.out.printf("Sleeping %d millis for the next time bucket to 
start\n", Long.valueOf(sleepTime));
 Thread.sleep(sleepTime);
 


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



Re: (tomcat) branch 11.0.x updated: Improve HTML output of DefaultServlet

2024-10-06 Thread Mark Thomas

On 06/10/2024 19:54, Michael Osipov wrote:

On 2024/10/06 18:43:27 Mark Thomas wrote:

On 06/10/2024 19:04, Michael Osipov wrote:

On 2024/10/06 14:18:34 Mark Thomas wrote:

On 05/10/2024 18:23, micha...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
new 4108bf15b5 Improve HTML output of DefaultServlet
4108bf15b5 is described below

commit 4108bf15b54cc82b56736edf07cff4561e8d457c
Author: Michael Osipov 
AuthorDate: Sat Oct 5 19:18:17 2024 +0200

   Improve HTML output of DefaultServlet


How does this improve the output? It appears to just be adding
(unnecessary) new lines in the HTML source.


I agree with you so far that my wording is bad on the summary. It does not 
change the HTML code, but simply makes line breaks consistent. No functional 
change.


OK. Not something that is high on my list of priotities but since we are
here...

Should the priority be to make the source clear / readable or should we
be aiming to minimise it (remove line breaks, comments etc) for
(marginally) better response time. I can see arguments for both.


Both objectives are valid.


While bandwidth is certainly more plentiful than it was 20 years ago, it
still pains me to see any of it wasted. Although looking at a typical
website I might be the only one that feels that way.

If the source is readable then it makes it easier for us to work with if
we ever want to change anything. It is also easier for contributors to
patch.

Given the small scale of the potential reduction, the maintenance
benefits and the (relatively) small resources concerned I think I am
leaning towards readable but what does everyone else think?


Personally, I prefer readability over compactness because it makes maintenance 
and contributions easier. I don't mind a flag for this, but those few bytes 
saved are negligiable. One still can use GZIP compression if the client 
requests it or even a filter to compact the source. I really often use Ctrl+U 
to look at source code and often I need to format it to make it reviewable :-(


I think an additional flag is probably overkill in this instance.

Mark

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