ignore empty state files stored

This commit is contained in:
kimchy 2011-07-21 22:11:14 +03:00
parent ba137df093
commit d4d227ba6b
1 changed files with 11 additions and 2 deletions

View File

@ -384,7 +384,11 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
if (fileIndex >= index) {
// try and read the meta data
try {
readStartedShards(Streams.copyToByteArray(new FileInputStream(stateFile)));
byte[] data = Streams.copyToByteArray(new FileInputStream(stateFile));
if (data.length == 0) {
logger.debug("[findLatestState]: not data for [" + name + "], ignoring...");
}
readStartedShards(data);
index = fileIndex;
} catch (IOException e) {
logger.warn("[findLatestState]: Failed to read state from [" + name + "], ignoring...", e);
@ -409,7 +413,12 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
if (fileIndex >= index) {
// try and read the meta data
try {
readMetaState(Streams.copyToByteArray(new FileInputStream(stateFile)));
byte[] data = Streams.copyToByteArray(new FileInputStream(stateFile));
if (data.length == 0) {
logger.debug("[findLatestState]: not data for [" + name + "], ignoring...");
continue;
}
readMetaState(data);
index = fileIndex;
} catch (IOException e) {
logger.warn("[findLatestState]: Failed to read state from [" + name + "], ignoring...", e);