Skip to content

Commit 90bd4ba

Browse files
authored
Revert "plugins: Add 'break' at RedifshClient request re-try loop (#4846)" (#4861)
This reverts commit 96dd728.
1 parent 546bf3d commit 90bd4ba

2 files changed

Lines changed: 1 addition & 24 deletions

File tree

utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,8 @@ protected HttpResponse retryHttpRequest(String url, HttpRequestBase httpReq, Htt
231231
for (int attempt = 1; attempt < redfishRequestMaxRetries + 1; attempt++) {
232232
try {
233233
TimeUnit.SECONDS.sleep(WAIT_FOR_REQUEST_RETRY);
234-
LOGGER.debug(String.format("HTTP %s request retry attempt %d/%d [URL: %s].", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
234+
LOGGER.debug(String.format("Retry HTTP %s request [URL: %s], attempt %d/%d.", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
235235
response = client.execute(httpReq);
236-
break;
237236
} catch (IOException | InterruptedException e) {
238237
if (attempt == redfishRequestMaxRetries) {
239238
throw new RedfishException(String.format("Failed to execute HTTP %s request retry attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e));

utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,26 +207,4 @@ public void retryHttpRequestNoException() throws IOException {
207207
Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
208208
Mockito.verify(client, Mockito.times(3)).execute(Mockito.any());
209209
}
210-
211-
@Test(expected = RedfishException.class)
212-
public void retryHttpRequestExceptionAfterTwoRetries() throws IOException {
213-
Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenThrow(IOException.class);
214-
215-
RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
216-
newRedfishClientspy.retryHttpRequest(url, httpReq, client);
217-
218-
Mockito.verify(newRedfishClientspy, Mockito.never()).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
219-
Mockito.verify(client, Mockito.never()).execute(Mockito.any());
220-
}
221-
222-
@Test
223-
public void retryHttpRequestSuccessAtTheSecondRetry() throws IOException {
224-
Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(httpResponse);
225-
226-
RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
227-
newRedfishClientspy.retryHttpRequest(url, httpReq, client);
228-
229-
Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
230-
Mockito.verify(client, Mockito.times(REDFISHT_REQUEST_RETRIES)).execute(Mockito.any());
231-
}
232210
}

0 commit comments

Comments
 (0)