[New] Added ThreadLocal to TX for logging when multiple TX open in same thread
This commit is contained in:
parent
b828ad1e79
commit
d218da5963
|
@ -103,6 +103,8 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
private Certificate certificate;
|
private Certificate certificate;
|
||||||
private PrivilegeContext privilegeContext;
|
private PrivilegeContext privilegeContext;
|
||||||
|
|
||||||
|
private static final ThreadLocal<StrolchTransaction> threadLocalTx = new ThreadLocal<>();
|
||||||
|
|
||||||
public AbstractTransaction(ComponentContainer container, StrolchRealm realm, Certificate certificate, String action,
|
public AbstractTransaction(ComponentContainer container, StrolchRealm realm, Certificate certificate, String action,
|
||||||
boolean readOnly) {
|
boolean readOnly) {
|
||||||
DBC.PRE.assertNotNull("container must be set!", container); //$NON-NLS-1$
|
DBC.PRE.assertNotNull("container must be set!", container); //$NON-NLS-1$
|
||||||
|
@ -110,6 +112,11 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
DBC.PRE.assertNotNull("certificate must be set!", certificate); //$NON-NLS-1$
|
DBC.PRE.assertNotNull("certificate must be set!", certificate); //$NON-NLS-1$
|
||||||
DBC.PRE.assertNotNull("action must be set!", action); //$NON-NLS-1$
|
DBC.PRE.assertNotNull("action must be set!", action); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (threadLocalTx.get() != null)
|
||||||
|
logger.error("THIS THREAD HAS ALREADY OPENED A TX!");
|
||||||
|
else
|
||||||
|
threadLocalTx.set(this);
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.privilegeHandler = container.getPrivilegeHandler();
|
this.privilegeHandler = container.getPrivilegeHandler();
|
||||||
this.realm = (InternalStrolchRealm) realm;
|
this.realm = (InternalStrolchRealm) realm;
|
||||||
|
@ -1498,6 +1505,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
releaseElementLocks();
|
releaseElementLocks();
|
||||||
|
threadLocalTx.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1516,6 +1524,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
this.txResult.setState(TransactionState.FAILED);
|
this.txResult.setState(TransactionState.FAILED);
|
||||||
} finally {
|
} finally {
|
||||||
releaseElementLocks();
|
releaseElementLocks();
|
||||||
|
threadLocalTx.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,6 +1568,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
this.txResult.setState(TransactionState.FAILED);
|
this.txResult.setState(TransactionState.FAILED);
|
||||||
} finally {
|
} finally {
|
||||||
releaseElementLocks();
|
releaseElementLocks();
|
||||||
|
threadLocalTx.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue