gnodet-bot commented on code in PR #2209:
URL: https://github.com/apache/maven-resolver/pull/2209#discussion_r4313569729


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java:
##########
@@ -307,6 +307,20 @@ private List<ArtifactResult> resolve(
 
                     artifact = artifact.setVersion(versionResult.getVersion());
 
+                    if (artifact.getVersion() == null
+                            || artifact.getVersion().trim().isEmpty()) {

Review Comment:
   💡 **Nit — dead null check:** `artifact.getVersion() == null` is unreachable 
after `artifact.setVersion(versionResult.getVersion())`. 
`AbstractArtifact.setVersion(null)` either short-circuits and returns `this` 
(when the current version is already `""`) or calls `newInstance(null, ...)` → 
`DefaultArtifact` constructor → `emptify(null)` → `""`. Either path produces an 
empty string, never null. Simplify to:
   
   ```suggestion
                       if (artifact.getVersion().trim().isEmpty()) {
   ```



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java:
##########
@@ -307,6 +307,20 @@ private List<ArtifactResult> resolve(
 
                     artifact = artifact.setVersion(versionResult.getVersion());
 
+                    if (artifact.getVersion() == null
+                            || artifact.getVersion().trim().isEmpty()) {

Review Comment:
   💡 **Nit — dead null check:** `artifact.getVersion() == null` is unreachable 
after `artifact.setVersion(versionResult.getVersion())`. 
`AbstractArtifact.setVersion(null)` either short-circuits and returns `this` 
(when the current version is already `""`) or calls `newInstance(null, ...)` → 
`DefaultArtifact` constructor → `emptify(null)` → `""`. Either path produces an 
empty string, never null. Simplify to:
   
   ```suggestion
                       if (artifact.getVersion().trim().isEmpty()) {
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to