@@ -366,6 +366,40 @@ public void retryOnTransientHttpError() throws Exception {
366366 fetcher .close ();
367367 }
368368
369+ @ Test
370+ public void retryOnSocketTimeoutException () throws Exception {
371+ this .server .enqueue (new MockResponse ().setResponseCode (200 ).setBodyDelay (2 , TimeUnit .SECONDS ).setBody (TEST_JSON ));
372+ this .server .enqueue (new MockResponse ().setResponseCode (200 ).setBody (TEST_JSON ));
373+
374+ ConfigFetcher fetcher = new ConfigFetcher (new OkHttpClient .Builder ().readTimeout (1 , TimeUnit .SECONDS ).build (), logger ,
375+ "" , this .server .url ("/" ).toString (), false , PollingModes .manualPoll ().getPollingIdentifier ());
376+
377+ FetchResponse response = fetcher .fetchAsync (null ).get ();
378+
379+ assertTrue (response .isFetched ());
380+ assertEquals ("fakeValue" , response .entry ().getConfig ().getEntries ().get ("fakeKey" ).getSettingsValue ().getStringValue ());
381+ assertEquals (2 , this .server .getRequestCount ());
382+
383+ fetcher .close ();
384+ }
385+
386+ @ Test
387+ public void retryOnUnexpectedError () throws Exception {
388+ this .server .enqueue (new MockResponse ().setResponseCode (200 ).setSocketPolicy (SocketPolicy .DISCONNECT_DURING_RESPONSE_BODY ).setBody (TEST_JSON ));
389+ this .server .enqueue (new MockResponse ().setResponseCode (200 ).setBody (TEST_JSON ));
390+
391+ ConfigFetcher fetcher = new ConfigFetcher (new OkHttpClient .Builder ().readTimeout (1 , TimeUnit .SECONDS ).build (), logger ,
392+ "" , this .server .url ("/" ).toString (), false , PollingModes .manualPoll ().getPollingIdentifier ());
393+
394+ FetchResponse response = fetcher .fetchAsync (null ).get ();
395+
396+ assertTrue (response .isFetched ());
397+ assertEquals ("fakeValue" , response .entry ().getConfig ().getEntries ().get ("fakeKey" ).getSettingsValue ().getStringValue ());
398+ assertEquals (2 , this .server .getRequestCount ());
399+
400+ fetcher .close ();
401+ }
402+
369403 @ Test
370404 public void retryOnTransientHttpErrorBothFail () throws Exception {
371405 // Both first request and retry return 500
0 commit comments