@@ -58,7 +58,7 @@ public class FileExtractor implements OutputStreamProvider {
5858 /**
5959 * An interface object to provide the extraction process with a command-state pattern.
6060 */
61- protected ExtractionListener extractionListener ;
61+ protected FileExtractionListener fileExtractionListener ;
6262
6363 /**
6464 * An absolute path for the destination filesystem of the extraction process.
@@ -107,7 +107,6 @@ public void extract() throws IOException, FileNotFoundException {
107107 * unlike the unbuffered streams, which polls byte streams from an online
108108 * pipe, and allocate memory according to the active bytes manipulated
109109 * by the pipeline. */
110- fileLocator .validateFileLocalization ();
111110 InputStream fileStream = fileLocator .getFileInputStream ();
112111
113112 /* Extracts the shipped native files */
@@ -118,25 +117,27 @@ public void extract() throws IOException, FileNotFoundException {
118117 /* use the bytes as the buffer length to write valid data */
119118 fileOutputStream .write (buffer , 0 , bytes );
120119 }
121- if (extractionListener != null ) {
122- extractionListener .onExtractionCompleted (this );
120+ if (fileExtractionListener != null ) {
121+ fileExtractionListener .onExtractionCompleted (this );
123122 }
124123 } catch (Exception e ) {
125- if (extractionListener != null ) {
126- extractionListener .onExtractionFailure (this , e );
124+ if (fileExtractionListener != null ) {
125+ fileExtractionListener .onExtractionFailure (this , e );
127126 }
128127 // release the native resources anyway!
129128 } finally {
130- if (extractionListener != null ) {
131- extractionListener .onExtractionFinalization (this , fileLocator );
129+ if (fileExtractionListener != null ) {
130+ fileExtractionListener .onExtractionFinalization (this , fileLocator );
132131 }
133132 }
134133 }
135134
136135 @ Override
137136 public void close () throws IOException {
138- fileOutputStream .close ();
139- fileOutputStream = null ;
137+ if (fileOutputStream != null ) {
138+ fileOutputStream .close ();
139+ fileOutputStream = null ;
140+ }
140141 }
141142
142143 @ Override
@@ -150,13 +151,13 @@ public InputStreamProvider getFileLocator() {
150151 }
151152
152153 /**
153- * Sets the extraction listener action to dispatch the {@link ExtractionListener #onExtractionCompleted(FileExtractor)}
154+ * Sets the extraction listener action to dispatch the {@link FileExtractionListener #onExtractionCompleted(FileExtractor)}
154155 * when the extraction task is completed.
155156 *
156- * @param extractionListener an implementation object of the extraction listener dispatched when the
157+ * @param fileExtractionListener an implementation object of the extraction listener dispatched when the
157158 * extraction is completed
158159 */
159- public void setExtractionListener (ExtractionListener extractionListener ) {
160- this .extractionListener = extractionListener ;
160+ public void setExtractionListener (FileExtractionListener fileExtractionListener ) {
161+ this .fileExtractionListener = fileExtractionListener ;
161162 }
162163}
0 commit comments