Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit for thread interruption #1

Open
wants to merge 1 commit into
base: 2.7.11_branch
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public class WriteLockManager {
*/
private static final Boolean ALLOW_INTERRUPTED_EXCEPTION_TO_BE_FIRED_UP_TRUE = true;

private static final Logger logger = Logger.getLogger(WriteLockManager.class.getSimpleName());

private static boolean isInterruptionEnabled() {
String value = System.getProperty("interruptionEnabled");
return Boolean.parseBoolean(value);
}

/**
* This a map from a thread to cache keys the thread is finding itself not being able to acquire. This map is
* important to explain why a thread might be stuck in a stack trace of the form: {@code
Expand Down Expand Up @@ -176,7 +183,15 @@ public Map acquireLocksForClone(Object objectForClone, ClassDescriptor descripto
toWaitOn.wait(ConcurrencyUtil.SINGLETON.getAcquireWaitTime());// wait for lock on object to be released
}
} catch (InterruptedException ex) {
// Ignore exception thread should continue.
//https://jira.site1.hyperwallet.local/browse/HW-53073
//Custom change to allow thread interruptions for bad threads stuck in org.eclipse.persistence.internal.helper.WriteLockManager.acquireLocksForClone pattern
if (isInterruptionEnabled()) {
logger.log(Level.SEVERE,
"EclipseLinkLockHandler has set interruption flag to TRUE. Allowing interrupts");
throw ConcurrencyException.waitWasInterrupted(ex.getMessage());
}
logger.log(Level.WARNING,
"EclipseLinkLockHandler has not set the interruption flag to TRUE. Will not interrupt");
}
}
Object waitObject = toWaitOn.getObject();
Expand All @@ -188,6 +203,7 @@ public Map acquireLocksForClone(Object objectForClone, ClassDescriptor descripto
toWaitOn = acquireLockAndRelatedLocks(objectForClone, lockedObjects, refreshedObjects, cacheKey, descriptor, cloningSession);
if ((toWaitOn != null) && ((++tries) > MAXTRIES)) {
// If we've tried too many times abort.
logger.log(Level.WARNING, "Interruption done by EclipseLink Library.");
throw ConcurrencyException.maxTriesLockOnCloneExceded(objectForClone);
}
}
Expand Down