schedin commented on code in PR #13: URL: https://github.com/apache/maven-jarsigner-plugin/pull/13#discussion_r1421718112
########## src/main/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojo.java: ########## @@ -126,4 +155,62 @@ protected JarSignerRequest createRequest(File archive) throws MojoExecutionExcep request.setKeypass(decrypt(keypass)); return request; } + + /** + * {@inheritDoc} + * + * Will retry signing up to maxTries times if it fails. + * + * @throws MojoExecutionException If all signing attempts fail. + */ + @Override + protected void executeJarSigner(JarSigner jarSigner, JarSignerRequest request) + throws JavaToolException, MojoExecutionException { + Commandline commandLine = null; + int resultCode = 0; + for (int attempt = 0; attempt < maxTries; attempt++) { + JavaToolResult result = jarSigner.execute(request); + resultCode = result.getExitCode(); + commandLine = result.getCommandline(); + if (resultCode == 0) { + return; + } + if (attempt < maxTries - 1) { // If not last attempt + waitStrategy.waitAfterFailure(attempt, Duration.ofSeconds(maxRetryDelaySeconds)); + } + } + throw new MojoExecutionException(getMessage("failure", getCommandlineInfo(commandLine), resultCode)); Review Comment: I have made a minor refactor of the for loop to that it is clearer in the source code that it is the last failure that is returned. I have also added test case `JarsignerSignMojoRetryTest.testLastErrorReturned()` to verify this behavior. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org