Skip to content

Commit

Permalink
Fix for testBug21934573.
Browse files Browse the repository at this point in the history
  • Loading branch information
soklakov committed Nov 27, 2018
1 parent e0f4c5c commit 63e91a4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7867,6 +7867,8 @@ public void run() {
}, testConn.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(testConn)) + "_thread").start();
}

TestBug21934573ExceptionInterceptor.initialized = true;

// Let the two concurrent threads run concurrently for 2secs, at the most, before checking if they hit a deadlock situation.
// Wait two times 1sec as TestBug21934573ExceptionInterceptor.mainThreadLock.notify() should be called twice (once per secondary thread).
synchronized (TestBug21934573ExceptionInterceptor.mainThreadLock) {
Expand Down Expand Up @@ -7903,6 +7905,7 @@ public void run() {
* SQLException (not only communication related exceptions) and calls directly methods changing servers lists from ReplicationConnectionGroup.
*/
public static class TestBug21934573ExceptionInterceptor implements ExceptionInterceptor {
static boolean initialized = false;
static Object mainThreadLock = new Object();
private static boolean threadIsWaiting = false;
private static final Set<String> replConnGroupLocks = Collections.synchronizedSet(new HashSet<String>());
Expand All @@ -7920,6 +7923,10 @@ public void destroy() {
}

public Exception interceptException(Exception sqlEx) {
if (!initialized) {
return sqlEx;
}

// Make sure both threads execute the code after the synchronized block concurrently.
synchronized (TestBug21934573ExceptionInterceptor.class) {
if (threadIsWaiting) {
Expand Down

0 comments on commit 63e91a4

Please sign in to comment.