Skip to content

Commit 03a5e00

Browse files
abhinvv1francisf
authored andcommitted
prevent retries except for 5XX
1 parent 5a462a8 commit 03a5e00

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/com/browserstack/automate/ci/common/uploader/AppUploaderHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ public static String uploadApp(Actionable build, PrintStream logger, String appP
5757
String.format("%s uploaded successfully to Browserstack with app_url : %s", appPath, appId));
5858
return appId;
5959
} catch (AppAutomateException e) {
60-
PluginLogger.logError(logger, String.format("App upload failed with status code: %d. Attempt %d of %d", e.getStatusCode(), attempt, MAX_RETRY_ATTEMPTS));
60+
int statusCode = e.getStatusCode();
61+
PluginLogger.logError(logger, String.format("App upload failed with status code: %d. Attempt %d of %d", statusCode, attempt, MAX_RETRY_ATTEMPTS));
6162
PluginLogger.logError(logger, e.getMessage());
62-
if (attempt < MAX_RETRY_ATTEMPTS) {
63+
if ((statusCode >= 500 || statusCode == 0) && attempt < MAX_RETRY_ATTEMPTS) {
6364
PluginLogger.log(logger, String.format("Retrying in %d seconds...", RETRY_DELAY_MS / 1000));
6465
try {
6566
Thread.sleep(RETRY_DELAY_MS);
@@ -68,11 +69,10 @@ public static String uploadApp(Actionable build, PrintStream logger, String appP
6869
PluginLogger.log(logger, "Upload retry interrupted. Error: " + ie.getMessage());
6970
return null;
7071
}
72+
} else {
73+
return null;
7174
}
72-
} catch (InvalidFileExtensionException e) {
73-
PluginLogger.logError(logger, e.getMessage());
74-
return null;
75-
} catch (FileNotFoundException e) {
75+
} catch (InvalidFileExtensionException | FileNotFoundException e) {
7676
PluginLogger.logError(logger, e.getMessage());
7777
return null;
7878
}

0 commit comments

Comments
 (0)