Author: cziegeler
Date: Tue Aug 24 15:32:37 2010
New Revision: 988597
URL: http://svn.apache.org/viewvc?rev=988597&view=rev
Log:
SLING-1560 : Improve and clean up code
Modified:
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java
Modified:
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java
URL:
http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java?rev=988597&r1=988596&r2=988597&view=diff
==============================================================================
---
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java
(original)
+++
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java
Tue Aug 24 15:32:37 2010
@@ -32,26 +32,28 @@ import java.util.SortedSet;
* keep track of all registered resources
*/
class PersistentResourceList {
- private final HashMap<String, SortedSet<RegisteredResource>> data;
+ private final Map<String, SortedSet<RegisteredResource>> data;
private final File dataFile;
@SuppressWarnings("unchecked")
PersistentResourceList(final File dataFile) {
this.dataFile = dataFile;
- ObjectInputStream ois = null;
- HashMap<String, SortedSet<RegisteredResource>> restoredData = null;
- try {
- ois = new ObjectInputStream(new FileInputStream(dataFile));
- restoredData = (HashMap<String,
SortedSet<RegisteredResource>>)ois.readObject();
- } catch(Exception e) {
- Logger.logInfo("Unable to restore data, starting with empty list
(" + e.toString());
- } finally {
- if(ois != null) {
- try {
- ois.close();
- } catch(IOException ignore) {
- // ignore
+ Map<String, SortedSet<RegisteredResource>> restoredData = null;
+ if ( dataFile.exists() ) {
+ ObjectInputStream ois = null;
+ try {
+ ois = new ObjectInputStream(new FileInputStream(dataFile));
+ restoredData = (Map<String,
SortedSet<RegisteredResource>>)ois.readObject();
+ } catch(Exception e) {
+ Logger.logInfo("Unable to restore data, starting with empty
list (" + e.toString());
+ } finally {
+ if(ois != null) {
+ try {
+ ois.close();
+ } catch(IOException ignore) {
+ // ignore
+ }
}
}
}