Permalink
Browse files

Bug fix in FtpServices.java - close resources in finally block. Also …

…made logging more consistent.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1453793 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 317ac30 commit ef50a531e07db1979b6f0bd9a53c5a85e87ebd36 @adrian-crum adrian-crum committed Mar 7, 2013
Showing with 20 additions and 19 deletions.
  1. +20 −19 framework/common/src/org/ofbiz/common/FtpServices.java
@@ -105,21 +105,21 @@
ftp.logout();
}
} catch (IOException ioe) {
- Debug.logInfo(ioe, "[putFile] caught exception: " + ioe.getMessage(), module);
+ Debug.logWarning(ioe, "[putFile] caught exception: " + ioe.getMessage(), module);
errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
} finally {
- if (ftp.isConnected()) {
- try {
+ try {
+ if (ftp.isConnected()) {
ftp.disconnect();
- } catch (IOException dce) {
- Debug.logWarning(dce, "[putFile] Problem with FTP disconnect", module);
}
+ } catch (Exception e) {
+ Debug.logWarning(e, "[putFile] Problem with FTP disconnect: ", module);
+ }
+ try {
+ localFile.close();
+ } catch (Exception e) {
+ Debug.logWarning(e, "[putFile] Problem closing local file: ", module);
}
- }
- try {
- localFile.close();
- } catch (IOException ce) {
- Debug.logWarning(ce, "[putFile] Problem closing local file", module);
}
if (errorList.size() > 0) {
Debug.logError("[putFile] The following error(s) (" + errorList.size() + ") occurred: " + errorList, module);
@@ -168,20 +168,21 @@
ftp.logout();
}
} catch (IOException ioe) {
+ Debug.logWarning(ioe, "[getFile] caught exception: " + ioe.getMessage(), module);
errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
} finally {
- if (ftp.isConnected()) {
- try {
+ try {
+ if (ftp.isConnected()) {
ftp.disconnect();
- } catch (IOException dce) {
- Debug.logWarning(dce, "[getFile] Problem with FTP disconnect", module);
}
+ } catch (Exception e) {
+ Debug.logWarning(e, "[getFile] Problem with FTP disconnect: ", module);
+ }
+ try {
+ localFile.close();
+ } catch (Exception e) {
+ Debug.logWarning(e, "[getFile] Problem closing local file: ", module);
}
- }
- try {
- localFile.close();
- } catch (IOException ce) {
- Debug.logWarning(ce, "[getFile] Problem closing local file", module);
}
if (errorList.size() > 0) {
Debug.logError("[getFile] The following error(s) (" + errorList.size() + ") occurred: " + errorList, module);

0 comments on commit ef50a53

Please sign in to comment.