[Joafip-svn] SF.net SVN: joafip:[3119] trunk/joafip-file/src/main/java/net/sf/joafip/ file/service
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2012-09-26 01:32:18
|
Revision: 3119
http://joafip.svn.sourceforge.net/joafip/?rev=3119&view=rev
Author: luc_peuvrier
Date: 2012-09-26 01:32:11 +0000 (Wed, 26 Sep 2012)
Log Message:
-----------
warning correction
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/HelperFileUtil.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/HelperFileUtil.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/HelperFileUtil.java 2012-09-25 03:12:29 UTC (rev 3118)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/HelperFileUtil.java 2012-09-26 01:32:11 UTC (rev 3119)
@@ -296,50 +296,59 @@
try {
fis2 = new FileInputStream(file2);
} catch (FileNotFoundException exception) {
+ try {
+ fis1.close();
+ } catch (Exception exception2) {
+ LOGGER.error("closing file1 after file2 opening error",
+ exception2);
+ }
final String message = FAILED_CHECK_FILE_DIFFERENCE + file1 + COMMA
+ file2;
throw FileIOException.create(message, file2, exception);
}
- int value1;
- int value2;
- long index = -1;
- do {
- index++;
+ try {
+ int value1;
+ int value2;
+ long index = -1;
+ do {
+ index++;
+ try {
+ value1 = fis1.read();
+ } catch (IOException exception) {
+ throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE
+ + file1 + COMMA + file2 + ": read " + file1
+ + FAILED, file1, exception);
+ }
+ try {
+ value2 = fis2.read();
+ } catch (IOException exception) {
+ throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE
+ + file1 + COMMA + file2 + ": read " + file2
+ + FAILED, file2, exception);
+ }
+ diff = value1 != value2;
+ if (diff) {
+ LOGGER.warn("difference at position: " + index
+ + " values: " + value1 + " " + value2);
+ }
+ return diff;
+ } while (!diff && value1 != -1 && value2 != -1);
+ } finally {
try {
- value1 = fis1.read();
+ fis1.close();
} catch (IOException exception) {
throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE
- + file1 + COMMA + file2 + ": read " + file1 + FAILED,
+ + file1 + COMMA + file2 + ": close " + file1 + FAILED,
file1, exception);
}
try {
- value2 = fis2.read();
+ fis2.close();
} catch (IOException exception) {
throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE
- + file1 + COMMA + file2 + ": read " + file2 + FAILED,
+ + file1 + COMMA + file2 + ": close " + file2 + FAILED,
file2, exception);
}
- diff = value1 != value2;
- } while (!diff && value1 != -1 && value2 != -1);
- try {
- fis1.close();
- } catch (IOException exception) {
- throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE + file1
- + COMMA + file2 + ": close " + file1 + FAILED, file1,
- exception);
}
- try {
- fis2.close();
- } catch (IOException exception) {
- throw FileIOException.create(FAILED_CHECK_FILE_DIFFERENCE + file1
- + COMMA + file2 + ": close " + file2 + FAILED, file2,
- exception);
- }
- if (diff) {
- LOGGER.warn("difference at position: " + index + " values: "
- + value1 + " " + value2);
- }
- return diff;
}
}
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2012-09-25 03:12:29 UTC (rev 3118)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2012-09-26 01:32:11 UTC (rev 3119)
@@ -209,6 +209,13 @@
try {
fos = new FileOutputStream(destinationFile);
} catch (FileNotFoundException exception) {
+ try {
+ fis.close();
+ } catch (Exception exception2) {
+ logger.error(
+ "error closing input file after openning output file failed",
+ exception2);
+ }
throw FileIOException.create(FAILED_OPEN + destinationFile,
destinationFile, exception);
}
@@ -228,6 +235,7 @@
}
} catch (Exception exception) {// NOPMD
// ignore error
+ logger.error("closing input file", exception);
}
try {
if (fos != null) {
@@ -235,6 +243,7 @@
}
} catch (Exception exception) {// NOPMD
// ignore error
+ logger.error("closing output file", exception);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|