This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b4886d3d304 Fix MySQLJsonBinlogProtocolValue possible leak (#19410)
b4886d3d304 is described below
commit b4886d3d3044fb95d752f4ebeb85f4adc7f1a3d7
Author: azexcy <[email protected]>
AuthorDate: Thu Jul 21 15:11:39 2022 +0800
Fix MySQLJsonBinlogProtocolValue possible leak (#19410)
---
.../row/column/value/string/MySQLJsonBinlogProtocolValue.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
index 692dc856b46..6ce0076aefb 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
@@ -17,6 +17,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string;
+import io.netty.buffer.ByteBuf;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.MySQLBinlogProtocolValue;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
@@ -39,7 +40,12 @@ public final class MySQLJsonBinlogProtocolValue implements
MySQLBinlogProtocolVa
@Override
public Serializable read(final MySQLBinlogColumnDef columnDef, final
MySQLPacketPayload payload) {
- return
MySQLJsonValueDecoder.decode(payload.getByteBuf().readBytes(readLengthFromMeta(columnDef.getColumnMeta(),
payload)));
+ ByteBuf newlyByteBuf =
payload.getByteBuf().readBytes(readLengthFromMeta(columnDef.getColumnMeta(),
payload));
+ try {
+ return MySQLJsonValueDecoder.decode(newlyByteBuf);
+ } finally {
+ newlyByteBuf.release();
+ }
}
private int readLengthFromMeta(final int columnMeta, final
MySQLPacketPayload payload) {