#45577: Close streams when the b-tree detects the files are corrupted, to allow reboot BLD200406271800
authormmatula@netbeans.org
Sun, 27 Jun 2004 14:42:04 +0000
changeset 1532728da75b46eb
parent 1531 3d87f07fbc01
child 1533 7a88570d6e12
#45577: Close streams when the b-tree detects the files are corrupted, to allow reboot
mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/BtreeDatabase.java
     1.1 --- a/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/BtreeDatabase.java	Sun Jun 27 14:39:08 2004 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/BtreeDatabase.java	Sun Jun 27 14:42:04 2004 +0000
     1.3 @@ -270,24 +270,30 @@
     1.4  
     1.5          fileCache = new FileCache(
     1.6                          PAGE_SIZE, FILE_CACHE_SIZE, fileNames, names[LFL]);
     1.7 -        dataFile = new BtreeDataFile(this.myStorage, fileCache, 0);
     1.8 -        myStorage.gen = dataFile;
     1.9 -        BtreeFileSource source = 
    1.10 -            new BtreeFileSource(1, fileCache, PAGE_SIZE, 
    1.11 -	    			isNew || rebuildIndex, dataFile, myStorage);
    1.12 -        indexFile = new SinglevaluedBtree(repositoryName, 
    1.13 -                            Storage.EntryType.MOFID, Storage.EntryType.INT, 
    1.14 -                            source);        
    1.15 -        
    1.16 -	if (rebuildIndex) {
    1.17 -	    rebuildIndexFile();
    1.18 -	    save (true);
    1.19 -	}
    1.20 +        boolean failure = true;
    1.21 +        try {
    1.22 +            dataFile = new BtreeDataFile(this.myStorage, fileCache, 0);
    1.23 +            myStorage.gen = dataFile;
    1.24 +            BtreeFileSource source = 
    1.25 +                new BtreeFileSource(1, fileCache, PAGE_SIZE, 
    1.26 +                                    isNew || rebuildIndex, dataFile, myStorage);
    1.27 +            indexFile = new SinglevaluedBtree(repositoryName, 
    1.28 +                                Storage.EntryType.MOFID, Storage.EntryType.INT, 
    1.29 +                                source);        
    1.30  
    1.31 -	fetchClassIndex();
    1.32 +            if (rebuildIndex) {
    1.33 +                rebuildIndexFile();
    1.34 +                save (true);
    1.35 +            }
    1.36  
    1.37 -        if (isNew) {
    1.38 -            save (true);
    1.39 +            fetchClassIndex();
    1.40 +
    1.41 +            if (isNew) {
    1.42 +                save (true);
    1.43 +            }
    1.44 +            failure = false;
    1.45 +        } finally {
    1.46 +            if (failure) fileCache.abort();
    1.47          }
    1.48      }
    1.49