Skip to content

Commit

Permalink
LPS-55159 No more weird file reading failures and retries
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyangzhou authored and brianchandotcom committed May 4, 2015
1 parent 72f4ad1 commit d5b773b
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,15 @@ private static FileLock _lockFile() {
}

private static ProjectData _readProjectData(File dataFile) {
for (int i = 0; i < _RETRY_TIMES; i++) {
try (FileInputStream fileInputStream = new FileInputStream(
dataFile);
ObjectInputStream objectInputStream = new ObjectInputStream(
fileInputStream)) {
try (FileInputStream fileInputStream = new FileInputStream(dataFile);
ObjectInputStream objectInputStream = new ObjectInputStream(
fileInputStream)) {

return (ProjectData)objectInputStream.readObject();
}
catch (IOException ioe) {
continue;
}
catch (Exception e) {
throw new RuntimeException(e);
}
return (ProjectData)objectInputStream.readObject();
}
catch (Exception e) {
throw new RuntimeException(e);
}

throw new IllegalStateException(
"Unable to load project data after retry for " + _RETRY_TIMES +
" times");
}

private static void _unlockFile(FileLock fileLock) {
Expand Down Expand Up @@ -127,8 +117,6 @@ private static void _writeProjectData(
}
}

private static final int _RETRY_TIMES = 10;

private static final ProjectData _projectData = new ProjectData();

}

0 comments on commit d5b773b

Please sign in to comment.