Skip to content

Commit

Permalink
Throw proper exception if fdObj is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Sep 24, 2023
1 parent 9417df4 commit 67f93fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/IKVM.Runtime/Java/Externs/java/net/SocketInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ public static int socketRead0(object this_, object fdObj, byte[] data, int off,
{
return InvokeFunc<global::java.net.SocketInputStream, int>(this_, self =>
{
if (fdObj == null)
throw new global::java.net.SocketException("Socket closed");
var socket = FileDescriptorAccessor.GetSocket(fdObj);
if (socket == null)
throw new global::java.net.SocketException("Invalid file handle.");
throw new global::java.net.SocketException("Socket closed");
if (timeout > 0 && socket.Available == 0)
{
Expand Down
5 changes: 4 additions & 1 deletion src/IKVM.Runtime/Java/Externs/java/net/SocketOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ public static void socketWrite0(object this_, object fdObj, byte[] data, int off

InvokeAction<global::java.net.SocketOutputStream>(this_, impl =>
{
if (fdObj == null)
throw new global::java.net.SocketException("Socket closed");
var socket = FileDescriptorAccessor.GetSocket(fdObj);
if (socket == null)
throw new global::java.net.SocketException("Invalid file handle.");
throw new global::java.net.SocketException("Socket closed");
var prevBlocking = socket.Blocking;
var prevSendTimeout = socket.SendTimeout;
Expand Down

0 comments on commit 67f93fd

Please sign in to comment.