@@ -151,7 +151,8 @@ private BatchExportResult processBatchWithRetry(
151151 TaskOrchestrationContext ctx ,
152152 List <String > instanceIds ,
153153 ExportJobConfiguration config ) {
154- for (int attempt = 1 ; attempt <= MAX_RETRY_ATTEMPTS ; attempt ++) {
154+ // Retries until the batch fully succeeds or MAX_RETRY_ATTEMPTS is reached; every path returns from inside.
155+ for (int attempt = 1 ; ; attempt ++) {
155156 List <ExportResult > results = exportBatch (ctx , instanceIds , config );
156157 List <ExportResult > failedResults = results .stream ()
157158 .filter (r -> !r .isSuccess ())
@@ -161,7 +162,7 @@ private BatchExportResult processBatchWithRetry(
161162 return BatchExportResult .succeeded (results .size ());
162163 }
163164
164- if (attempt = = MAX_RETRY_ATTEMPTS ) {
165+ if (attempt > = MAX_RETRY_ATTEMPTS ) {
165166 Instant now = ctx .getCurrentInstant ();
166167 int finalAttempt = attempt ;
167168 List <ExportFailure > failures = failedResults .stream ()
@@ -179,9 +180,6 @@ private BatchExportResult processBatchWithRetry(
179180 MIN_BACKOFF_SECONDS * (int ) Math .pow (2 , attempt - 1 ), MAX_BACKOFF_SECONDS );
180181 ctx .createTimer (Duration .ofSeconds (backoffSeconds )).await ();
181182 }
182-
183- // Unreachable: the loop either returns success/failure or retries.
184- return BatchExportResult .succeeded (0 );
185183 }
186184
187185 private List <ExportResult > exportBatch (
0 commit comments