Bug 486952 - [osgi R7] set org.osgi.framework.storage property when
derived

Change-Id: I7ff18cea64a58827ab74374c2b8db5fb97b80837
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 983fabf..07f7f7f 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -2417,6 +2417,19 @@
 		new Equinox(null);
 	}
 
+	public void testNullStorageArea() throws BundleException {
+		File install = getContext().getDataFile(getName());
+		install.mkdirs();
+		Equinox equinox = new Equinox(Collections.singletonMap("osgi.install.area", install.getAbsolutePath()));
+		try {
+			equinox.init();
+			String storageArea = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_STORAGE);
+			assertNotNull("No storage area set.", storageArea);
+		} finally {
+			equinox.stop();
+		}
+	}
+
 	public void testOSGiDevSetsCheckConfiguration() throws BundleException {
 		String originalCheckConfiguration = System.clearProperty(EquinoxConfiguration.PROP_CHECK_CONFIGURATION);
 		try {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index eb554cd..a582750 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -126,6 +126,12 @@
 		Location parent = this.osgiLocation.getParentLocation();
 		parentRoot = parent == null ? null : new File(parent.getURL().getFile());
 
+		if (container.getConfiguration().getConfiguration(Constants.FRAMEWORK_STORAGE) == null) {
+			// Set the derived value if not already set as part of configuration.
+			// Note this is the parent directory of where the framework stores data (org.eclipse.osgi/)
+			container.getConfiguration().setConfiguration(Constants.FRAMEWORK_STORAGE, childRoot.getParentFile().getAbsolutePath());
+		}
+
 		InputStream info = getInfoInputStream();
 		DataInputStream data = info == null ? null : new DataInputStream(new BufferedInputStream(info));
 		try {