HDFS-13730. BlockReaderRemote.sendReadResult throws NPE. Contributed by Yuanbo Liu.

This commit is contained in:
Wei-Chiu Chuang 2019-06-17 20:18:53 -07:00
parent 10311c30b0
commit 62ad9885ea
2 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,7 @@
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import org.apache.hadoop.net.unix.DomainSocket; import org.apache.hadoop.net.unix.DomainSocket;
@ -93,7 +94,8 @@ public void close() throws IOException {
@Override @Override
public String getRemoteAddressString() { public String getRemoteAddressString() {
return socket.getRemoteSocketAddress().toString(); SocketAddress address = socket.getRemoteSocketAddress();
return address == null ? null : address.toString();
} }
@Override @Override

View File

@ -21,6 +21,7 @@
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import org.apache.hadoop.net.SocketInputStream; import org.apache.hadoop.net.SocketInputStream;
@ -96,7 +97,8 @@ public void close() throws IOException {
@Override @Override
public String getRemoteAddressString() { public String getRemoteAddressString() {
return socket.getRemoteSocketAddress().toString(); SocketAddress address = socket.getRemoteSocketAddress();
return address == null ? null : address.toString();
} }
@Override @Override