File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
snaploader/src/main/java/electrostatic4j/snaploader/filesystem Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,13 @@ protected FileLocator() {
9292
9393
9494 @ Override
95- public void initialize (int size ) {
95+ public void initialize (int size ) throws IOException {
96+ // 1) sanity-check for double initializing
97+ // 2) sanity-check for pre-initialization using other routines
98+ // (e.g., classpath resources stream).
99+ if (this .fileInputStream != null ) {
100+ return ;
101+ }
96102 try {
97103 final ZipFile compression = compressionType .createNewCompressionObject (directory );
98104 final ZipEntry zipEntry = compression .getEntry (filePath );
@@ -106,7 +112,8 @@ public void initialize(int size) {
106112 this .fileInputStream = compression .getInputStream (zipEntry );
107113 SnapLoaderLogger .log (Level .INFO , getClass ().getName (), "initialize(int)" ,
108114 "File locator initialized with hash key #" + getHashKey ());
109- } catch (IOException e ) {
115+ } catch (Exception e ) {
116+ close ();
110117 throw new FilesystemResourceInitializationException (
111118 "Failed to initialize the file locator handler #" + getHashKey (), e );
112119 }
You can’t perform that action at this time.
0 commit comments