Fix NullPointer if faultHandler is null at initial request

This commit is contained in:
Manfred Karrer 2018-01-23 18:53:24 -05:00
parent 31564e923c
commit 8075f9eef9
No known key found for this signature in database
GPG key ID: 401250966A6B2C46

View file

@ -55,7 +55,9 @@ public class PriceFeedService {
private final Map<String, MarketPrice> cache = new HashMap<>();
private final String baseCurrencyCode;
private PriceProvider priceProvider;
@Nullable
private Consumer<Double> priceConsumer;
@Nullable
private FaultHandler faultHandler;
private String currencyCode;
private final StringProperty currencyCodeProperty = new SimpleStringProperty();
@ -134,8 +136,8 @@ public class PriceFeedService {
retryCounter++;
request(true);
}, retryCounter);
this.faultHandler.handleFault(errorMessage, throwable);
if (faultHandler != null)
faultHandler.handleFault(errorMessage, throwable);
});
}
@ -250,7 +252,8 @@ public class PriceFeedService {
} else {
String errorMessage = "We don't have a price for " + currencyCode + ". priceProvider=" + priceProvider;
log.debug(errorMessage);
faultHandler.handleFault(errorMessage, new PriceRequestException(errorMessage));
if (faultHandler != null)
faultHandler.handleFault(errorMessage, new PriceRequestException(errorMessage));
}
}
updateCounter.set(updateCounter.get() + 1);