vanzin commented on a change in pull request #26609: [SPARK-29971] Fix multiple
possible buffer leaks in `TransportFrameDecoder/TransportCipher`
URL: https://github.com/apache/spark/pull/26609#discussion_r348761657
##########
File path:
common/network-common/src/main/java/org/apache/spark/network/util/ByteArrayReadableChannel.java
##########
@@ -19,23 +19,64 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
import java.nio.channels.ReadableByteChannel;
import io.netty.buffer.ByteBuf;
public class ByteArrayReadableChannel implements ReadableByteChannel {
private ByteBuf data;
+ private boolean closed;
public int readableBytes() {
- return data.readableBytes();
+ return data == null ? 0 : data.readableBytes();
}
public void feedData(ByteBuf buf) {
- data = buf;
+ if (closed) {
+ buf.release();
+ return;
+ }
+ ByteBuf currentData = data;
+ if (currentData == null) {
+ data = buf;
+ } else {
+ int currentReadable = currentData.readableBytes();
Review comment:
It's not a public API for Spark. Spark has a lot of public classes that are
not considered part of its public API. People shouldn't use those except at
their own risk.
(Only the classes in Spark's public API docs are considered really public,
and this whole module is not there.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]