Tinkoff / invest-openapi-java-sdk

Apache License 2.0
167 stars 46 forks source link

Зависание при запросе Candles #110

Closed SavchenkoVV closed 3 years ago

SavchenkoVV commented 4 years ago
api.getMarketContext().getMarketCandles(v.figi, from, to, CandleInterval.FIVE_MIN).get()

com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (okio.RealBufferedSource$inputStream$1); line: 1, column: 0]
    at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
    at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4344)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4189)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3250)
    at ru.tinkoff.invest.openapi.okhttp.BaseContextImpl.handleResponse(BaseContextImpl.java:77)
    at ru.tinkoff.invest.openapi.okhttp.MarketContextImpl$10.onResponse(MarketContextImpl.java:249)
    at okhttp3.RealCall$AsyncCall.run(RealCall.kt:140)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

В блоке

public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                try {
                    RestResponse<HistoricalCandles> result = (RestResponse)MarketContextImpl.this.handleResponse(response, MarketContextImpl.historicalCandlesTypeReference);
                    future.complete(Optional.of((HistoricalCandles)result.payload));
                } catch (OpenApiException var4) {
                    if (var4.getCode().equals("INSTRUMENT_ERROR")) {
                        future.complete(Optional.empty());
                    } else {
                        future.completeExceptionally(var4);
                    }
                }
            }

Не перехвачены исключения(В данном случае com.fasterxml.jackson.databind.exc.MismatchedInputException) и future.completeExceptionally не вызывается

zlumyo commented 3 years ago

Неперехваченные исключения исправлены в ПР #119.