From e7a1a6038f7e62238e725d06ee57c366b3275628 Mon Sep 17 00:00:00 2001 From: ZhanwangZhou Date: Wed, 23 Oct 2024 16:20:50 -0500 Subject: [PATCH] Fix non-deterministic behavior in testMultipartFormData --- .../org/nanohttpd/junit/protocols/http/HttpServerTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/nanohttpd/junit/protocols/http/HttpServerTest.java b/core/src/test/java/org/nanohttpd/junit/protocols/http/HttpServerTest.java index d9d3c5c7..e56e8bc0 100644 --- a/core/src/test/java/org/nanohttpd/junit/protocols/http/HttpServerTest.java +++ b/core/src/test/java/org/nanohttpd/junit/protocols/http/HttpServerTest.java @@ -49,6 +49,7 @@ import java.io.OutputStream; import java.io.StringReader; import java.net.InetAddress; +import java.util.Collections; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -230,7 +231,9 @@ public Response serve(IHTTPSession session) { try { session.parseBody(this.files); - for (String key : files.keySet()) { + List keyList = new ArrayList<>(files.keySet()); + Collections.sort(keyList); + for (String key : keyList) { responseMsg.append(key); } } catch (Exception e) {