1
1
package com .techempower .inverno .benchmark .internal ;
2
2
3
- import java .time .ZonedDateTime ;
4
- import java .time .format .DateTimeFormatter ;
5
- import java .util .Collections ;
6
- import java .util .concurrent .CompletableFuture ;
7
- import java .util .concurrent .ThreadLocalRandom ;
8
- import java .util .concurrent .TimeUnit ;
9
- import java .util .function .Supplier ;
10
-
11
3
import com .fasterxml .jackson .core .JsonProcessingException ;
12
4
import com .fasterxml .jackson .databind .ObjectMapper ;
13
5
import com .techempower .inverno .benchmark .model .Fortune ;
14
6
import com .techempower .inverno .benchmark .model .Message ;
15
7
import com .techempower .inverno .benchmark .model .World ;
16
8
import com .techempower .inverno .benchmark .templates .FortunesTemplate ;
17
-
18
9
import io .inverno .core .annotation .Bean ;
19
10
import io .inverno .core .annotation .Bean .Visibility ;
20
11
import io .inverno .core .annotation .Destroy ;
39
30
import io .netty .handler .codec .http .HttpHeaderNames ;
40
31
import io .netty .handler .codec .http .HttpHeaderValues ;
41
32
import io .netty .util .AsciiString ;
33
+ import java .time .ZonedDateTime ;
34
+ import java .time .format .DateTimeFormatter ;
35
+ import java .util .Collections ;
36
+ import java .util .concurrent .CompletableFuture ;
37
+ import java .util .concurrent .ThreadLocalRandom ;
38
+ import java .util .concurrent .TimeUnit ;
39
+ import java .util .function .Supplier ;
42
40
import reactor .core .publisher .Flux ;
43
41
import reactor .core .publisher .Mono ;
44
42
@@ -81,6 +79,8 @@ public void init() {
81
79
this .dateEventLoopGroup .scheduleAtFixedRate (() -> {
82
80
this .date = new AsciiString (DateTimeFormatter .RFC_1123_DATE_TIME .format (ZonedDateTime .now ()));
83
81
}, 0 , 1000 , TimeUnit .MILLISECONDS );
82
+
83
+
84
84
}
85
85
86
86
@ Destroy
@@ -133,7 +133,7 @@ public void handle(Exchange<ExchangeContext> exchange) throws HttpException {
133
133
134
134
private static final ByteBuf STATIC_PLAINTEXT_BYTEBUF ;
135
135
static {
136
- ByteBuf tmpBuf = Unpooled .directBuffer (STATIC_PLAINTEXT_LEN );
136
+ ByteBuf tmpBuf = Unpooled .buffer (STATIC_PLAINTEXT_LEN );
137
137
tmpBuf .writeBytes (STATIC_PLAINTEXT );
138
138
STATIC_PLAINTEXT_BYTEBUF = Unpooled .unreleasableBuffer (tmpBuf );
139
139
}
@@ -172,7 +172,7 @@ public void handle_json(Exchange<ExchangeContext> exchange) throws HttpException
172
172
)
173
173
.body ()
174
174
.raw ()
175
- .value (Unpooled .unreleasableBuffer ( Unpooled . wrappedBuffer (this .mapper .writeValueAsBytes (new Message ("Hello, World!" ) ))));
175
+ .value (Unpooled .wrappedBuffer (this .mapper .writeValueAsBytes (new Message ("Hello, World!" ))));
176
176
}
177
177
catch (JsonProcessingException | IllegalStateException e ) {
178
178
throw new InternalServerErrorException ("Error serializing message as JSON" , e );
@@ -196,7 +196,7 @@ public void handle_db(Exchange<ExchangeContext> exchange) throws HttpException {
196
196
DB_SELECT_WORLD ,
197
197
row -> {
198
198
try {
199
- return Unpooled .unreleasableBuffer ( Unpooled . wrappedBuffer (this .mapper .writeValueAsBytes (new World (row .getInteger (0 ), row .getInteger (1 ) ))));
199
+ return Unpooled .wrappedBuffer (this .mapper .writeValueAsBytes (new World (row .getInteger (0 ), row .getInteger (1 ))));
200
200
}
201
201
catch (JsonProcessingException e ) {
202
202
throw new InternalServerErrorException (e );
@@ -241,7 +241,7 @@ public void handle_queries(Exchange<ExchangeContext> exchange) throws HttpExcept
241
241
.collectList ()
242
242
.map (worlds -> {
243
243
try {
244
- return Unpooled .unreleasableBuffer ( Unpooled . wrappedBuffer (this .mapper .writeValueAsBytes (worlds ) ));
244
+ return Unpooled .wrappedBuffer (this .mapper .writeValueAsBytes (worlds ));
245
245
}
246
246
catch (JsonProcessingException e ) {
247
247
throw new InternalServerErrorException (e );
@@ -278,7 +278,7 @@ public void handle_updates(Exchange<ExchangeContext> exchange) throws HttpExcept
278
278
)
279
279
.map (worlds -> {
280
280
try {
281
- return Unpooled .unreleasableBuffer ( Unpooled . wrappedBuffer (this .mapper .writeValueAsBytes (worlds ) ));
281
+ return Unpooled .wrappedBuffer (this .mapper .writeValueAsBytes (worlds ));
282
282
}
283
283
catch (JsonProcessingException e ) {
284
284
throw new InternalServerErrorException (e );
@@ -290,7 +290,7 @@ public void handle_updates(Exchange<ExchangeContext> exchange) throws HttpExcept
290
290
291
291
private static final CharSequence MEDIA_TEXT_HTML_UTF8 = AsciiString .cached ("text/html; charset=utf-8" );
292
292
293
- private static final FortunesTemplate .Renderer <CompletableFuture <ByteBuf >> FORTUNES_RENDERER = FortunesTemplate .bytebuf (() -> Unpooled .unreleasableBuffer ( Unpooled . buffer () ));
293
+ private static final FortunesTemplate .Renderer <CompletableFuture <ByteBuf >> FORTUNES_RENDERER = FortunesTemplate .bytebuf (() -> Unpooled .buffer ());
294
294
295
295
public void handle_fortunes (Exchange <ExchangeContext > exchange ) throws HttpException {
296
296
exchange .response ()
0 commit comments