Skip to content

Commit 2d07fc0

Browse files
andreas-eberletsegismont
authored andcommitted
PgCient: Handle idle-session timeout and prevent NullPointerException in PgDecoder.decoderError() (#1402)
Signed-off-by: Andreas Eberle <andreas.eberle@arconsis.com>
1 parent bbbb46c commit 2d07fc0

File tree

1 file changed

+7
-3
lines changed
  • vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec

1 file changed

+7
-3
lines changed

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgDecoder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void decodeDataRow(ByteBuf in) {
209209
cmd.rowDecoder.handleRow(len, in);
210210
}
211211

212-
private void decodeRowDescription(ByteBuf in) {
212+
private void decodeRowDescription(ByteBuf in) {
213213
PgColumnDesc[] columns = new PgColumnDesc[in.readUnsignedShort()];
214214
for (int c = 0; c < columns.length; ++c) {
215215
String fieldName = Util.readCStringUTF8(in);
@@ -254,11 +254,15 @@ private void decodeError(ChannelHandlerContext ctx, ByteBuf in) {
254254
switch (response.getCode()) {
255255
default:
256256
PgCommandCodec<?, ?> cmd = codec.peek();
257-
cmd.handleErrorResponse(response);
257+
if (cmd != null) {
258+
cmd.handleErrorResponse(response);
259+
}
258260
break;
259-
// Unsolicited errors
261+
// Unsolicited errors
260262
case "57P01":
261263
// admin_shutdown
264+
case "57P05":
265+
// terminating connection due to idle-session timeout
262266
case "25P03":
263267
// terminating connection due to idle-in-transaction timeout
264268
ctx.fireExceptionCaught(response.toException());

0 commit comments

Comments
 (0)