aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1707431 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java
Date Thu, 08 Oct 2015 02:17:14 GMT
Author: jwross
Date: Thu Oct  8 02:17:13 2015
New Revision: 1707431

URL: http://svn.apache.org/viewvc?rev=1707431&view=rev
Log:
ARIES-1428 org.osgi.framework.BundleException: Could not resolve module: <module> Bundle
was filtered by a resolver hook.

Prevent bundles that are not associated with any subsystems from resolving only if there is
a subsystem installation in progress on the same thread.

Added:
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java?rev=1707431&r1=1707430&r2=1707431&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResolverHook.java
Thu Oct  8 02:17:13 2015
@@ -77,7 +77,7 @@ public class SubsystemResolverHook imple
 					// Don't want to filter out the region context bundle.
 					continue;
 				Collection<BasicSubsystem> subsystems = this.subsystems.getSubsystemsReferencing(revision);
-				if (subsystems.isEmpty()) {
+				if (subsystems.isEmpty() && ThreadLocalSubsystem.get() != null) {
 				    // This is the revision of a bundle being installed as part of a subsystem installation
 				    // before it has been added as a reference or constituent.
 				    iterator.remove();

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java?rev=1707431&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1428Test.java
Thu Oct  8 02:17:13 2015
@@ -0,0 +1,85 @@
+/*
+ * 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.aries.subsystem.itests.defect;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.aries.subsystem.itests.SubsystemTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+/*
+ * https://issues.apache.org/jira/browse/ARIES-1428
+ * 
+ * org.osgi.framework.BundleException: Could not resolve module: <module> Bundle 
+ * was filtered by a resolver hook.
+ */
+public class Aries1428Test extends SubsystemTest {
+	/*
+	 * Bundle-SymbolicName: bundle.a.jar
+	 */
+	private static final String BUNDLE_A = "bundle.a.jar";
+	
+	private void createBundleA() throws IOException {
+		createBundle(
+				name(BUNDLE_A));
+	}
+	
+	private static boolean createdTestFiles;
+	
+	@Before
+	public void createTestFiles() throws Exception {
+		if (createdTestFiles)
+			return;
+		createBundleA();
+		createdTestFiles = true;
+	}
+    
+    @Test
+    public void testBundleNotPartOfSubsystemInstallationResolves() throws Exception {
+    	final Bundle core = getSubsystemCoreBundle();
+    	core.stop();
+    	bundleContext.addServiceListener(
+    			new ServiceListener() {
+    				@Override
+    				public void serviceChanged(ServiceEvent event) {
+    					if (event.getType() == ServiceEvent.REGISTERED) {
+    						File file = new File(BUNDLE_A);
+    						try {
+    							Bundle bundleA = bundleContext.installBundle(
+    									file.toURI().toString(), new FileInputStream(file));
+    							bundleA.start();
+    						}
+    						catch (Exception e) {
+    							e.printStackTrace();
+    						}
+    					}
+    				}
+    			},
+    			"(objectClass=org.osgi.service.subsystem.Subsystem)"
+    	);
+    	core.start();
+    	assertBundleState(Bundle.RESOLVED | Bundle.ACTIVE, BUNDLE_A, getRootSubsystem());
+    }
+}



Mime
View raw message