diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java index 009573c494..cd924839e3 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java @@ -18,17 +18,18 @@ *******************************************************************************/ package org.apache.ofbiz.accounting.thirdparty.gosoftware; -import java.io.DataInputStream; import java.io.IOException; import java.io.PrintStream; +import java.io.DataInputStream; import java.net.Socket; import javax.xml.parsers.ParserConfigurationException; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.GeneralException; -import org.apache.ofbiz.base.util.ObjectType; import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.base.util.ObjectType; +import org.apache.ofbiz.base.util.GeneralException; +import org.apache.ofbiz.base.util.Debug; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; @@ -188,7 +189,6 @@ public class PcChargeApi { Socket sock = new Socket(host, port); PrintStream ps = new PrintStream(sock.getOutputStream()); DataInputStream dis = new DataInputStream(sock.getInputStream()); - sock.close(); ps.print(this.toString()); ps.flush(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java index 8c2bb767b5..1ca5942cc2 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java @@ -585,7 +585,6 @@ public class PdfSurveyServices { ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((c = fis.read()) != -1) baos.write(c); inputByteBuffer = ByteBuffer.wrap(baos.toByteArray()); - fis.close(); } catch (FileNotFoundException e) { throw(new GeneralException(e.getMessage())); } catch (IOException e) { diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java b/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java index f666f8b690..7c1f88cf11 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java @@ -31,6 +31,16 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import ezvcard.Ezvcard; +import ezvcard.io.text.VCardReader; +import ezvcard.parameter.AddressType; +import ezvcard.parameter.TelephoneType; +import ezvcard.parameter.EmailType; +import ezvcard.property.Address; +import ezvcard.property.Email; +import ezvcard.property.FormattedName; +import ezvcard.property.StructuredName; +import ezvcard.property.Telephone; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; import org.apache.ofbiz.base.util.StringUtil; @@ -52,17 +62,6 @@ import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceUtil; -import ezvcard.Ezvcard; -import ezvcard.io.text.VCardReader; -import ezvcard.parameter.AddressType; -import ezvcard.parameter.EmailType; -import ezvcard.parameter.TelephoneType; -import ezvcard.property.Address; -import ezvcard.property.Email; -import ezvcard.property.FormattedName; -import ezvcard.property.StructuredName; -import ezvcard.property.Telephone; - public class VCard { public static final String module = VCard.class.getName(); public static final String resourceError = "MarketingUiLabels"; @@ -72,9 +71,8 @@ public class VCard { * @param dctx * @param context * @return - * @throws IOException */ - public static Map importVCard(DispatchContext dctx, Map context) throws IOException { + public static Map importVCard(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); Locale locale = (Locale) context.get("locale"); @@ -86,10 +84,10 @@ public class VCard { boolean isGroup = false; List> partiesCreated = new ArrayList>(); List> partiesExist = new ArrayList>(); - String partyName = ""; // TODO this is not used yet - VCardReader vCardReader = new VCardReader(in); + String partyName = ""; try { + VCardReader vCardReader = new VCardReader(in); ezvcard.VCard vcard = null; while ((vcard = vCardReader.readNext()) != null) { @@ -164,7 +162,6 @@ public class VCard { } else { //TODO change uncorrect labellisation String emailFormatErrMsg = UtilProperties.getMessage(resourceError, "SfaImportVCardEmailFormatError", locale); - vCardReader.close(); return ServiceUtil.returnError(structuredName.getGiven() + " " + structuredName.getFamily() + " has " + emailFormatErrMsg); } } @@ -218,13 +215,12 @@ public class VCard { resp = dispatcher.runSync("createPartyIdentification", createPartyIdentificationMap); } } + vCardReader.close(); } catch (IOException | GenericEntityException | GenericServiceException e) { Debug.logError(e, module); - vCardReader.close(); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "SfaImportVCardError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } - vCardReader.close(); result.put("partiesCreated", partiesCreated); result.put("partiesExist", partiesExist); return result; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java index 3b6115dfaf..6e9be0c43b 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java @@ -108,7 +108,6 @@ public final class Debug { Formatter formatter = new Formatter(sb); formatter.format(msg, params); msg = sb.toString(); - formatter.close(); } // log diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java index 55a56646c6..9f76b9c2df 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java @@ -1883,7 +1883,6 @@ public class DatabaseUtil { try { stmt = connection.createStatement(); stmt.executeUpdate(sql2); - stmt.close(); } catch (SQLException e2) { // if this also fails report original error, not this error... return "SQL Exception while executing the following:\n" + sql + "\nError was: " + e.toString();