Ich verwende Retrofit 2, um einen Microservice aufzurufen, der bei einer PUT-Methode einen 200 und einen leeren Antworttext zurückgibt. Retrofit 2 scheint jedoch nicht in der Lage zu sein, dies zu handhaben und in der "enqueue" auf den Zweig onFailure geht
@Override public void onFailure (Anruf Anruf, Throwable t) {Retrofit2 OkHttp3 Response Body Null Fehler
Hier sind die Protokolle:
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION: --> PUT http://127.0.0.1/test/ http/1.1
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION: Content-Type: application/vnd.tipico.notification-v1+json
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION: Content-Length: 87
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION:
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION: {"state":"ACTIVE","externalId":"abcd","loginName":"gsdfgsdf","updatedAt":1495531062000}
Mai 27, 2017 3:26:49 PM okhttp3.internal.platform.Platform log
INFORMATION: --> END PUT (87-byte body)
Mai 27, 2017 3:26:50 PM okhttp3.internal.platform.Platform log
INFORMATION: <-- 200 http://127.0.0.1/test/ (197ms)
Mai 27, 2017 3:26:50 PM okhttp3.internal.platform.Platform log
INFORMATION: X-Application-Context: customer-care-notification-service:49980
Mai 27, 2017 3:26:50 PM okhttp3.internal.platform.Platform log
INFORMATION: Content-Length: 0
Mai 27, 2017 3:26:50 PM okhttp3.internal.platform.Platform log
INFORMATION: Date: Sat, 27 May 2017 13:26:49 GMT
Mai 27, 2017 3:26:50 PM okhttp3.internal.platform.Platform log
INFORMATION: <-- END HTTP (0-byte body)
15:26:50,030 ERROR com.test.app.Test - Failed CCNS call com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: [email protected]; line: 1, column: 0]
Wer weiß, was das verursacht? Da die Anfrage erfolgreich geliefert wurde (siehe oben).
Das ist ziemlich seltsam hinzuzufügen. Ruft Ihr Aufruf irgendein Objekt zurück, das nachzurüsten versuchen könnte, zu deserialisieren? bei Anruf meine ich die Java-Schnittstelle – Fred
Haben Sie eine Lösung gefunden? Ich stehe vor demselben Problem. Sieht so aus als ob das mit einigen Jackson Releases passiert. Welche Version verwendest du? – Pawan
Hi, ja Sie müssen NullOnEmptyConverterFactory wie hier implementieren https://github.com/square/retrofit/issues/1554 – razvan