[SPARK-4107] Fix incorrect handling of read() and skip() return values

`read()` may return fewer bytes than requested; when this occurred, the old
code would silently return less data than requested, which might cause stream
corruption errors.
u probably want to catch other exception / errors, e.g. in this case i'd also try to catch out of memory