Browse Source

Remove plaintext "optimization" in undertow test (#3642)

* Remove plaintext "optimization" in undertow test

The `buffer.duplicate()` line was throwing an OutOfMemoryError for me
locally, so this optimization wasn't safe.

* Remove an unused import
Michael Hixson 7 years ago
parent
commit
ef4077f7cc
1 changed files with 1 additions and 11 deletions
  1. 1 11
      frameworks/Java/undertow/src/main/java/hello/HelloWebServer.java

+ 1 - 11
frameworks/Java/undertow/src/main/java/hello/HelloWebServer.java

@@ -1,7 +1,6 @@
 package hello;
 package hello;
 
 
 import static io.undertow.util.Headers.CONTENT_TYPE;
 import static io.undertow.util.Headers.CONTENT_TYPE;
-import static java.nio.charset.StandardCharsets.US_ASCII;
 import static java.util.Comparator.comparing;
 import static java.util.Comparator.comparing;
 
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -83,18 +82,9 @@ public final class HelloWebServer {
   }
   }
 
 
   static HttpHandler plaintextHandler() {
   static HttpHandler plaintextHandler() {
-    // Normally, one would send the string "Hello, World!" directly.  Reusing a
-    // ByteBuffer is a micro-optimization that is explicitly permitted by the
-    // plaintext test requirements.
-
-    var bytes = "Hello, World!".getBytes(US_ASCII);
-    var buffer = ByteBuffer.allocateDirect(bytes.length);
-    buffer.put(bytes);
-    buffer.flip();
-
     return exchange -> {
     return exchange -> {
       exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain");
       exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain");
-      exchange.getResponseSender().send(buffer.duplicate());
+      exchange.getResponseSender().send("Hello, World!");
     };
     };
   }
   }