Skip to content

Commit

Permalink
[WFLY-18537] Memory leak, remove XAResourceRecovery before stopping c…
Browse files Browse the repository at this point in the history
…ontext
  • Loading branch information
marcosgopen committed Sep 25, 2023
1 parent d7d7dfa commit 69f16f0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public final class LocalTransactionContextService implements Service<LocalTransa
private final InjectedValue<XAResourceRecoveryRegistry> xaResourceRecoveryRegistryInjector = new InjectedValue<>();
private final InjectedValue<ServerEnvironment> serverEnvironmentInjector = new InjectedValue<>();
private final int staleTransactionTime;
private JBossLocalTransactionProvider provider;

public LocalTransactionContextService(final int staleTransactionTime) {
this.staleTransactionTime = staleTransactionTime;
Expand All @@ -62,7 +63,8 @@ public void start(final StartContext context) throws StartException {
builder.setXAResourceRecoveryRegistry(xaResourceRecoveryRegistryInjector.getValue());
builder.setXARecoveryLogDirRelativeToPath(serverEnvironmentInjector.getValue().getServerDataDir().toPath());
builder.setStaleTransactionTime(staleTransactionTime);
final LocalTransactionContext transactionContext = this.context = new LocalTransactionContext(builder.build());
this.provider = builder.build();
final LocalTransactionContext transactionContext = this.context = new LocalTransactionContext(this.provider);
// TODO: replace this with per-CL settings for embedded use and to support remote UserTransaction
doPrivileged((PrivilegedAction<Void>) () -> {
LocalTransactionContext.getContextManager().setGlobalDefault(transactionContext);
Expand All @@ -78,6 +80,7 @@ public void start(final StartContext context) throws StartException {
}

public void stop(final StopContext context) {
this.provider.removeXAResourceRecovery(xaResourceRecoveryRegistryInjector.getValue());
this.context = null;
// TODO: replace this with per-CL settings for embedded use and to support remote UserTransaction
doPrivileged((PrivilegedAction<Void>) () -> {
Expand Down

0 comments on commit 69f16f0

Please sign in to comment.