mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 08:08:02 +01:00
Minor improvements
This commit is contained in:
@@ -15,8 +15,8 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -118,12 +118,12 @@ public class CurrencyConversionManager implements Managed {
|
||||
}
|
||||
|
||||
private void updateEntity() {
|
||||
List<CurrencyConversionEntity> entities = new LinkedList<>();
|
||||
final List<CurrencyConversionEntity> entities = new ArrayList<>(cachedCoinGeckoValues.size());
|
||||
|
||||
for (Map.Entry<String, BigDecimal> currency : cachedCoinGeckoValues.entrySet()) {
|
||||
BigDecimal usdValue = stripTrailingZerosAfterDecimal(currency.getValue());
|
||||
final BigDecimal usdValue = stripTrailingZerosAfterDecimal(currency.getValue());
|
||||
|
||||
Map<String, BigDecimal> values = new HashMap<>();
|
||||
final Map<String, BigDecimal> values = new HashMap<>();
|
||||
values.put("USD", usdValue);
|
||||
|
||||
for (Map.Entry<String, BigDecimal> conversion : cachedFixerValues.entrySet()) {
|
||||
|
||||
@@ -28,9 +28,9 @@ public class FixerClient {
|
||||
|
||||
public Map<String, BigDecimal> getConversionsForBase(String base) throws FixerException {
|
||||
try {
|
||||
URI uri = URI.create("https://data.fixer.io/api/latest?access_key=" + apiKey + "&base=" + base);
|
||||
final URI uri = URI.create("https://data.fixer.io/api/latest?access_key=" + apiKey + "&base=" + base);
|
||||
|
||||
HttpResponse<String> response = client.send(HttpRequest.newBuilder()
|
||||
final HttpResponse<String> response = client.send(HttpRequest.newBuilder()
|
||||
.GET()
|
||||
.uri(uri)
|
||||
.timeout(Duration.ofSeconds(15))
|
||||
@@ -41,10 +41,13 @@ public class FixerClient {
|
||||
throw new FixerException("Bad response: " + response.statusCode() + " " + response.toString());
|
||||
}
|
||||
|
||||
FixerResponse parsedResponse = SystemMapper.jsonMapper().readValue(response.body(), FixerResponse.class);
|
||||
final FixerResponse parsedResponse = SystemMapper.jsonMapper().readValue(response.body(), FixerResponse.class);
|
||||
|
||||
if (parsedResponse.success) return parsedResponse.rates;
|
||||
else throw new FixerException("Got failed response!");
|
||||
if (parsedResponse.success) {
|
||||
return parsedResponse.rates;
|
||||
} else {
|
||||
throw new FixerException("Got failed response!");
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
throw new FixerException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user