diff options
author | Thomas Watson | 2007-10-24 18:38:57 +0000 |
---|---|---|
committer | Thomas Watson | 2007-10-24 18:38:57 +0000 |
commit | ee47e0b539ed62b75bc72506b8947c35a917d09a (patch) | |
tree | ef98a4fd4fceddd36fd29c954ab5ed560271f073 | |
parent | 1fc3d832fcfe6be196412b1f1a1e069a66e4d128 (diff) | |
download | rt.equinox.framework-ee47e0b539ed62b75bc72506b8947c35a917d09a.tar.gz rt.equinox.framework-ee47e0b539ed62b75bc72506b8947c35a917d09a.tar.xz rt.equinox.framework-ee47e0b539ed62b75bc72506b8947c35a917d09a.zip |
Clean up API in prep for bug 207073
-rw-r--r-- | bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java index bad41b82e..7e6f80b9e 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. + * Copyright (c) 2003, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -83,34 +83,42 @@ public class ReliableFile { private static final byte identifier2[] = {'.', 'v', '1', '\n'}; private static final int BUF_SIZE = 4096; - private static int maxInputStreamBuffer = 128 * 1024; //128k - private static int defaultMaxGenerations = 2; - private static boolean fileSharing = true; - //our cache of the last lookuped up generations for a file + private static final int maxInputStreamBuffer; + private static final int defaultMaxGenerations; + private static final boolean fileSharing; + //our cache of the last looked up generations for a file private static File lastGenerationFile = null; private static int[] lastGenerations = null; static { String prop = FrameworkProperties.getProperty(PROP_MAX_BUFFER); + int tmpMaxInput = 128 * 1024; //128k if (prop != null) { try { - maxInputStreamBuffer = Integer.parseInt(prop); + tmpMaxInput = Integer.parseInt(prop); } catch (NumberFormatException e) {/*ignore*/ } } + maxInputStreamBuffer = tmpMaxInput; + + int tmpDefaultMax = 2; prop = FrameworkProperties.getProperty(PROP_MAX_GENERATIONS); if (prop != null) { try { - defaultMaxGenerations = Integer.parseInt(prop); + tmpDefaultMax = Integer.parseInt(prop); } catch (NumberFormatException e) {/*ignore*/ } } + defaultMaxGenerations = tmpDefaultMax; + prop = FrameworkProperties.getProperty(PROP_OSGI_LOCKING); + boolean tmpFileSharing = true; if (prop != null) { if (prop.equals("none")) { //$NON-NLS-1$ - fileSharing = false; + tmpFileSharing = false; } } + fileSharing = tmpFileSharing; } /** File object for original reference file */ @@ -249,20 +257,18 @@ public class ReliableFile { CacheInfo info; synchronized (cacheFiles) { info = (CacheInfo) cacheFiles.get(file); - } - long timeStamp = file.lastModified(); - if (info == null || timeStamp != info.timeStamp) { - try { - is = new FileInputStream(file); - if (is.available() < maxInputStreamBuffer) - is = new BufferedInputStream(is); - Checksum cksum = getChecksumCalculator(); - int filetype = getStreamType(is, cksum); - info = new CacheInfo(filetype, cksum, timeStamp); - synchronized (cacheFiles) { + long timeStamp = file.lastModified(); + if (info == null || timeStamp != info.timeStamp) { + try { + is = new FileInputStream(file); + if (is.available() < maxInputStreamBuffer) + is = new BufferedInputStream(is); + Checksum cksum = getChecksumCalculator(); + int filetype = getStreamType(is, cksum); + info = new CacheInfo(filetype, cksum, timeStamp); cacheFiles.put(file, info); + } catch (IOException e) {/*ignore*/ } - } catch (IOException e) {/*ignore*/ } } @@ -359,7 +365,7 @@ public class ReliableFile { /** * Close the target file for reading. * - * @param checksum Checksum of the file contenets + * @param checksum Checksum of the file contents * @throws IOException If an error occurs closing the file. */ void closeOutputFile(Checksum checksum) throws IOException { @@ -682,10 +688,7 @@ public class ReliableFile { */ int getSignatureSize() throws IOException { if (inputFile != null) { - CacheInfo info; - synchronized (cacheFiles) { - info = (CacheInfo) cacheFiles.get(inputFile); - } + CacheInfo info = (CacheInfo) cacheFiles.get(inputFile); if (info != null) { switch (info.filetype) { case FILETYPE_VALID : |