Skip to content

Commit

Permalink
Address situation where a throwable during forceKillAcquires() leaves…
Browse files Browse the repository at this point in the history
… the force_kill_acquires flag set to true.
  • Loading branch information
swaldman committed Mar 14, 2019
1 parent 042e90d commit 5a9b0eb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dist-static/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- Address situation where a throwable during forceKillAcquires() left the force_kill_acquires flag
set to true, making it impossible for the pool to restart acquisition attempts on recovery. We
now unset the flag under any circumstance, but log interrupts or unexpected throwables, and make
a best effort to complete the intended expiration of waiting clients by throwing InterruptException
Many thanks to Stefan Cordes (rscadrde on github), Vipin Nair (swvist on github), and Łukasz Jąder
(ljader on github) for their work on this issue.
c3p0-0.9.5.3
-- Address CVE-2018-20433, https://nvd.nist.gov/vuln/detail/CVE-2018-20433 re liberal parsing of
XML config. By default, c3p0 no longer expands entity references in XML config files. This
Expand Down
38 changes: 38 additions & 0 deletions src/java/com/mchange/v2/resourcepool/BasicResourcePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,44 @@ private synchronized void forceKillAcquires() throws InterruptedException
}
force_kill_acquires = false;
}
catch ( InterruptedException e )
{
// We were interrupted while trying to kill acquireWaiter Threads
// let's make a best-effort attempt to finish our work
for (Iterator ii = acquireWaiters.iterator(); ii.hasNext(); )
((Thread) ii.next()).interrupt();

// and let's log the issue
if (logger.isLoggable( MLevel.WARNING ))
logger.log( MLevel.WARNING,
"An interrupt left an attempt to gently clear threads waiting on resource acquisition potentially incomplete! " +
"We have made a best attempt to finish that by interrupt()ing the waiting Threads." );

force_kill_acquires = false;

e.fillInStackTrace();
throw e;
}
catch ( Throwable ick )
{
// let's still make a best-effort attempt to finish our work
for (Iterator ii = acquireWaiters.iterator(); ii.hasNext(); )
((Thread) ii.next()).interrupt();

// and let's log the issue, with the throwable
if (logger.isLoggable( MLevel.SEVERE ))
logger.log( MLevel.SEVERE,
"An unexpected problem caused our attempt to gently clear threads waiting on resource acquisition to fail! " +
"We have made a best attempt to finish that by interrupt()ing the waiting Threads.",
ick );

force_kill_acquires = false;

// we still throw the unexpected throwable
if ( ick instanceof RuntimeException ) throw (RuntimeException) ick;
else if ( ick instanceof Error ) throw (Error) ick;
else throw new RuntimeException("Wrapped unexpected Throwable.", ick );
}
finally
{ otherWaiters.remove( t ); }
}
Expand Down

0 comments on commit 5a9b0eb

Please sign in to comment.