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

HW-53073: Allow Thread Interruption for WriteLockManager #1

Open
wants to merge 14 commits into
base: 2.7
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.lang.Boolean.parseBoolean;

/**
* INTERNAL:
* <p>
Expand All @@ -57,21 +59,19 @@
* @since 10.0.3
*/
public class WriteLockManager {
private static Logger logger = Logger.getLogger(WriteLockManager.class.getSimpleName());

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

// this will allow us to prevent a readlock thread from looping forever.
public static final int MAXTRIES = 10000;

public static final int MAX_WAIT = 600000; //10 mins
private static volatile boolean interruptionEnabled;

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty simple. best of the hacky approaches imo.


public static void setInterruptionEnabled(boolean interruptionEnabled) {
WriteLockManager.interruptionEnabled = interruptionEnabled;
}

/* This attribute stores the list of threads that have had a problem acquiring locks */
/* the first element in this list will be the prevailing thread */
Expand Down Expand Up @@ -107,7 +107,7 @@ public Map acquireLocksForClone(Object objectForClone, ClassDescriptor descripto
} catch (InterruptedException ex) {
//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
jportner-hw marked this conversation as resolved.
Show resolved Hide resolved
if (interruptionEnabled) {
if (isInterruptionEnabled()) {
logger.log(Level.SEVERE,
"EclipseLinkLockHandler has set interruption flag to TRUE. Allowing interrupts");
throw ConcurrencyException.waitWasInterrupted(ex.getMessage());
Expand Down