Tim,

On 8/31/23 04:03, Scott,Tim wrote:
Hi Chris,

Hi all,

Thanks for your responses. I think I've found the problem.

My wrapping class which detects the invocation of the close() method to 
decrement its count is no longer decrementing its count because 
method.getDeclaringClass() has changed from java.sql.Connection to 
java.lang.AutoCloseable.

Is it safe to check for either java.sql.Connection or java.lang.AutoCloseable?

.. or should I just check for the "close()" method invocation, based on the 
fact that I'm not wrapping anything (here) that I shouldn't be counting?

That depends upon the point of the whole thing. What, um, is the point
of the whole thing?

The wrapping class is to limit the number of active connections, waiting up to a configured time 
for one to become idle if necessary. I can't recall if this was because the timeout or the limit 
was not configurable when this was first written in 2007. The count is decremented if the called 
method is "close" and it's from the expected Class. Previously this was 
java.sql.Connection, now it also accepts "close" from java.lang.AutoCloseable to 
decrement the count.

What you describe above is the job of a connection pool, and Tomcat provides two of them for your selection. There are a host of others available for Java as well. I highly recommend that you use one of those instead of trying to re-invent this particular wheel.

As the count wasn't being decremented, the active concurrent limit was quickly 
(believed to be) reached.

I discussed this with a colleague who had previously worked with this 
application. There was some consternation about the approach but it was agreed 
that this was the least risk answer - for an application we're dropping support 
for in December, it is not worth rewriting. This will at least enable 
deployments to address vulnerabilities fixed in 9.0.71+.

Okay :)

-chris

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

Reply via email to