knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

Incompatibility with Jackson 2.15.x (as used by Spring Boot 3.1.x) #4777

Open rvullriede opened 9 months ago

rvullriede commented 9 months ago

When you use XChange in a Spring Boot 3.1.x project you'll encounter problem with the deserialisation if IOrderFlags. An easy way to reproduce it is to simply upgrade to 2.15.2</version.fasterxml> in XChange's parent pom and run the tests.

The first failing tests is: BinanceAdaptersTest.testFilledMarketOrder:21 » MismatchedInput Unexpected token (VALUE_STRING), expected START_OBJECT: need JSON Object to contain As.WRAPPER_OBJECT type information for class org.knowm.xchange.binance.dto.trade.TimeInForce at [Source: (InputStreamReader); line: 11, column: 20] (through reference chain: org.knowm.xchange.binance.dto.trade.BinanceOrder["timeInForce"]) [ERROR] TradeServiceResilienceTest.shouldSucceedIfFirstCallTimeoutedAndRetryIsEnabled:39 » HttpStatusIO Unexpected token (VALUE_STRING), expected START_OBJECT: need JSON Object to contain As.WRAPPER_OBJECT type information for class org.knowm.xchange.binance.dto.trade.TimeInForce at [Source: (String)"[ { "symbol": "LTCBTC", "orderId": 1, "orderListId": -1, "clientOrderId": "myOrder1", "price": "0.1", "origQty": "1.0", "executedQty": "0.0", "cummulativeQuoteQty": "0.0", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "stopPrice": "0.0", "icebergQty": "0.0", "time": 1499827319559, "updateTime": 1499827319559, "isWorking": true, "origQuoteOrderQty": "0.000000" }]"; line: 1, column: 236] (through reference chain: java.util.ArrayList[0]->org.knowm.xchange.binance.dto.trade.BinanceOrder["timeInForce"])

I went through Jackson's changelog and found the following issue which might be related: https://github.com/FasterXML/jackson-databind/issues/2968

I couldn't (yet) follow how Jackson is supposed to work in XChange related to type inheritance and didn't find an easy fix for this. I hope somebody else with deeper knowledge on this might be able to :-)