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

W-16263266: expressionExecutor in adaptor is disposed more than once #13664

Open
wants to merge 1 commit into
base: support/4.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -33,6 +33,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
Expand Down Expand Up @@ -488,6 +489,20 @@ public void flowNameBinding() {
assertThat(result.getValue(), is(flowName));
}

@Test
public void expressionExecutorIsNotDisposedWhenAlreadyDisposed() throws MuleException {
DataWeaveExpressionLanguageAdaptor expressionLanguageAdaptor =
new DataWeaveExpressionLanguageAdaptor(mock(MuleContext.class, RETURNS_DEEP_STUBS), registry,
genericExpressionLanguageService, getFeatureFlaggingService());
ExpressionLanguage mockedExpressionLanguage = mock(ExpressionLanguage.class);
when(genericExpressionLanguageService.create(any())).thenReturn(mockedExpressionLanguage);
expressionLanguageAdaptor.initialise();
expressionLanguageAdaptor.dispose();
verify(mockedExpressionLanguage, times(1)).dispose();
expressionLanguageAdaptor.dispose();
verify(mockedExpressionLanguage, times(1)).dispose();
}

@Test
public void payloadExpressionShouldNotBeEvaluate() throws MuleException {
DataWeaveExpressionLanguageAdaptor expressionLanguageAdaptor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class DataWeaveExpressionLanguageAdaptor implements ExtendedExpressionLan
private List<BindingContext> globalBindings = new LinkedList<>();
private volatile boolean initialised = false;

private boolean disposed = false;

@Inject
public DataWeaveExpressionLanguageAdaptor(MuleContext muleContext, Registry registry,
DefaultExpressionLanguageFactoryService service,
Expand Down Expand Up @@ -289,9 +291,10 @@ private BindingContext bindingContextFor(ComponentLocation componentLocation, Co
}

@Override
public void dispose() {
if (expressionExecutor != null) {
public synchronized void dispose() {
if (expressionExecutor != null && !disposed) {
expressionExecutor.dispose();
disposed = true;
}
}

Expand Down