Skip to content

Commit

Permalink
fix: NPE when no result found
Browse files Browse the repository at this point in the history
fixes #39 .

i opted to just filter, as would prefer leaving to the subscriber to
retry if necessary
  • Loading branch information
Kaushik Gopal committed Jan 28, 2017
1 parent 90b9ed9 commit ddf9504
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ public Date call(long[] longs) {
* See RESPONSE_INDEX_ prefixes in {@link SntpClient} for details
*/
public Observable<long[]> initializeNtp(String ntpPool) {
return Observable//
.just(ntpPool)//
.compose(resolveNtpPoolToIpAddresses())//
return Observable
.just(ntpPool)
.compose(resolveNtpPoolToIpAddresses())
.flatMap(bestResponseAgainstSingleIp(5)) // get best response from querying the ip 5 times
.take(5) // take 5 of the best results
.toList()//
.map(filterMedianResponse())//
.toList()
.filter(new Func1<List<long[]>, Boolean>() {
@Override
public Boolean call(List<long[]> longs) {
return longs != null && longs.size() > 0;
}
})
.map(filterMedianResponse())
.doOnNext(new Action1<long[]>() {
@Override
public void call(long[] ntpResponse) {
Expand Down

0 comments on commit ddf9504

Please sign in to comment.