Skip to content

Commit 2a8febe

Browse files
author
Christoph Läubrich
committed
No need for atomic reference
1 parent 7f0641c commit 2a8febe

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

platform-tests/src/test/java/org/junit/platform/reporting/open/xml/OpenTestReportGeneratingListenerTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void writesXmlReportToSocket(@TempDir Path tempDirectory) throws Exception {
328328
});
329329

330330
// Start a server socket to receive the XML
331-
var xmlContent = new AtomicReference<String>();
331+
var builder = new StringBuilder();
332332
var latch = new CountDownLatch(1);
333333

334334
try (var serverSocket = new ServerSocket(0, 50, InetAddress.getLoopbackAddress())) { // Use any available port
@@ -339,12 +339,10 @@ void writesXmlReportToSocket(@TempDir Path tempDirectory) throws Exception {
339339
try (Socket clientSocket = serverSocket.accept();
340340
var reader = new BufferedReader(
341341
new InputStreamReader(clientSocket.getInputStream(), StandardCharsets.UTF_8))) {
342-
var builder = new StringBuilder();
343342
String line;
344343
while ((line = reader.readLine()) != null) {
345344
builder.append(line).append("\n");
346345
}
347-
xmlContent.set(builder.toString());
348346
}
349347
catch (Exception e) {
350348
fail(e);
@@ -364,7 +362,7 @@ void writesXmlReportToSocket(@TempDir Path tempDirectory) throws Exception {
364362
assertThat(serverThread.join(Duration.ofSeconds(10))).isTrue();
365363

366364
// Verify XML was received
367-
assertThat(xmlContent.get()) //
365+
assertThat(builder.toString()) //
368366
.isNotNull() //
369367
.contains("<e:events") //
370368
.contains("dummy") //

0 commit comments

Comments
 (0)