Skip to content

Commit d1034ed

Browse files
committed
Merge pull request #2642 from zsxwing/fix-memory-leak
Fix a potential memory leak in schedulePeriodically
2 parents 68f7f66 + 9f590cf commit d1034ed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/rx/Scheduler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ public void call() {
123123
}
124124
}
125125
};
126-
mas.set(schedule(recursiveAction, initialDelay, unit));
126+
MultipleAssignmentSubscription s = new MultipleAssignmentSubscription();
127+
// Should call `mas.set` before `schedule`, or the new Subscription may replace the old one.
128+
mas.set(s);
129+
s.set(schedule(recursiveAction, initialDelay, unit));
127130
return mas;
128131
}
129132

0 commit comments

Comments
 (0)