From 1e3fc55c24534c376cf35de78516271113c65fd7 Mon Sep 17 00:00:00 2001 From: joshua bauer Date: Wed, 20 Sep 2017 14:34:17 -0700 Subject: [PATCH] Undertow version change. --- pom.xml | 2 +- .../io/sinistral/proteus/server/ServerRequest.java | 11 +++++++++-- .../io/sinistral/proteus/services/AssetsService.java | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a705553..97ff6fb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 io.sinistral proteus-core - 0.1.6-SNAPSHOT + 0.1.7-SNAPSHOT proteus core Proteus is an extremely light, fast, and flexible Java REST API framework built atop Undertow. http://github.com/noboomu/proteus diff --git a/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/src/main/java/io/sinistral/proteus/server/ServerRequest.java index 4bedd3f..6d888cb 100644 --- a/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -11,6 +11,7 @@ import java.util.Map; import java.util.concurrent.Executor; +import org.xnio.Pool; import org.xnio.Pooled; import org.xnio.channels.StreamSourceChannel; @@ -142,7 +143,8 @@ private void extractBytes() throws IOException { this.exchange.startBlocking(); - + + try (Pooled pooled = exchange.getConnection().getBufferPool().allocate()){ ByteBuffer buf = pooled.getResource(); @@ -159,8 +161,13 @@ private void extractBytes() throws IOException int pos = buf.limit(); ByteBuffer buffer = ByteBuffer.allocate(pos); + + ByteBuffer src = buf.duplicate(); + src.position(0); + src.limit(0 + pos); + buffer.put(src); - System.arraycopy(buf.array(), 0, buffer.array(), 0, pos); + //System.arraycopy(buf.array(), 0, buffer.array(), 0, pos); exchange.putAttachment(BYTE_BUFFER_KEY, buffer); diff --git a/src/main/java/io/sinistral/proteus/services/AssetsService.java b/src/main/java/io/sinistral/proteus/services/AssetsService.java index 3ff21ef..f41861b 100644 --- a/src/main/java/io/sinistral/proteus/services/AssetsService.java +++ b/src/main/java/io/sinistral/proteus/services/AssetsService.java @@ -68,7 +68,7 @@ public RoutingHandler get() final FileResourceManager fileResourceManager = new FileResourceManager(Paths.get(assetsDirectoryName).toFile(),1024l); - router.add(Methods.GET, assetsPath + "/*", io.undertow.Handlers.rewrite("regex('" + assetsPath + "/(.*)')", "/$1", getClass().getClassLoader(), new ResourceHandler(fileResourceManager) + router.add(Methods.GET, assetsPath + "/*", io.undertow.Handlers.rewrite("regex['" + assetsPath + "/(.*)']", "/$1", getClass().getClassLoader(), new ResourceHandler(fileResourceManager) .setCachable(TruePredicate.instance()) .setCacheTime(assetsCacheTime) ));