Skip to content

Commit

Permalink
if the write channel is null treat it as Errno.EACCES
Browse files Browse the repository at this point in the history
a NPE happens before when the writechannel was null. such a situation happens
when you try to write a file inside classloader (uri:classloader://some.file)

improving the error condition of #3557
mkristian committed Jan 11, 2016
1 parent 528dba7 commit cbc0cb7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/util/io/PosixShim.java
Original file line number Diff line number Diff line change
@@ -99,6 +99,10 @@ public int write(ChannelFD fd, byte[] bytes, int offset, int length, boolean non
// pretend the channel is nonblocking.
}

if (fd.chWrite == null) {
errno = Errno.EACCES;
return -1;
}
int written = fd.chWrite.write(tmp);

if (written == 0 && length > 0) {

0 comments on commit cbc0cb7

Please sign in to comment.