return null;
}
}
protected Bucket loadBucket(File bucketFile) throws CacheLoaderException, InterruptedException {
Bucket bucket = null;
if (bucketFile.exists()) {
if (trace) {
log.trace("Found bucket file: '" + bucketFile + "'");
}
InputStream is = null;
try {
// It could happen that the output buffer might not have been
// flushed, so just in case, flush it to be able to read it.
fileSync.flush(bucketFile);
if (bucketFile.length() == 0) {
// short circuit
return null;
}
is = new FileInputStream(bucketFile);
bucket = (Bucket) objectFromInputStreamInReentrantMode(is);
} catch (InterruptedException ie) {
throw ie;
} catch (Exception e) {
log.errorReadingFromFile(bucketFile.getAbsoluteFile(), e);
throw new CacheLoaderException("Error while reading from file", e);
} finally {
safeClose(is);
}
}
if (bucket != null) {
bucket.setBucketId(bucketFile.getName());
}
return bucket;
}