[Git][java-team/felix-resolver][upstream] New upstream version 1.16.0

Emmanuel Bourg gitlab at salsa.debian.org
Sun Aug 2 23:17:01 BST 2020



Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / felix-resolver


Commits:
07152408 by Emmanuel Bourg at 2020-08-03T00:00:47+02:00
New upstream version 1.16.0
- - - - -


8 changed files:

- NOTICE
- doc/changelog.txt
- pom.xml
- src/main/java/org/apache/felix/resolver/Candidates.java
- src/main/java/org/apache/felix/resolver/ResolutionError.java
- src/main/java/org/apache/felix/resolver/ResolverImpl.java
- + src/main/java/org/apache/felix/resolver/reason/ReasonException.java
- + src/main/resources/org/apache/felix/resolver/reason/packageinfo


Changes:

=====================================
NOTICE
=====================================
@@ -1,6 +1,6 @@
 
 Apache Felix Resolver
-Copyright 2006-2017 The Apache Software Foundation
+Copyright 2006-2018 The Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).


=====================================
doc/changelog.txt
=====================================
@@ -1,3 +1,9 @@
+1.16.0
+------
+
+** Improvement
+    * [FELIX-5782] - allow resolver errors to be introspected
+
 1.14.0
 ------
 


=====================================
pom.xml
=====================================
@@ -29,12 +29,12 @@
   <description>
     Provide OSGi resolver service.
   </description>
-  <version>1.14.0</version>
+  <version>1.16.0</version>
   <artifactId>org.apache.felix.resolver</artifactId>
   <scm>
-     <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.14.0</connection>
-     <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.14.0</developerConnection>
-     <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.14.0</url>
+     <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</connection>
+     <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</developerConnection>
+     <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</url>
   </scm>
   <dependencies>
     <dependency>
@@ -68,13 +68,14 @@
         <configuration>
           <instructions>
             <_sources>true</_sources>
-            <_sourcepath>${build.sourceDirectory}</_sourcepath>
-            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <_sourcepath>${project.build.sourceDirectory}</_sourcepath>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
             <Bundle-Activator>
               org.apache.felix.resolver.Activator
             </Bundle-Activator>
             <Private-Package>org.apache.*</Private-Package>
             <Export-Package>
+              org.apache.felix.resolver.reason,
               org.osgi.service.resolver.*;provide:=true
             </Export-Package>
             <Import-Package>


=====================================
src/main/java/org/apache/felix/resolver/Candidates.java
=====================================
@@ -24,11 +24,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.felix.resolver.ResolverImpl.PermutationType;
 import org.apache.felix.resolver.ResolverImpl.ResolveSession;
+import org.apache.felix.resolver.reason.ReasonException;
 import org.apache.felix.resolver.util.*;
 import org.osgi.framework.Version;
 import org.osgi.framework.namespace.*;
 import org.osgi.resource.*;
 import org.osgi.service.resolver.HostedCapability;
+import org.osgi.service.resolver.ResolutionException;
 import org.osgi.service.resolver.ResolveContext;
 
 class Candidates
@@ -1276,6 +1278,11 @@ class Candidates
             return Collections.singleton(requirement);
         }
 
+        @Override
+        public ResolutionException toException() {
+            return new ReasonException(ReasonException.Reason.DynamicImport, getMessage(), null, getUnresolvedRequirements());
+        }
+
     }
 
     static class FragmentNotSelectedError extends ResolutionError {
@@ -1290,6 +1297,16 @@ class Candidates
             return "Fragment was not selected for attachment: " + resource;
         }
 
+        @Override
+        public Collection<Requirement> getUnresolvedRequirements() {
+            return resource.getRequirements(HostNamespace.HOST_NAMESPACE);
+        }
+
+        @Override
+        public ResolutionException toException() {
+            return new ReasonException(ReasonException.Reason.FragmentNotSelected, getMessage(), null, getUnresolvedRequirements());
+        }
+
     }
 
     static class MissingRequirementError extends ResolutionError {
@@ -1320,6 +1337,12 @@ class Candidates
             return Collections.singleton(requirement);
         }
 
+        @Override
+        public ResolutionException toException() {
+            return new ReasonException(
+                ReasonException.Reason.MissingRequirement, getMessage(), cause != null ? cause.toException() : null, getUnresolvedRequirements());
+        }
+
     }
 
 }


