question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with blocking observable

See original GitHub issue

Hi,

Having issues getting the blocking requests working. In order to support backwards compatibility in our clients we support returning both Observable<T> and T. To get the Observable we do:

    Observable<ByteBuf> observable = template.requestBuilder().build().observe();
    Observable<T> response = observable.map(new Func1<ByteBuf, T>() {
                @Override
                public T call(ByteBuf byteBuf) {
                    byteBuf.retain();
                     try {
                        InputStream stream = new ByteBufInputStream(byteBuf);
                        return streamToObject(stream, tClass);
                    } finally {
                        byteBuf.release();
                    }
              }});
    T item = response.toBlocking().last();

That works well for MOST of the times. However, sometimes we get: java.util.NoSuchElementException: Sequence contains no elements.

Anyone have any idea?

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
OskarKjellincommented, Oct 7, 2014

@NiteshKant at least I am not seeing that specific error any more. I also tried doing the same for futures with something like this; observable.lastOrDefault().toBlocking().toFuture();

Does that sound right?

At what point will the default value be invoked? How can we be sure that the only case this happens if a response has been indeed been returned but the bytebuf was empty? Having huge issues trying to make this backwards compatible. Seems like we’re getting false defaults…

0reactions
dhawkencommented, Nov 7, 2014

RC10 seems to be on rx-netty-0.3.17. Will 18 be rolled in to that? We also seem to be encountering this issue and am interested in a work around. Haven’t found anything yet, outside of retry, which isn’t great for all situations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using RX JAVA Blocking Observable effectively - Medium
In this article I am going to explain about Blocking Observables. As the name suggests, Blocking Observable is an Observable, which implements ...
Read more >
java - Am I misusing rxJava by converting an observable into a ...
I use hystrix-feign to make the HTTP calls. BlockingObservable is a variety of Observable that provides blocking operators.
Read more >
Intro - ReactiveX
Callbacks solve the problem of premature blocking on Future.get() by not allowing anything to block. They are naturally efficient because they execute when...
Read more >
4. Applying Reactive Programming to Existing Applications
However, BlockingObservable is much more convenient in blocking environments that ... but in rare cases you must add concurrency to an existing Observable...
Read more >
3 Common Rxjs Pitfalls (and how to avoid them)
We are going to go over why the issue happens and how to fix it. ... An observable itself is just a definition...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found