[ 
https://issues.apache.org/jira/browse/CSV-318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved CSV-318.
---------------------------------
    Fix Version/s: 1.14.1
         Assignee: Gary D. Gregory
       Resolution: Fixed

[~tupari]

This issue is now fixed in git master and snapshot builds in 
https://repository.apache.org/content/repositories/snapshots/org/apache/commons/commons-csv/1.14.1-SNAPSHOT/

Please test your use case and report back here.

TY!


> CSVPrinter.printRecord(Stream) hangs if given a parallel stream
> ---------------------------------------------------------------
>
>                 Key: CSV-318
>                 URL: https://issues.apache.org/jira/browse/CSV-318
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Printer
>    Affects Versions: 1.14.0
>         Environment: {color:#000000}openjdk version "21.0.6" 
> 2025-01-21{color}{color:#000000} {color}
> {color:#000000}OpenJDK Runtime Environment (Red_Hat-21.0.6.0.7-1) (build 
> 21.0.6+7){color}{color:#000000} {color}
> {color:#000000}OpenJDK 64-Bit Server VM (Red_Hat-21.0.6.0.7-1) (build 
> 21.0.6+7, mixed mode, sharing){color}
> {color:#000000} {color}
>            Reporter: Joseph Shraibman
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 1.14.1
>
>
> {code:java}
> import org.apache.commons.csv.CSVFormat;
> import org.apache.commons.csv.CSVPrinter;
> import org.junit.jupiter.api.Test;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.PrintWriter;
> public class CommonsCsvTest {
>    @Test
>     void testWithParStream() throws IOException {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         try(CSVPrinter printer = new CSVPrinter(new PrintWriter(baos), 
> CSVFormat.DEFAULT)){
>             printer.printRecord(java.util.stream.Stream.of("col a", "col b", 
> "col c").parallel());
>         }
>     }
>     @Test
>     void testWithSeqStream() throws IOException {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         try(CSVPrinter printer = new CSVPrinter(new PrintWriter(baos), 
> CSVFormat.DEFAULT)){
>             printer.printRecord(java.util.stream.Stream.of("col a", "col b", 
> "col c"));
>         }
>     }
> }
>  {code}
> A simple workaround is to call sequential() on any passed in Stream.
> I don't know why this is happening.  At first I thought it must be a problem 
> with the underlying Stream implementation but this code has no problem:
>  
> {code:java}
> @Test
> void testJavaStream(){
>     java.util.stream.Stream.of("col a", "col b", "col c").parallel()
>             .forEachOrdered(System.out::println);
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to