You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2026/10/20 15:47:29 UTC

(maven) branch maven-3.10.x updated: fix: error == null to error != null in isError (#13595)

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch maven-3.10.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.10.x by this push:
     new a1da31a656 fix: error == null to error != null in isError (#13595)
a1da31a656 is described below

commit a1da31a65677ace7134f6e2dfc330b7e06a9379e
Author: Arturo Bernal <ab...@apache.org>
AuthorDate: Tue Oct 20 17:47:22 2026 +0200

    fix: error == null to error != null in isError (#13595)
    
    Backport of #11733 to maven-3.10.x.
    
    `ArtifactMetadata.isError()` in `maven-compat` returned `true` when there was no error and `false` when there was one, because the comparison was inverted. The branch still has `return error == null;`.
    
    The patch needed only the module path to be adapted (`maven-compat` is a top level module here). The new `ArtifactMetadataTest` has 5 tests, all fail without the change and pass with it. I did not run the rest of the build or the integration tests.
    
    ---
    
    To make clear that you license your contribution under
    the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
    check one of the following:
    
    - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
    - [x] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
---
 .../repository/metadata/ArtifactMetadata.java      |  2 +-
 .../repository/metadata/ArtifactMetadataTest.java  | 68 ++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java
index 004cd29295..10a749f272 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java
@@ -321,7 +321,7 @@ public void setError(String error) {
     }
 
     public boolean isError() {
-        return error == null;
+        return error != null;
     }
 
     public String getDependencyConflictId() {
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/ArtifactMetadataTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/ArtifactMetadataTest.java
new file mode 100644
index 0000000000..c319730133
--- /dev/null
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/ArtifactMetadataTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.repository.metadata;
+
+import org.apache.maven.artifact.ArtifactScopeEnum;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Regression test for {@link ArtifactMetadata#isError()}.
+ * Verifies that isError() returns true when error is set, false when error is null.
+ */
+@Deprecated
+class ArtifactMetadataTest {
+
+    @Test
+    void isErrorReturnsFalseWhenErrorIsNull() {
+        ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
+        assertFalse(metadata.isError());
+    }
+
+    @Test
+    void isErrorReturnsTrueWhenErrorIsSet() {
+        ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
+        metadata.setError("Something went wrong");
+        assertTrue(metadata.isError());
+    }
+
+    @Test
+    void isErrorReturnsFalseAfterErrorIsCleared() {
+        ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
+        metadata.setError("Something went wrong");
+        metadata.setError(null);
+        assertFalse(metadata.isError());
+    }
+
+    @Test
+    void isErrorReturnsTrueWhenConstructedWithError() {
+        ArtifactMetadata metadata = new ArtifactMetadata(
+                "g", "a", "1.0", "jar", ArtifactScopeEnum.DEFAULT_SCOPE, null, null, null, false, "Resolution failed");
+        assertTrue(metadata.isError());
+    }
+
+    @Test
+    void isErrorReturnsFalseWhenConstructedWithoutError() {
+        ArtifactMetadata metadata = new ArtifactMetadata(
+                "g", "a", "1.0", "jar", ArtifactScopeEnum.DEFAULT_SCOPE, null, null, null, true, null);
+        assertFalse(metadata.isError());
+    }
+}