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

[4.x.x] Fix an issue where XQuery Trigger state may leak #5483

Merged
Merged
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 @@ -405,6 +405,7 @@ private void execute(final TriggerPhase phase, final TriggerEvent event, final D
compiledQuery = getScript(broker, transaction);
if (compiledQuery == null) {
// NOTE: can occur if there is no such XQueryTrigger library module available in the database
TriggerStatePerThread.clearIfFinished(phase);
return;
}
} catch (final TriggerException e) {
Expand Down Expand Up @@ -447,6 +448,7 @@ private void execute(final TriggerPhase phase, final TriggerEvent event, final D
if (LOG.isDebugEnabled()) {
LOG.debug("No such function '" + functionName + "' in XQueryTrigger: " + compiledQuery.getSource());
}
TriggerStatePerThread.clearIfFinished(phase);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.exist.test.TestConstants.TEST_COLLECTION_URI;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.*;

public class StoreResourceTest {
Expand Down Expand Up @@ -80,7 +80,7 @@ public void replaceXmlAsOwner() throws AuthenticationException, LockException, P
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
final long originalDoc1LastModified = getLastModified(USER1_DOC1);
replaceXmlDoc(user2, USER1_DOC1, "<something>else</something>");
checkAttributes(USER1_DOC1, USER1_NAME, GROUP1_NAME, USER1_DOC1_MODE, equalTo(getCreated(USER1_DOC1)), not(originalDoc1LastModified));
checkAttributes(USER1_DOC1, USER1_NAME, GROUP1_NAME, USER1_DOC1_MODE, equalTo(getCreated(USER1_DOC1)), greaterThanOrEqualTo(originalDoc1LastModified));
}

/**
Expand All @@ -91,7 +91,7 @@ public void replaceBinaryAsGroupMember() throws AuthenticationException, LockExc
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
final long originalDoc1LastModified = getLastModified(USER1_BIN_DOC1);
replaceBinDoc(user2, USER1_BIN_DOC1, "something else");
checkAttributes(USER1_BIN_DOC1, USER1_NAME, GROUP1_NAME, USER1_BIN_DOC1_MODE, equalTo(getCreated(USER1_BIN_DOC1)), not(originalDoc1LastModified));
checkAttributes(USER1_BIN_DOC1, USER1_NAME, GROUP1_NAME, USER1_BIN_DOC1_MODE, equalTo(getCreated(USER1_BIN_DOC1)), greaterThanOrEqualTo(originalDoc1LastModified));
}

private void replaceXmlDoc(final Subject execAsUser, final XmldbURI docName, final String content) throws EXistException, PermissionDeniedException, LockException, IOException, SAXException {
Expand Down