summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-05-22 17:58:10 +0200
committerSimon Rettberg2023-05-22 17:58:10 +0200
commit189efc3254cf41b878ba69a6a48f1e2d9d31d6ea (patch)
treeac826a7220b2bc0c223ff2688cd0da37c0e66529
parent[server] Add one second timeout to cache updates (diff)
downloadtutor-module-189efc3254cf41b878ba69a6a48f1e2d9d31d6ea.tar.gz
tutor-module-189efc3254cf41b878ba69a6a48f1e2d9d31d6ea.tar.xz
tutor-module-189efc3254cf41b878ba69a6a48f1e2d9d31d6ea.zip
[server] Restore Java 1.8 compat for now
Since this is really the only place so far, refactor to support older Java. Let's move to 11+ after the next release.
-rw-r--r--dozentenmodulserver/pom.xml6
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/JsonHttpListener.java10
2 files changed, 12 insertions, 4 deletions
diff --git a/dozentenmodulserver/pom.xml b/dozentenmodulserver/pom.xml
index 3493feb8..26666ac5 100644
--- a/dozentenmodulserver/pom.xml
+++ b/dozentenmodulserver/pom.xml
@@ -140,9 +140,9 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
- <source>11</source>
- <target>11</target>
- <release>11</release>
+ <source>1.8</source>
+ <target>1.8</target>
+ <release>8</release>
<compilerArgument>-Xlint:all</compilerArgument>
</configuration>
</plugin>
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/JsonHttpListener.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/JsonHttpListener.java
index 55c09756..cec5dd5f 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/JsonHttpListener.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/JsonHttpListener.java
@@ -57,7 +57,15 @@ public class JsonHttpListener extends NanoHTTPD {
return new Response(Response.Status.BAD_REQUEST, "text/plain; charset=UTF-8",
"No Content-Length provided");
- byte[] buffer = session.getInputStream().readNBytes(len);
+ byte[] buffer = new byte[len];
+ int pos = 0;
+ while (pos < len) {
+ int ret = session.getInputStream().read(buffer, pos, len - pos);
+ if (ret <= 0)
+ return new Response(Response.Status.BAD_REQUEST, "text/plain; charset=UTF-8",
+ "Request content truncated (" + pos + "/" + len + ")");
+ pos += ret;
+ }
TMemoryBuffer inbuffer = new TMemoryBuffer(buffer.length);
inbuffer.write(buffer);
TProtocol inprotocol = new TJSONProtocol(inbuffer);