Skip to content

Commit 10437e3

Browse files
committed
Release IO buffer on outbound error
`OutboundMessageHandler` writes message to `ByteBuf`. It allocates a dedicated IO buffer for this. Writing can fail for various reasons (unsupported byte arrays, etc). Previously this IO buffer has not been released in case of an error. When writing is successful IO buffer is released by then channel pipeline. This commit makes `OutboundMessageHandler` release buffer before rethrowing the exception.
1 parent aac5738 commit 10437e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/outbound/OutboundMessageHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ protected void encode( ChannelHandlerContext ctx, Message msg, List<Object> out
6565
try
6666
{
6767
writer.write( msg );
68+
output.stop();
6869
}
6970
catch ( Throwable error )
70-
{
71-
throw new EncoderException( "Failed to write outbound message: " + msg, error );
72-
}
73-
finally
7471
{
7572
output.stop();
73+
// release buffer because it will not get added to the out list and no other handler is going to handle it
74+
messageBuf.release();
75+
throw new EncoderException( "Failed to write outbound message: " + msg, error );
7676
}
7777

7878
if ( log.isTraceEnabled() )

0 commit comments

Comments
 (0)