diff --git a/frameworks/Java/smart-socket/pom.xml b/frameworks/Java/smart-socket/pom.xml
index e4bbc87e873..81fbc295b98 100644
--- a/frameworks/Java/smart-socket/pom.xml
+++ b/frameworks/Java/smart-socket/pom.xml
@@ -8,10 +8,10 @@
jar
UTF-8
- 11
- 11
+ 17
+ 17
2.17.1
- 0.2.1-SNAPSHOT
+ 0.6-SNAPSHOT
5.0.0
0.9.23
diff --git a/frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile b/frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile
index b6fa2e31680..8b1cbe79930 100644
--- a/frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile
+++ b/frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile
@@ -1,13 +1,13 @@
-FROM maven:3.6.1-jdk-11-slim as maven
+FROM maven:3.8.6-openjdk-18-slim as maven
WORKDIR /smart-socket
COPY pom.xml pom.xml
COPY src src
RUN mvn compile assembly:single -q
-FROM openjdk:11.0.3-jdk-slim
+FROM openjdk:21-jdk-slim
WORKDIR /smart-socket
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar
EXPOSE 8080
-CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-cp", "app.jar", "org.smartboot.servlet.Bootstrap"]
+CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-cp", "app.jar", "org.smartboot.servlet.Bootstrap"]
diff --git a/frameworks/Java/smart-socket/smart-socket.dockerfile b/frameworks/Java/smart-socket/smart-socket.dockerfile
index f51ddcbd178..b40ad2c8d43 100644
--- a/frameworks/Java/smart-socket/smart-socket.dockerfile
+++ b/frameworks/Java/smart-socket/smart-socket.dockerfile
@@ -1,13 +1,13 @@
-FROM maven:3.6.1-jdk-11-slim as maven
+FROM maven:3.8.6-openjdk-18-slim as maven
WORKDIR /smart-socket
COPY pom.xml pom.xml
COPY src src
RUN mvn compile assembly:single -q
-FROM openjdk:11.0.3-jdk-slim
+FROM openjdk:21-jdk-slim
WORKDIR /smart-socket
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar
EXPOSE 8080
-CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-cp", "app.jar", "org.smartboot.http.Bootstrap"]
+CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-cp", "app.jar", "org.smartboot.http.Bootstrap"]
diff --git a/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java b/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java
index 0aa0f44a2d1..b20525ec571 100644
--- a/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java
+++ b/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java
@@ -1,11 +1,12 @@
package org.smartboot.http;
+import com.jsoniter.output.JsonStream;
+import com.jsoniter.output.JsonStreamPool;
import com.jsoniter.spi.JsonException;
-import io.edap.x.json.Eson;
-import io.edap.x.json.JsonWriter;
+import com.jsoniter.spi.Slice;
+import jakarta.servlet.http.HttpServletResponse;
import org.smartboot.http.server.HttpResponse;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
@@ -13,57 +14,56 @@
* @version V1.0 , 2020/6/16
*/
public class JsonUtil {
+ // public static void writeJsonBytes(HttpResponse httpResponse, Object obj) {
+// JsonWriter writer = Eson.THREAD_WRITER.get();
+// try {
+// writer.reset();
+// Eson.serialize(obj, writer);
+// httpResponse.setContentLength(writer.size());
+// writer.toStream(httpResponse.getOutputStream());
+// } catch (IOException e) {
+// throw new JsonException(e);
+// }
+// }
public static void writeJsonBytes(HttpResponse httpResponse, Object obj) {
- JsonWriter writer = Eson.THREAD_WRITER.get();
+ JsonStream stream = JsonStreamPool.borrowJsonStream();
try {
- writer.reset();
- Eson.serialize(obj, writer);
- httpResponse.setContentLength(writer.size());
- writer.toStream(httpResponse.getOutputStream());
+ stream.reset(null);
+ stream.writeVal(obj.getClass(), obj);
+ Slice slice = stream.buffer();
+ httpResponse.setContentLength(slice.tail());
+ httpResponse.getOutputStream().write(slice.data(), 0, slice.tail());
} catch (IOException e) {
throw new JsonException(e);
+ } finally {
+ JsonStreamPool.returnJsonStream(stream);
}
}
-// public static void writeJsonBytes(HttpResponse httpResponse, Object obj) {
-// JsonStream stream = JsonStreamPool.borrowJsonStream();
-// try {
-// stream.reset(null);
-// stream.writeVal(obj.getClass(), obj);
-// Slice slice = stream.buffer();
-// httpResponse.setContentLength(slice.tail());
-// httpResponse.getOutputStream().write(slice.data(), 0, slice.tail());
-// } catch (IOException e) {
-// throw new JsonException(e);
-// } finally {
-// JsonStreamPool.returnJsonStream(stream);
-// }
-// }
+ public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) {
+ JsonStream stream = JsonStreamPool.borrowJsonStream();
+ try {
+ stream.reset(null);
+ stream.writeVal(obj.getClass(), obj);
+ Slice slice = stream.buffer();
+ httpResponse.setContentLength(slice.tail());
+ httpResponse.getOutputStream().write(slice.data(), 0, slice.tail());
+ } catch (IOException e) {
+ throw new JsonException(e);
+ } finally {
+ JsonStreamPool.returnJsonStream(stream);
+ }
+ }
// public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) {
-// JsonStream stream = JsonStreamPool.borrowJsonStream();
+// JsonWriter writer = Eson.THREAD_WRITER.get();
// try {
-// stream.reset(null);
-// stream.writeVal(obj.getClass(), obj);
-// Slice slice = stream.buffer();
-// httpResponse.setContentLength(slice.tail());
-// httpResponse.getOutputStream().write(slice.data(), 0, slice.tail());
+// writer.reset();
+// Eson.serialize(obj, writer);
+// httpResponse.setContentLength(writer.size());
+// writer.toStream(httpResponse.getOutputStream());
// } catch (IOException e) {
// throw new JsonException(e);
-// } finally {
-// JsonStreamPool.returnJsonStream(stream);
// }
// }
-
- public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) {
- JsonWriter writer = Eson.THREAD_WRITER.get();
- try {
- writer.reset();
- Eson.serialize(obj, writer);
- httpResponse.setContentLength(writer.size());
- writer.toStream(httpResponse.getOutputStream());
- } catch (IOException e) {
- throw new JsonException(e);
- }
- }
}
diff --git a/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java b/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java
index 23efbecbd3f..681ad1a7593 100644
--- a/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java
+++ b/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java
@@ -4,13 +4,9 @@
import org.smartboot.http.server.HttpRequest;
import org.smartboot.http.server.HttpResponse;
import org.smartboot.http.server.HttpServerHandler;
-import org.smartboot.http.server.impl.Request;
import org.smartboot.servlet.conf.ServletInfo;
-import org.smartboot.socket.StateMachineEnum;
-import org.smartboot.socket.extension.processor.AbstractMessageProcessor;
-import org.smartboot.socket.transport.AioSession;
-import java.io.IOException;
+import java.util.concurrent.CompletableFuture;
/**
* @author 三刀(zhengjunweimail@163.com)
@@ -18,7 +14,7 @@
*/
public class Bootstrap {
- public static void main(String[] args) {
+ public static void main(String[] args) throws Throwable {
ContainerRuntime containerRuntime = new ContainerRuntime();
// plaintext
ServletContextRuntime applicationRuntime = new ServletContextRuntime("/");
@@ -50,8 +46,8 @@ public static void main(String[] args) {
bootstrap.setPort(8080)
.httpHandler(new HttpServerHandler() {
@Override
- public void handle(HttpRequest request, HttpResponse response) throws IOException {
- containerRuntime.doHandle(request, response);
+ public void handle(HttpRequest request, HttpResponse response, CompletableFuture