aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1704412 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1404Test.java
Date Mon, 21 Sep 2015 19:59:41 GMT
Author: jwross
Date: Mon Sep 21 19:59:40 2015
New Revision: 1704412

URL: http://svn.apache.org/viewvc?rev=1704412&view=rev
Log:
ARIES-1404 Restart of the osgi container does not restart subsystem core because of an error
related to missing resource org.apache.aries.subsystem.resource.synthesized

This issue can occur with an unresolved optional dependency as well as with an unresolved
mandatory dependency in conjunction with the Application-ImportService header.

I added the filtering of synthetic resources to the computeDependencies(SubsystemManifest)
method of SubsystemResource rather than the suggested location
in synthesized.patch (Bas - baselzinga@gmail.com) because it will prevent issues with other
current or future headers.

The patch modifications to setImportIsolationPolicy are not appropriate because service dependencies
are already included in the wiring if the implementation
has been made aware of them through one of the supported means which are (1) Require-Capability
bundle headers in the osgi.service namespace, and (2) Blueprint XML.

I also added a dedicated test for this defect rather than including it in the already existing
ResolutionTest as in the test-cases-1.patch (Bas - baselzinga@gmail.com)
of ARIES-1357.

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

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java?rev=1704412&r1=1704411&r2=1704412&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
Mon Sep 21 19:59:40 2015
@@ -374,12 +374,18 @@ public class SubsystemResource implement
 			setImportIsolationPolicy(resolution);
 			for (Map.Entry<Resource, List<Wire>> entry : resolution.entrySet()) {
 				Resource key = entry.getKey();
-				if (!contentHeader.contains(key)) {
+				String type = ResourceHelper.getTypeAttribute(key);
+				// Do not include synthetic resources in the dependencies.
+				if (!Constants.ResourceTypeSynthesized.equals(type)
+						&& !contentHeader.contains(key)) {
 					addDependency(key);
 				}
 				for (Wire wire : entry.getValue()) {
 					Resource provider = wire.getProvider();
-					if (!contentHeader.contains(provider)) {
+					type = ResourceHelper.getTypeAttribute(provider);
+					// Do not include synthetic resources in the dependencies.
+					if (!Constants.ResourceTypeSynthesized.equals(type)
+							&& !contentHeader.contains(provider)) {
 						addDependency(provider);
 					}
 				}

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1404Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1404Test.java?rev=1704412&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1404Test.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1404Test.java
Mon Sep 21 19:59:40 2015
@@ -0,0 +1,143 @@
+/*
+ * 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 static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.subsystem.itests.Header;
+import org.apache.aries.subsystem.itests.SubsystemTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+import org.osgi.service.subsystem.SubsystemException;
+
+/*
+ * https://issues.apache.org/jira/browse/ARIES-1404
+ * 
+ * Restart of the osgi container does not restart subsystem core because of an 
+ * error related to missing resource 
+ * org.apache.aries.subsystem.resource.synthesized.
+ */
+public class Aries1404Test extends SubsystemTest {
+    /*
+     * Subsystem-SymbolicName: application.a.esa
+     * Subsystem-Content: bundle.a.jar
+     */
+    private static final String APPLICATION_A = "application.a.esa";
+    /*
+     * Subsystem-SymbolicName: application.b.esa
+     * Subsystem-Content: bundle.b.jar
+     * Application-ImportService: b
+     */
+    private static final String APPLICATION_B = "application.b.esa";
+	/*
+	 * Bundle-SymbolicName: bundle.a.jar
+	 * Require-Capability: a;resolution:=optional
+	 */
+	private static final String BUNDLE_A = "bundle.a.jar";
+	/*
+	 * Bundle-SymbolicName: bundle.b.jar
+	 * Require-Capability: osgi.service;filter:="(objectClass=b)"
+	 */
+	private static final String BUNDLE_B = "bundle.b.jar";
+	
+	private static boolean createdTestFiles;
+	
+	@Before
+	public void createTestFiles() throws Exception {
+		if (createdTestFiles)
+			return;
+		createBundleA();
+		createBundleB();
+		createApplicationA();
+		createApplicationB();
+		createdTestFiles = true;
+	}
+	
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), new Header(Constants.REQUIRE_CAPABILITY, "a;resolution:=optional"));
+	}
+	
+	private void createBundleB() throws IOException {
+		createBundle(name(BUNDLE_B), new Header(Constants.REQUIRE_CAPABILITY, "osgi.service;filter:=\"(objectClass=b)\""));
+	}
+    
+    private static void createApplicationA() throws IOException {
+        createApplicationAManifest();
+        createSubsystem(APPLICATION_A, BUNDLE_A);
+    }
+    
+    private static void createApplicationAManifest() throws IOException {
+        Map<String, String> attributes = new HashMap<String, String>();
+        attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_A);
+        createManifest(APPLICATION_A + ".mf", attributes);
+    }
+    
+    private static void createApplicationB() throws IOException {
+        createApplicationBManifest();
+        createSubsystem(APPLICATION_B, BUNDLE_B);
+    }
+    
+    private static void createApplicationBManifest() throws IOException {
+        Map<String, String> attributes = new HashMap<String, String>();
+        attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_B);
+        attributes.put("Application-ImportService", "b");
+        createManifest(APPLICATION_B + ".mf", attributes);
+    }
+    
+    @Test 
+    public void testProvisionedSyntheticResourceWithOptionalRequirement() throws Exception
{
+    	Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
+    	try {
+    		try {
+    			restartSubsystemsImplBundle();
+    		}
+    		catch (SubsystemException e) {
+    			e.printStackTrace();
+    			fail("Core bundle should have restarted");
+    		}
+    	}
+    	finally {
+    		stopAndUninstallSubsystemSilently(applicationA);
+    	}
+    }
+    
+    @Test 
+    public void testProvisionedSyntheticResourceWithMandatoryRequirementAndApplicationImportService()
throws Exception {
+    	Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
+    	try {
+    		try {
+    			restartSubsystemsImplBundle();
+    		}
+    		catch (SubsystemException e) {
+    			e.printStackTrace();
+    			fail("Core bundle should have restarted");
+    		}
+    	}
+    	finally {
+    		stopAndUninstallSubsystemSilently(applicationB);
+    	}
+    }
+}



Mime
View raw message