You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2021/12/29 08:04:59 UTC

[ofbiz-framework] 02/02: Improved: suppresses 2 warnings related to deprecated CSVFormat.DEFAULT.withHeader()

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit c4088961d32fde4e07b0329b349f9a6006f67f08
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Sun Dec 26 19:20:43 2021 +0100

    Improved: suppresses 2 warnings related to deprecated CSVFormat.DEFAULT.withHeader()
    
    This was not done correctly last time (previous commit e4d4329)
---
 .../java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java     | 4 +++-
 .../src/main/java/org/apache/ofbiz/party/party/PartyServices.java     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
index 3b1da0c..4cdf7d1 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
@@ -37,6 +37,7 @@ import java.util.Map.Entry;
 
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVFormat.Builder;
 import org.apache.commons.csv.CSVRecord;
 import org.apache.ofbiz.accounting.payment.PaymentGatewayServices;
 import org.apache.ofbiz.accounting.payment.PaymentWorker;
@@ -3552,7 +3553,8 @@ public class InvoiceServices {
         String organizationPartyId = (String) context.get("organizationPartyId");
         String encoding = System.getProperty("file.encoding");
         String csvString = Charset.forName(encoding).decode(fileBytes).toString();
-        CSVFormat fmt = CSVFormat.DEFAULT;
+        Builder csvFormatBuilder = Builder.create().setHeader();
+        CSVFormat fmt = csvFormatBuilder.build();
         List<String> errMsgs = new LinkedList<>();
         List<String> newErrMsgs;
         String lastInvoiceId = null;
diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
index 7bd0079..3022f47 100644
--- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
+++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
@@ -34,6 +34,7 @@ import java.util.Locale;
 import java.util.Map;
 
 import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVFormat.Builder;
 import org.apache.commons.csv.CSVRecord;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.UtilDateTime;
@@ -2326,7 +2327,8 @@ public class PartyServices {
         ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile");
         String encoding = System.getProperty("file.encoding");
         String csvString = Charset.forName(encoding).decode(fileBytes).toString();
-        CSVFormat fmt = CSVFormat.DEFAULT;
+        Builder csvFormatBuilder = Builder.create().setHeader();
+        CSVFormat fmt = csvFormatBuilder.build();
         List<String> errMsgs = new LinkedList<>();
         List<String> newErrMsgs = new LinkedList<>();
         String lastPartyId = null;        // last partyId read from the csv file