Skip to content

Commit efa351d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3bcb9bf + 585fcb6 commit efa351d

File tree

93 files changed

+1446
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1446
-306
lines changed

frameworks/Go/goravel/src/fiber/go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module goravel
22

33
go 1.22
4+
toolchain go1.24.1
45

56
require (
67
github.com/bytedance/sonic v1.11.9
@@ -160,14 +161,14 @@ require (
160161
go.uber.org/atomic v1.11.0 // indirect
161162
go.uber.org/multierr v1.9.0 // indirect
162163
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
163-
golang.org/x/crypto v0.24.0 // indirect
164+
golang.org/x/crypto v0.35.0 // indirect
164165
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
165166
golang.org/x/net v0.26.0 // indirect
166167
golang.org/x/oauth2 v0.18.0 // indirect
167-
golang.org/x/sync v0.7.0 // indirect
168-
golang.org/x/sys v0.21.0 // indirect
169-
golang.org/x/term v0.21.0 // indirect
170-
golang.org/x/text v0.16.0 // indirect
168+
golang.org/x/sync v0.11.0 // indirect
169+
golang.org/x/sys v0.30.0 // indirect
170+
golang.org/x/term v0.29.0 // indirect
171+
golang.org/x/text v0.22.0 // indirect
171172
golang.org/x/time v0.5.0 // indirect
172173
google.golang.org/api v0.171.0 // indirect
173174
google.golang.org/appengine v1.6.8 // indirect

frameworks/Go/goravel/src/fiber/go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0
723723
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
724724
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
725725
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
726-
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
727-
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
726+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
727+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
728728
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
729729
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
730730
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -840,8 +840,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
840840
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
841841
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
842842
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
843-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
844-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
843+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
844+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
845845
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
846846
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
847847
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -905,8 +905,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
905905
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
906906
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
907907
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
908-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
909-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
908+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
909+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
910910
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
911911
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
912912
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -917,8 +917,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
917917
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
918918
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
919919
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
920-
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
921-
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
920+
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
921+
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
922922
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
923923
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
924924
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -935,8 +935,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
935935
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
936936
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
937937
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
938-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
939-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
938+
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
939+
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
940940
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
941941
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
942942
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

frameworks/Java/netty/src/main/java/hello/HelloServerHandler.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package hello;
22

3-
import static hello.HttpResponses.makeJsonResponse;
4-
import static hello.HttpResponses.makePlaintextResponse;
3+
import static hello.HttpResponses.*;
54
import static hello.JsonUtils.acquireJsonStreamFromEventLoop;
65
import static hello.JsonUtils.releaseJsonStreamFromEventLoop;
76
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
@@ -11,6 +10,7 @@
1110
import java.text.SimpleDateFormat;
1211
import java.util.Date;
1312
import java.util.concurrent.ScheduledExecutorService;
13+
import java.util.concurrent.ScheduledFuture;
1414
import java.util.concurrent.TimeUnit;
1515

1616
import com.jsoniter.output.JsonStream;
@@ -19,11 +19,7 @@
1919
import io.netty.channel.ChannelFutureListener;
2020
import io.netty.channel.ChannelHandlerContext;
2121
import io.netty.channel.ChannelInboundHandlerAdapter;
22-
import io.netty.handler.codec.http.DefaultFullHttpResponse;
23-
import io.netty.handler.codec.http.DefaultHttpRequest;
24-
import io.netty.handler.codec.http.FullHttpResponse;
25-
import io.netty.handler.codec.http.HttpRequest;
26-
import io.netty.handler.codec.http.LastHttpContent;
22+
import io.netty.handler.codec.http.*;
2723
import io.netty.util.AsciiString;
2824
import io.netty.util.ReferenceCountUtil;
2925
import io.netty.util.concurrent.FastThreadLocal;
@@ -37,15 +33,19 @@ protected DateFormat initialValue() {
3733
}
3834
};
3935

40-
protected volatile AsciiString date = new AsciiString(FORMAT.get().format(new Date()));
36+
private HttpHeaders jsonHeaders = makeJsonHeaders(new AsciiString(FORMAT.get().format(new Date())));
37+
private HttpHeaders plaintextHeaders = makePlaintextHeaders(new AsciiString(FORMAT.get().format(new Date())));
38+
private ScheduledFuture<?> refreshHeaders;
4139

4240
public HelloServerHandler(ScheduledExecutorService service) {
43-
service.scheduleWithFixedDelay(new Runnable() {
41+
refreshHeaders = service.scheduleWithFixedDelay(new Runnable() {
4442
private final DateFormat format = FORMAT.get();
4543

4644
@Override
4745
public void run() {
48-
date = new AsciiString(format.format(new Date()));
46+
var date = new AsciiString(format.format(new Date()));
47+
jsonHeaders = makeJsonHeaders(date);
48+
plaintextHeaders = makePlaintextHeaders(date);
4949
}
5050
}, 1000, 1000, TimeUnit.MILLISECONDS);
5151
}
@@ -80,13 +80,13 @@ private void process(ChannelHandlerContext ctx, HttpRequest request) throws Exce
8080
String uri = request.uri();
8181
switch (uri) {
8282
case "/plaintext":
83-
writePlainResponse(ctx, date);
83+
writePlainResponse(ctx, plaintextHeaders);
8484
return;
8585
case "/json":
8686
// even for the virtual thread case we expect virtual threads to be executed inlined!
8787
var stream = acquireJsonStreamFromEventLoop();
8888
try {
89-
writeJsonResponse(ctx, stream, date);
89+
writeJsonResponse(ctx, stream, jsonHeaders);
9090
} finally {
9191
releaseJsonStreamFromEventLoop(stream);
9292
}
@@ -98,12 +98,12 @@ private void process(ChannelHandlerContext ctx, HttpRequest request) throws Exce
9898
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
9999
}
100100

101-
protected void writePlainResponse(ChannelHandlerContext ctx, AsciiString date) {
102-
ctx.write(makePlaintextResponse(date), ctx.voidPromise());
101+
protected void writePlainResponse(ChannelHandlerContext ctx, HttpHeaders plaintextHeaders) {
102+
ctx.write(makePlaintextResponse(plaintextHeaders), ctx.voidPromise());
103103
}
104104

105-
protected void writeJsonResponse(ChannelHandlerContext ctx, JsonStream stream, AsciiString date) {
106-
ctx.write(makeJsonResponse(stream, date), ctx.voidPromise());
105+
protected void writeJsonResponse(ChannelHandlerContext ctx, JsonStream stream, HttpHeaders jsonHeaders) {
106+
ctx.write(makeJsonResponse(stream, jsonHeaders), ctx.voidPromise());
107107
}
108108

109109
@Override
@@ -115,4 +115,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
115115
public void channelReadComplete(ChannelHandlerContext ctx) {
116116
ctx.flush();
117117
}
118+
119+
@Override
120+
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
121+
super.channelInactive(ctx);
122+
if (refreshHeaders != null) {
123+
refreshHeaders.cancel(false);
124+
refreshHeaders = null;
125+
}
126+
}
118127
}

frameworks/Java/netty/src/main/java/hello/HelloServerInitializer.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,45 @@
22

33
import java.util.concurrent.ScheduledExecutorService;
44

5+
import io.netty.buffer.ByteBuf;
6+
import io.netty.buffer.Unpooled;
57
import io.netty.channel.ChannelInitializer;
68
import io.netty.channel.socket.SocketChannel;
7-
import io.netty.handler.codec.http.DefaultFullHttpResponse;
8-
import io.netty.handler.codec.http.DefaultHttpRequest;
9-
import io.netty.handler.codec.http.HttpMessage;
10-
import io.netty.handler.codec.http.HttpMethod;
11-
import io.netty.handler.codec.http.HttpRequestDecoder;
12-
import io.netty.handler.codec.http.HttpResponseEncoder;
13-
import io.netty.handler.codec.http.HttpVersion;
9+
import io.netty.handler.codec.http.*;
1410

1511
public class HelloServerInitializer extends ChannelInitializer<SocketChannel> {
1612

17-
protected final ScheduledExecutorService service;
18-
19-
public HelloServerInitializer(ScheduledExecutorService service) {
20-
this.service = service;
13+
public HelloServerInitializer() {
2114
}
2215

2316
@Override
2417
public void initChannel(SocketChannel ch) throws Exception {
2518
ch.pipeline()
2619
.addLast("encoder", new HttpResponseEncoder() {
20+
21+
private ByteBuf encodedHeaders;
22+
private HttpHeaders lastSeenHeaders;
23+
24+
@Override
25+
protected void encodeHeaders(HttpHeaders headers, ByteBuf buf) {
26+
if (lastSeenHeaders != headers) {
27+
updateEncodedHttpHeaders(headers, buf);
28+
}
29+
var encodedHeaders = this.encodedHeaders;
30+
buf.ensureWritable(encodedHeaders.readableBytes());
31+
encodedHeaders.getBytes(encodedHeaders.readerIndex(), buf, encodedHeaders.readableBytes());
32+
}
33+
34+
private void updateEncodedHttpHeaders(HttpHeaders headers, ByteBuf buf) {
35+
if (encodedHeaders == null) {
36+
encodedHeaders = Unpooled.buffer(buf.writableBytes());
37+
} else {
38+
encodedHeaders.clear().ensureWritable(buf.writableBytes());
39+
}
40+
super.encodeHeaders(headers, encodedHeaders);
41+
lastSeenHeaders = headers;
42+
}
43+
2744
@Override
2845
public boolean acceptOutboundMessage(final Object msg) throws Exception {
2946
if (msg.getClass() == DefaultFullHttpResponse.class) {
@@ -46,7 +63,7 @@ protected boolean isContentAlwaysEmpty(final HttpMessage msg) {
4663
return false;
4764
}
4865
})
49-
.addLast("handler", newHelloServerHandler(service));
66+
.addLast("handler", newHelloServerHandler(ch.eventLoop()));
5067
}
5168

5269
protected HelloServerHandler newHelloServerHandler(ScheduledExecutorService service) {

frameworks/Java/netty/src/main/java/hello/HelloWebServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public void run() throws Exception {
6767
}
6868
var channelB = b.group(group).channel(serverChannelClass);
6969
if (EVENT_LOOP_CARRIER) {
70-
channelB.childHandler(new HelloLoomServerInitializer((MultithreadVirtualEventExecutorGroup) group, group.next()));
70+
channelB.childHandler(new HelloLoomServerInitializer((MultithreadVirtualEventExecutorGroup) group));
7171
} else {
72-
channelB.childHandler(new HelloServerInitializer(group.next()));
72+
channelB.childHandler(new HelloServerInitializer());
7373
}
7474
b.childOption(ChannelOption.SO_REUSEADDR, true);
7575

frameworks/Java/netty/src/main/java/hello/HttpResponses.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,43 @@
2020
import io.netty.buffer.ByteBuf;
2121
import io.netty.buffer.Unpooled;
2222
import io.netty.handler.codec.http.DefaultFullHttpResponse;
23+
import io.netty.handler.codec.http.DefaultHttpHeadersFactory;
2324
import io.netty.handler.codec.http.FullHttpResponse;
25+
import io.netty.handler.codec.http.HttpHeaders;
26+
import io.netty.handler.codec.http.HttpHeadersFactory;
2427
import io.netty.util.AsciiString;
2528

2629
public class HttpResponses {
2730

28-
public static FullHttpResponse makePlaintextResponse(AsciiString date) {
29-
return makeResponse(Unpooled.wrappedBuffer(STATIC_PLAINTEXT), TEXT_PLAIN, PLAINTEXT_CLHEADER_VALUE, date);
30-
}
31+
private static final HttpHeadersFactory HEADERS_FACTORY = DefaultHttpHeadersFactory.headersFactory()
32+
.withValidation(false);
3133

32-
public static FullHttpResponse makeJsonResponse(JsonStream stream, AsciiString date) {
33-
return makeResponse(Unpooled.wrappedBuffer(serializeMsg(newMsg(), stream)), APPLICATION_JSON, JSON_CLHEADER_VALUE, date);
34+
public static HttpHeaders makeJsonHeaders(AsciiString date) {
35+
return HEADERS_FACTORY.newHeaders()
36+
.set(CONTENT_TYPE, APPLICATION_JSON)
37+
.set(SERVER, SERVER_NAME)
38+
.set(DATE, date)
39+
.set(CONTENT_LENGTH, JSON_CLHEADER_VALUE);
3440
}
3541

36-
private static FullHttpResponse makeResponse(ByteBuf buf, CharSequence contentType, CharSequence contentLength, AsciiString date) {
37-
final FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, buf, false);
38-
response.headers()
39-
.set(CONTENT_TYPE, contentType)
42+
43+
public static HttpHeaders makePlaintextHeaders(AsciiString date) {
44+
return HEADERS_FACTORY.newHeaders()
45+
.set(CONTENT_TYPE, TEXT_PLAIN)
4046
.set(SERVER, SERVER_NAME)
4147
.set(DATE, date)
42-
.set(CONTENT_LENGTH, contentLength);
43-
return response;
48+
.set(CONTENT_LENGTH, PLAINTEXT_CLHEADER_VALUE);
49+
}
50+
51+
public static FullHttpResponse makePlaintextResponse(HttpHeaders plaintextHeaders) {
52+
return makeResponse(Unpooled.wrappedBuffer(STATIC_PLAINTEXT), plaintextHeaders);
53+
}
54+
55+
public static FullHttpResponse makeJsonResponse(JsonStream stream, HttpHeaders jsonHeaders) {
56+
return makeResponse(Unpooled.wrappedBuffer(serializeMsg(newMsg(), stream)), jsonHeaders);
57+
}
58+
59+
private static FullHttpResponse makeResponse(ByteBuf buf, HttpHeaders headers) {
60+
return new DefaultFullHttpResponse(HTTP_1_1, OK, buf, headers, HttpHeaders.EMPTY_HEADERS);
4461
}
4562
}

frameworks/Java/netty/src/main/java/hello/loom/HelloLoomServerInitializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ public class HelloLoomServerInitializer extends HelloServerInitializer {
99

1010
private final MultithreadVirtualEventExecutorGroup group;
1111

12-
public HelloLoomServerInitializer(MultithreadVirtualEventExecutorGroup group, ScheduledExecutorService service) {
13-
super(service);
12+
public HelloLoomServerInitializer(MultithreadVirtualEventExecutorGroup group) {
1413
this.group = group;
1514
}
1615

frameworks/Java/netty/src/main/java/hello/loom/VirtualThreadHelloServerHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import hello.HttpResponses;
1010
import io.netty.channel.ChannelHandlerContext;
1111
import io.netty.handler.codec.http.FullHttpResponse;
12+
import io.netty.handler.codec.http.HttpHeaders;
1213
import io.netty.util.AsciiString;
1314

1415
public class VirtualThreadHelloServerHandler extends HelloServerHandler {
@@ -22,16 +23,16 @@ public VirtualThreadHelloServerHandler(ScheduledExecutorService service, Multith
2223
}
2324

2425
@Override
25-
protected void writePlainResponse(ChannelHandlerContext ctx, AsciiString date) {
26+
protected void writePlainResponse(ChannelHandlerContext ctx, HttpHeaders plainTextHeaders) {
2627
group.eventLoopVirtualThreadFactory().newThread(() -> {
27-
responses.add(HttpResponses.makePlaintextResponse(date));
28+
responses.add(HttpResponses.makePlaintextResponse(plainTextHeaders));
2829
}).start();
2930
}
3031

3132
@Override
32-
protected void writeJsonResponse(ChannelHandlerContext ctx, JsonStream stream, AsciiString date) {
33+
protected void writeJsonResponse(ChannelHandlerContext ctx, JsonStream stream, HttpHeaders jsonHeaders) {
3334
group.eventLoopVirtualThreadFactory().newThread(() -> {
34-
responses.add(HttpResponses.makeJsonResponse(stream, date));
35+
responses.add(HttpResponses.makeJsonResponse(stream, jsonHeaders));
3536
}).start();
3637
}
3738

0 commit comments

Comments
 (0)