Skip to content

Commit 8a52ff8

Browse files
hmadala001Copilot
andcommitted
MLE-33565 Make TestE2ENumberOfConcurrentUsers error buffer thread-safe
Use StringBuffer for msgEx, which is appended to by concurrent worker threads, and move the assertion out of the finally block so it only resets the concurrent-request-limit. Co-authored-by: Copilot <[email protected]>
1 parent 2d07fb2 commit 8a52ff8

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/ClientApiFunctionalTest.java‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ public void TestE2EModuleNotFound() {
306306
// (default). Expect to see ForbiddenUser when same user logins multiple times.
307307
@Test
308308
public void TestE2ENumberOfConcurrentUsers() throws InterruptedException {
309-
StringBuilder msgEx = new StringBuilder();
309+
// Appended to concurrently by multiple worker threads, so it must be thread-safe.
310+
StringBuffer msgEx = new StringBuffer();
310311
Thread w1, w2, w3;
311312

312313
System.out.println("Running TestE2ENumberOfConcurrentUsers");
@@ -348,12 +349,13 @@ public void run() {
348349
w3.join();
349350
} finally {
350351
modifyConcurrentUsersOnHttpServer(serverName, 0);
351-
System.out.println("Exception from API responses of call are " + msgEx);
352-
assertTrue(
353-
msgEx.toString().contains("Local message: failed to POST at") &&
354-
msgEx.toString().contains("/ext/TestE2EIntegerParamReturnDouble/TestE2EIntegerParamReturnDoubleErrorCond.sjs"),
355-
"Unexpected error message: " + msgEx);
356352
}
353+
354+
System.out.println("Exception from API responses of call are " + msgEx);
355+
assertTrue(
356+
msgEx.toString().contains("Local message: failed to POST at") &&
357+
msgEx.toString().contains("/ext/TestE2EIntegerParamReturnDouble/TestE2EIntegerParamReturnDoubleErrorCond.sjs"),
358+
"Unexpected error message: " + msgEx);
357359
}
358360

359361
// Test users with invalid roles

0 commit comments

Comments
 (0)