Implement maxTries parameter#1
Conversation
|
i do need this enhancement because tsa timeouts on me quite often. turns out im the guy who also needs the delay. tsa.starfieldtech.com currently starts timeouting after many requests. having dozens of jars to sign it stops long before it is even close to finishing. |
|
@lasselindqvist thanks for sharing your changes. that made it easier for me to also add the retryDelay parameter. |
|
@rfscholte, any chance of getting this merged? |
|
I need to catch up after a week of absence due to conferences. But the first thing I notice is a missing test. Probably easiest to solve when mocking jarSigner. |
1df500a to
7b10ed5
Compare
maxTries lets the plugin try signing multiple times if first tries fail. Useful when used with a Time Stamp Authority. Default is 1 so backwards compatibility is fully kept.
7b10ed5 to
67ddfef
Compare
|
I added a unit test for the new method and fixed Checkstyle errors while at it. "mvn install" passes. |
|
@rfscholte, possible to merge this? I have been using a forked version for a while and can confirm it works. |
|
|
||
| @Test | ||
| public void testSignSuccessOnFirst() throws MojoExecutionException, JavaToolException { | ||
| AbstractJarsignerMojo mojo = Mockito.mock(AbstractJarsignerMojo.class); |
There was a problem hiding this comment.
@lasselindqvist Excellent!
This is the first unit test. One advice, pls use Mockito injection in JUnit4+ and keep using our codestyle with spaces and brackets on new line. This may help you to configure Eclipse or IDEA.
https://maven.apache.org/developers/conventions/code.html
Configuration of Ides:
https://maven.apache.org/developers/maven-idea-codestyle.xml
https://maven.apache.org/developers/maven-eclipse-codestyle.xml
There was a problem hiding this comment.
I'll try to find time to change the formatting this weekend.
| result1.setExitCode( 1 ); | ||
| JavaToolResult result2 = new JavaToolResult(); | ||
| result2.setExitCode( 1 ); | ||
| Mockito.when( jarSigner.execute( request )).thenReturn( result1 ).thenReturn( result2 ); |
There was a problem hiding this comment.
you can avoid chaining in one line and use multiple lines:
when( ... )
.thenReturn( ... )
.thenReturn( ... );
There was a problem hiding this comment.
This way you can avoid too long lines which are broken in Github and it is more readable because your eyes see all important structure/parts of the story sentence in one place: when then... and the arguments are the second important things.
slachiewicz
left a comment
There was a problem hiding this comment.
need more tests - sometimes build fails https://builds.apache.org/view/M-R/view/Maven/job/maven-box/job/maven-jarsigner-plugin/job/MJARSIGNER-41/
|
maybe we should combine this change with #3 |
|
The failures seem to be unrelated to this: if it is indeed the "new" tasks that break the build. The tests pass fine. |
|
why is this not really picked up? Our build system now and then breaks constantly because of those TSA servers. i need to manually switch between then (adjusting the mvn settings file) to go to another TSA server now and then, and then that one can have other problems.. we really need what other sign tools already have implemented not just a retry count but also that you can have multiply tsa urls.. <jarsigner.tsa>http://timestamp.sectigo.com,http://rfc3161timestamp.globalsign.com/advanced,http://timestamp.digicert.com</jarsigner.tsa> then if the first fails it retries it with the second one if that one fails it tries it with the 3rd. i think only then we can get a reliable build, now it is just a hit and miss. |
|
i made a patch for this on top of this jarsigner plugin: now it tries all the timestamp urls you give the jarsigner.tsa (separated by ,) and if all of them fail, it will retry them again with a delay that you can set. |
|
Since the multiple tsa URL suggestion by @jcompagner was a bit hidden (in the comment of this pull request) I have written a dedicated ticket for it: https://issues.apache.org/jira/projects/MJARSIGNER/issues/MJARSIGNER-74. |
|
that multi tsa is more important then just a retry, that is because if a tsa service is not working then it can be not working for quite some time (not minutes but more hours or half days....) thats why we use now a patch version of the jarsigner: that does retries but first over all tsa urls that are given (comma separated list) <jarsigner.tsa>http://timestamp.sectigo.com,http://rfc3161timestamp.globalsign.com/advanced,http://timestamp.digicert.com</jarsigner.tsa> and then with: <jarsigner.tsaMaxRetry>3</jarsigner.tsaMaxRetry> but those last 2 are not that important it could even have retry once, because if the first tsa fails then retrying it over the other 2 will almost all the time work fine |
|
superseded by #13 |
|
@jcompagner: You have a good point. Since this pull request is now closed (because most of the feature request was implemented in #13), do you think the existing ticket https://issues.apache.org/jira/projects/MJARSIGNER/issues/MJARSIGNER-74 (that links to the patch) is enough to track this? Since I did not have direct need for multiple TSA URLs I did not implement it. |
|
as i said, for us multiply TSA is way more important then retries, it just need to roll over the TSA once Because last week Thursday, 1 or 2 projects builds where broken (that where using a ant sign script instead of mvn) and that ant sign script doesn't have that multiply tsa support to http://sha256timestamp.ws.symantec.com/sha256/timestamp because starting in the night until the whole morning the sectigo one failed, so that was many ours.. |
Implements maxTries discussed in MJARSIGNER-41. This change is based on the patch provided in the issue in Jira.
maxTries lets the plugin try signing multiple times if first tries fail. Useful when used with a Time Stamp Authority. Default is 1 so backwards compatibility is fully kept.