=====================================
src/main/java/org/apache/felix/resolver/ResolutionError.java
=====================================
@@ -38,9 +38,7 @@ public abstract class ResolutionError {
         return Collections.emptyList();
     }
 
-    public ResolutionException toException() {
-        return new ResolutionException(getMessage(), null, getUnresolvedRequirements());
-    }
+    public abstract ResolutionException toException();
 
     @Override
     public String toString() {


=====================================
src/main/java/org/apache/felix/resolver/ResolverImpl.java
=====================================
@@ -25,6 +25,7 @@ import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.felix.resolver.reason.ReasonException;
 import org.apache.felix.resolver.util.ArrayMap;
 import org.apache.felix.resolver.util.CandidateSelector;
 import org.apache.felix.resolver.util.OpenHashMap;
@@ -2464,6 +2465,11 @@ public class ResolverImpl implements Resolver
 
             return cap;
         }
+
+        @Override
+        public ResolutionException toException() {
+            return new ReasonException(ReasonException.Reason.UseConstraint, getMessage(), null, getUnresolvedRequirements());
+        }
     }
 
     private static class EnhancedExecutor


=====================================
src/main/java/org/apache/felix/resolver/reason/ReasonException.java
=====================================
@@ -0,0 +1,96 @@
+/*
+ * 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.felix.resolver.reason;
+
+import java.util.Collection;
+
+import org.osgi.resource.Requirement;
+import org.osgi.service.resolver.ResolutionException;
+
+/**
+ * An exception that holds the reason for a resolution failure.
+ *
+ * @see {@link ResolutionException}
+ */
+public class ReasonException extends ResolutionException {
+
+    /**
+     * The reasons for resolution failure.
+     */
+    public static enum Reason {
+        /**
+         * Represents an unresolved package referenced by {@code Dynamic-ImportPackage}.
+         * <p>
+         * {@link ReasonException#getUnresolvedRequirements()} will return a
+         * collection containing the single {@code osgi.wiring.package;resolution:=dynamic}
+         * requirement which failed to resolve.
+         * <p>
+         * This reason has no a transitive cause.
+         */
+        DynamicImport,
+
+        /**
+         * Represents the scenario where a fragment matches a host but is not
+         * selected because another fragment with the same {@code Bundle-SymbolicName}
+         * already matched, usually a fragment of a higher version.
+         * <p>
+         * {@link ReasonException#getUnresolvedRequirements()} will return
+         * a collection containing the single {@code osgi.wiring.host} requirement of
+         * the fragment.
+         * <p>
+         * This reason has no a transitive cause.
+         */
+        FragmentNotSelected,
+
+        /**
+         * Represents the scenario where a requirement could not be resolved.
+         * <p>
+         * {@link ReasonException#getUnresolvedRequirements()} will return
+         * a collection containing a single requirement that didn't resolve.
+         * <p>
+         * This reason may have a transitive cause.
+         */
+        MissingRequirement,
+
+        /**
+         * Represents a failure in the <em>use constraints</em> of a bundle.
+         * <p>
+         * {@link ReasonException#getUnresolvedRequirements()} will return
+         * a collection containing a single requirement to blame for the use constraint
+         * violation.
+         * <p>
+         * This reason has no a transitive cause.
+         */
+        UseConstraint
+    }
+
+    private static final long serialVersionUID = -5276675175114379539L;
+
+    public ReasonException(Reason reason, String message, Throwable cause, Collection<Requirement> unresolvedRequirements) {
+        super(message, cause, unresolvedRequirements);
+        this.reason = reason;
+    }
+
+    public Reason getReason() {
+        return reason;
+    }
+
+    private final Reason reason;
+
+}


=====================================
src/main/resources/org/apache/felix/resolver/reason/packageinfo
=====================================
@@ -0,0 +1 @@
+version 1.0.0
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/java-team/felix-resolver/-/commit/071524089a8d858f53331c2137d13b0618527302

-- 
View it on GitLab: https://salsa.debian.org/java-team/felix-resolver/-/commit/071524089a8d858f53331c2137d13b0618527302
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20200802/8df9e2a8/attachment.html>


More information about the pkg-java-commits mailing list