You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2012/09/30 14:07:26 UTC
svn commit: r1392005 - in /karaf/trunk/features/core/src:
main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
test/java/org/apache/karaf/features/FeaturesServiceTest.java
Author: cschneider
Date: Sun Sep 30 12:07:25 2012
New Revision: 1392005
URL: http://svn.apache.org/viewvc?rev=1392005&view=rev
Log:
KARAF-608 Bugfix in FeatureServiceTest and saveState
Modified:
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=1392005&r1=1392004&r2=1392005&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java Sun Sep 30 12:07:25 2012
@@ -21,6 +21,7 @@ import static java.lang.String.format;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
@@ -770,19 +771,28 @@ public class FeaturesServiceImpl impleme
}
protected void saveState() {
+ OutputStream os = null;
try {
File file = bundleManager.getDataFile("FeaturesServiceState.properties");
Properties props = new Properties();
saveSet(props, "repositories.", repositories.keySet());
saveMap(props, "features.", installed);
- OutputStream os = new FileOutputStream(file);
+ os = new FileOutputStream(file);
+ props.store(new FileOutputStream(file), "FeaturesService State");
+ } catch (Exception e) {
+ LOGGER.error("Error persisting FeaturesService state", e);
+ } finally {
+ closeStream(os);
+ }
+ }
+
+ private void closeStream(OutputStream os) {
+ if (os != null) {
try {
- props.store(new FileOutputStream(file), "FeaturesService State");
- } finally {
os.close();
+ } catch (IOException e) {
+ // Ignore
}
- } catch (Exception e) {
- LOGGER.error("Error persisting FeaturesService state", e);
}
}
Modified: karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java?rev=1392005&r1=1392004&r2=1392005&view=diff
==============================================================================
--- karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java (original)
+++ karaf/trunk/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java Sun Sep 30 12:07:25 2012
@@ -50,6 +50,7 @@ import org.apache.karaf.features.interna
import org.apache.karaf.features.internal.TestBase;
import org.easymock.EasyMock;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -62,7 +63,8 @@ public class FeaturesServiceTest extends
File dataFile;
- protected void setUp() throws IOException {
+ @Before
+ public void setUp() throws IOException {
dataFile = File.createTempFile("features", null, null);
}