Skip to content

Commit 3dbe178

Browse files
committed
Fixes msgpack#217: Handle when FileInputStream.getChannel() returns null
1 parent 7cd8f41 commit 3dbe178

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

msgpack-core/src/main/java/org/msgpack/core/buffer/InputStreamBufferInput.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.FileInputStream;
44
import java.io.IOException;
55
import java.io.InputStream;
6+
import java.nio.channels.FileChannel;
67

78
import static org.msgpack.core.Preconditions.checkNotNull;
89

@@ -18,7 +19,10 @@ public class InputStreamBufferInput implements MessageBufferInput {
1819
public static MessageBufferInput newBufferInput(InputStream in) {
1920
checkNotNull(in, "InputStream is null");
2021
if (in instanceof FileInputStream) {
21-
return new ChannelBufferInput(((FileInputStream) in).getChannel());
22+
FileChannel channel = ((FileInputStream) in).getChannel();
23+
if(channel != null) {
24+
return new ChannelBufferInput(channel);
25+
}
2226
}
2327
return new InputStreamBufferInput(in);
2428
}

0 commit comments

Comments
 (0)