File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 3636import java .nio .file .InvalidPathException ;
3737import java .nio .file .Path ;
3838import java .time .Instant ;
39+ import java .time .ZoneOffset ;
3940import java .time .format .DateTimeFormatter ;
4041import java .time .format .DateTimeParseException ;
4142import java .util .concurrent .TimeUnit ;
@@ -134,7 +135,10 @@ private HttpResponse generateResponse(HttpRequest request) throws IOException {
134135 //create response
135136 HttpResponse response = new HttpResponse (HttpStatusCode .OK );
136137 response .addHeader ("ETag" , eTag );
137- if (lastModified > 0 ) response .addHeader ("Last-Modified" , DateTimeFormatter .RFC_1123_DATE_TIME .format (Instant .ofEpochMilli (lastModified )));
138+ if (lastModified > 0 ) response .addHeader ("Last-Modified" , DateTimeFormatter .RFC_1123_DATE_TIME .format (Instant
139+ .ofEpochMilli (lastModified )
140+ .atOffset (ZoneOffset .UTC )
141+ ));
138142 response .addHeader ("Cache-Control" , "public" );
139143 response .addHeader ("Cache-Control" , "max-age=" + TimeUnit .DAYS .toSeconds (1 ));
140144
Original file line number Diff line number Diff line change @@ -87,13 +87,20 @@ public void accept(SelectionKey selectionKey) {
8787 () -> requestHandler .handle (request ),
8888 responseHandlerExecutor
8989 );
90- futureResponse .thenAccept (response -> {
90+ futureResponse .handle ((response , error ) -> {
91+ if (error != null ) {
92+ Logger .global .logError ("Unexpected error handling request" , error );
93+ response = new HttpResponse (HttpStatusCode .INTERNAL_SERVER_ERROR );
94+ }
95+
9196 try {
9297 response .read (channel ); // do an initial read to trigger response sending intent
9398 this .response = response ;
9499 } catch (IOException e ) {
95100 handleIOException (channel , e );
96101 }
102+
103+ return null ;
97104 });
98105 }
99106
You can’t perform that action at this time.
0 commit comments