RxJavaString icon indicating copy to clipboard operation
RxJavaString copied to clipboard

StringObservable.decode should call onError when buffer not empty on completion

Open davidmoten opened this issue 10 years ago • 4 comments

At the moment if StringObservable.decode is called on a stream of byte[] and the source stream completes with bytes left over in the buffer (more is required before a string can be emitted) then the observable effectively hangs (onCompleted is not called). Because this situation cannot be distinguished from the source not completing or hanging I'd like to see StringObservable.decode call onError with some custom exception type that can be ignored if people wish using the normal means.

Are people ok with me submitting a PR for this?

davidmoten avatar Sep 29 '15 06:09 davidmoten

Sounds like a good idea to me.

akarnokd avatar Sep 29 '15 07:09 akarnokd

It's not entirely obviously but it is actually the default behavior to replace malformed chars with a question mark char. It is possible to pass in a custom CharsetDecoder with different malformed handling. See http://docs.oracle.com/javase/7/docs/api/java/nio/charset/CodingErrorAction.html.

Consider just adding an overload that makes it easy to set that enum.

abersnaze avatar Sep 30 '15 07:09 abersnaze

@davidmoten is this still an issue?

abersnaze avatar Mar 17 '16 07:03 abersnaze

@abersnaze I imagine so. I like your suggestion. I'll pop this on my list of things to do.

davidmoten avatar Mar 17 '16 11:03 davidmoten