Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package org.apache.spark.network.util;

import java.io.IOException;
import java.io.InputStream;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufHolder;
import io.netty.channel.ChannelHandlerContext;
Expand All @@ -42,6 +45,14 @@ protected String format(ChannelHandlerContext ctx, String eventName, Object arg)
} else if (arg instanceof ByteBufHolder) {
return format(ctx, eventName) + " " +
((ByteBufHolder) arg).content().readableBytes() + "B";
} else if (arg instanceof InputStream) {
int available = -1;
try {
available = ((InputStream) arg).available();
} catch (IOException ex) {
// Swallow, but return -1 to indicate an error happened
}
return format(ctx, eventName, arg) + " " + available + "B";
} else {
return super.format(ctx, eventName, arg);
}
Expand Down