You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jan Burkhardt (Jira)" <ji...@apache.org> on 2025/08/21 08:48:00 UTC
[jira] [Commented] (CSV-318) CSVPrinter.printRecord(Stream) hangs if given a parallel stream
[ https://issues.apache.org/jira/browse/CSV-318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18015354#comment-18015354 ]
Jan Burkhardt commented on CSV-318:
-----------------------------------
For some reason I am lacking rights to create tickets myself so I try to get attention this way:
I opened a related PR to get rid of the introduced spotbugs dependency
[https://github.com/apache/commons-csv/pull/564]
> 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)