Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Program using interval and take does not terminate #388

@samuelgruetter

Description

@samuelgruetter

When I run the following snippet:

static Action1<Long> onNextFunc(final String who) {
    return new Action1<Long>() {
        public void call(Long x) {
            System.out.println(who + " got " + x);
        }            
    };
}
static Action1<Throwable> onErrorFunc(final String who) {
    return new Action1<Throwable>() {
        public void call(Throwable t) {
            t.printStackTrace();
        }            
    };
}    
static Action0 onCompleteFunc(final String who) {
    return new Action0() {
        public void call() {
            System.out.println(who + " complete");
        }            
    };
}
public static void main(String[] args) {
    Observable<Long> oneNumberPerSecond = Observable.interval(1, TimeUnit.SECONDS).take(5);
    oneNumberPerSecond.subscribe(onNextFunc("subscriber 1"), onErrorFunc("subscriber 1"), onCompleteFunc("subscriber 1"));
}

then I get (as expected) the following output:

subscriber 1 got 0
subscriber 1 got 1
subscriber 1 got 2
subscriber 1 got 3
subscriber 1 got 4
subscriber 1 complete

However, the program does not terminate, and that's unexpected.

I ran this test using rxjava-core-0.13.2-SNAPSHOT.jar built from commit 00d7c3b (Sat Sep 14 08:37:09 2013 -0700).

Due to this problem, some tests in the RxScalaDemo that I'm working on do not terminate, which is annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions