Windows Named Pipes: Allow reading fewer bytes #109
Conversation
Ref facebookarchive#92 `read(b, off, len)` can sometimes be called when the length is unknown. This changes so that it uses the number of available bytes returned from `GetOverlappedResult` function, copies the bytes, and returns it.
@@ -117,17 +117,15 @@ public int read(byte[] b, int off, int len) throws IOException { | |||
} | |||
} | |||
|
|||
IntByReference read = new IntByReference(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you rename read
to r
? Can you name it properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you rename
read
tor
?
I thought it's confusing to name a local variable as read
(past perfect tense?) inside the implementation of a method named read
. Given that this reference is a throw-away that later gets used as int actualLen
, I though a single letter variable name is most proper here.
Can you name it properly?
I did what I thought was good. I'd be happy to change to something else if you have suggestions.
When? Nailgun protocol is designed in such a way that |
I saw it break when I was using this code in sbt server, which has code like this: bytesRead = in.read(readBuffer) |
I see. Could you then make this logic configurable - something like an extra parameter/field to throw or not throw an exception when less bytes than requested have been read? In the context of nailgun (because of some internals of the protocol) such situation is a signal that the connection |
... the connection is unhealthy. While in your context it can be ok. I would like to keep this logic for nail gun. |
This adds requireStrictLength parameter to NGWin32NamedPipeSocket and NGWin32NamedPipeServerSocket so the socket can return an inputstream whose `read(byte[], int, int)` requires exact length, as opposed to passing in a buffer array.
@ilya-klyuchnikov This feels odd to me since most |
Thanks! |
Ref #92
read(b, off, len)
can sometimes be called when the length is unknown. This changes so that it uses the number of available bytes returned fromGetOverlappedResult
function, copies the bytes, and returns it.