-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNG-8150] Handle absent source/target files in transfer listener #1575
[MNG-8150] Handle absent source/target files in transfer listener #1575
Conversation
Looks nice, but the maven-3.9.x branch (Maven 3.9.x) is Java 8... |
Yeah, I see that now :) Do you want me to keep records on this branch and use a class on |
No, IMO records on master (Maven 4, that is Java 17) is ok, I just warned you when you try to backport this to maven-3.9.x branch... |
Makes sense, thank you. Here is the PR for backport: #1576 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor changes would be nice if included.
@@ -35,7 +35,7 @@ | |||
*/ | |||
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener { | |||
|
|||
private Map<TransferResource, Long> transfers = new LinkedHashMap<>(); | |||
private Map<TransferResourceIdentifier, TransferResourceAndSize> transfers = new LinkedHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those 3 fields should be final
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 274f180
@@ -35,7 +35,7 @@ | |||
*/ | |||
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener { | |||
|
|||
private Map<TransferResource, Long> transfers = new LinkedHashMap<>(); | |||
private Map<TransferResourceIdentifier, TransferResourceAndSize> transfers = new LinkedHashMap<>(); | |||
private FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get rid of the Locale.ENGLISH
parameter which is unused, though this can be done in a subsequent PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #1579
@@ -35,7 +35,7 @@ | |||
*/ | |||
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment specifying that this class is not thread safe and should only be used from a single thread, or wrapped in the SimplexTransferListener
?
It would avoid having to look why this class is not thread safe (the StringBuffer
as a field makes that quite easy to spot).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 274f180
) Backporting #1575 to Maven 3.9.x. - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) --- https://issues.apache.org/jira/browse/MNG-8150
## Summary Addressing #1575 (comment) - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) --- https://issues.apache.org/jira/browse/MNG-8150
Summary
The PR address two issues observed in the
SimplexTransferListener
andConsoleMavenTransferListener
:SimplexTransferListener
will break with an NPE if thefile
is not set on the resource.TransferResource
is not immutable and does not implementequals
orhashCode,
making its usage in collections brittle. Listener consumers are not guaranteed to reuse the same instance across listener invocations. I suggest wrapping it in an immutable identifier.Let me know if I am overthinking this or if anything else is needed.
Resolves https://issues.apache.org/jira/browse/MNG-8150