diff --git a/core/src/main/java/io/sinistral/proteus/server/Extractors.java b/core/src/main/java/io/sinistral/proteus/server/Extractors.java index 9da892e..af4f0a9 100644 --- a/core/src/main/java/io/sinistral/proteus/server/Extractors.java +++ b/core/src/main/java/io/sinistral/proteus/server/Extractors.java @@ -3,6 +3,19 @@ */ package io.sinistral.proteus.server; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.google.inject.Inject; +import io.sinistral.proteus.server.predicates.ServerPredicates; +import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.form.FormDataParser; +import io.undertow.util.HttpString; +import io.undertow.util.Methods; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.lang.reflect.Method; @@ -19,21 +32,6 @@ import java.util.Objects; import java.util.function.Function; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.google.inject.Inject; - -import io.sinistral.proteus.server.predicates.ServerPredicates; -import io.undertow.server.HttpServerExchange; -import io.undertow.server.handlers.form.FormDataParser; -import io.undertow.util.HttpString; -import io.undertow.util.Methods; - /** * @author jbauer */ @@ -41,22 +39,20 @@ public class Extractors { private static Logger log = LoggerFactory.getLogger(Extractors.class.getCanonicalName()); - @Inject + @Inject public static XmlMapper XML_MAPPER; - @Inject + @Inject public static ObjectMapper OBJECT_MAPPER; - - public static JsonNode parseJson(byte[] bytes) { - try - { - return OBJECT_MAPPER.readTree(bytes); - } catch (Exception e) - { - log.error(e.getMessage(),e); - return null; - } - }; + + public static JsonNode parseJson(byte[] bytes) { + try { + return OBJECT_MAPPER.readTree(bytes); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + } public static class Optional { diff --git a/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java index 7c52580..56e4187 100644 --- a/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -36,14 +36,9 @@ */ public class ServerRequest { - protected static final Receiver.ErrorCallback ERROR_CALLBACK = new Receiver.ErrorCallback() - { - @Override - public void error(HttpServerExchange exchange, IOException e) - { - exchange.putAttachment(DefaultResponseListener.EXCEPTION, e); - exchange.endExchange(); - } + protected static final Receiver.ErrorCallback ERROR_CALLBACK = (exchange, e) -> { + exchange.putAttachment(DefaultResponseListener.EXCEPTION, e); + exchange.endExchange(); }; public static final AttachmentKey BYTE_BUFFER_KEY = AttachmentKey.create(ByteBuffer.class); @@ -109,16 +104,11 @@ public HttpServerExchange exchange() private void extractBytes() throws IOException { - this.exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback() - { - @Override - public void handle(HttpServerExchange exchange, byte[] message) - { - ByteBuffer buffer = ByteBuffer.wrap(message); - - exchange.putAttachment(BYTE_BUFFER_KEY, buffer); - } - },ERROR_CALLBACK); + this.exchange.getRequestReceiver().receiveFullBytes((exchange, message) -> { + ByteBuffer buffer = ByteBuffer.wrap(message); + + exchange.putAttachment(BYTE_BUFFER_KEY, buffer); + },ERROR_CALLBACK); } private void extractFormParameters(final FormData formData)