flink-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maximilian Michels <...@apache.org>
Subject Re: DataInputStream read vs. readFully
Date Wed, 28 Sep 2016 13:37:36 GMT
Hi Ufuk,

`read(buf)` is not always `read(buf, 0, buf.length)`. Whereas
`readFully(buf)` ensures `read(buf, 0, buf.length)`, right? The method
is clearly documented but these mistakes can happen like a forgotten
null pointer check.

If we want to prevent mistakes like this, we can replace `read(buf)`
with `readFully(buf)` by default. This wouldn't break any code. We
could then add another method to explicitly enable partial reads.


On Wed, Sep 28, 2016 at 12:34 PM, Ufuk Celebi <uce@apache.org> wrote:
> Hey devs,
> had a quick discussion with Stephan about usage of DataInputStream
> read and readFully. In most cases we want to use readFully, but it's
> easy to accidentally use read instead (happened to me here for
> example: https://issues.apache.org/jira/browse/FLINK-4332), which only
> reads as many bytes as are available in the stream.
> We asked ourselves whether it is possible to prevent read calls by
> default and only allow them on a case by case basis. Unfortunately, I
> couldn't find anything that could work.
> Does someone else have an idea there?
> – Ufuk

View raw message