private DirectoryMetadata getMetadataForPath(final String requestPath)
throws ClassNotFoundException, IOException {
- final String urlString = globalPrefix +
- Utils.urlEncode(requestPath) +
- "/.thumbnails/metadata_6.dat";
+ final String urlString = globalPrefix + Utils.urlEncode(requestPath) +"/.thumbnails/metadata_6.dat";
- IOException exception = null;
-
- for (int i = 0; i < METADATA_LOAD_TRY_COUNT; i++)
+ for (int i = 0; true; i++)
try {
-
- final BufferedInputStream in = new BufferedInputStream(new URL(
- urlString).openStream());
-
- final ObjectInputStream oin = new ObjectInputStream(in);
- final DirectoryMetadata directory = (DirectoryMetadata) oin
- .readObject();
- in.close();
-
- return directory;
+ return attemptDirectoryMetadataDownload(urlString);
} catch (final IOException e) {
- exception = e;
+ if (i > METADATA_LOAD_TRY_COUNT) throw e;
}
+ }
+
+ private DirectoryMetadata attemptDirectoryMetadataDownload(String urlString) throws IOException, ClassNotFoundException {
+ final BufferedInputStream inputStream = new BufferedInputStream(new URL(
+ urlString).openStream());
+
+ final ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
+ final DirectoryMetadata directory = (DirectoryMetadata) objectInputStream
+ .readObject();
+ inputStream.close();
- throw exception;
+ return directory;
}
@Override