Skip to content

Commit c0d01c7

Browse files
committed
Fix blocking call in static StartupMessage initializer
We now no longer use ZoneId.systemDefault() to determine the system timezone to avoid blocking I/O and use TimeZone.getDefault() instead. ZoneId attempts to resolve its zone information from TzdbZoneRulesProvider which uses a file (tzdb.dat) that contains timezone information. Since TzdbZoneRulesProvider opens the file in its constructor we have no other way to override the blocking behavior therefore we use the legacy API which does not use files at all. [resolves #275]
1 parent c44037d commit c0d01c7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/io/r2dbc/postgresql/message/frontend/StartupMessage.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import reactor.core.publisher.Mono;
2525
import reactor.util.annotation.Nullable;
2626

27-
import java.time.ZoneId;
2827
import java.util.Map;
2928
import java.util.Objects;
29+
import java.util.TimeZone;
3030

3131
import static io.netty.util.CharsetUtil.UTF_8;
3232
import static io.r2dbc.postgresql.message.frontend.FrontendMessageUtils.writeByte;
@@ -55,7 +55,7 @@ public final class StartupMessage implements FrontendMessage {
5555

5656
private static final ByteBuf NUMERAL_2 = Unpooled.copiedBuffer("2", UTF_8).asReadOnly();
5757

58-
private static final ByteBuf SYSTEM_TIME_ZONE = Unpooled.copiedBuffer(ZoneId.systemDefault().toString(), UTF_8).asReadOnly();
58+
private static final ByteBuf SYSTEM_TIME_ZONE = Unpooled.copiedBuffer(TimeZone.getDefault().getID(), UTF_8).asReadOnly();
5959

6060
private static final ByteBuf TIMEZONE = Unpooled.copiedBuffer("TimeZone", UTF_8).asReadOnly();
6161

0 commit comments

Comments
 (0)