[
https://issues.apache.org/jira/browse/GROOVY-12295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107762#comment-18107762
]
ASF GitHub Bot commented on GROOVY-12295:
-----------------------------------------
testlens-app[bot] commented on PR #2831:
URL: https://github.com/apache/groovy/pull/2831#issuecomment-5406722061
## ✅ All tests passed ✅
🏷️ Commit: 857d0fdb55f14e043069273a3ea99c3421061d21
▶️ Tests: 113147 executed
⚪️ Checks: 31/31 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> CsvSlurper: parsing fails with useHeader=false despite documented
> auto-generated column names
> ---------------------------------------------------------------------------------------------
>
> Key: GROOVY-12295
> URL: https://issues.apache.org/jira/browse/GROOVY-12295
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> The javadoc for {{CsvSlurper#parse(Reader)}} states:
> {quote}When {{useHeader}} is false, maps are keyed by auto-generated column
> names.{quote}
> No such auto-generation exists. With {{useHeader=false}}, any non-empty input
> fails:
> {code:groovy}
> new groovy.csv.CsvSlurper().setUseHeader(false).parseText('1,2\n3,4')
> {code}
> throws:
> {noformat}
> groovy.csv.CsvRuntimeException
> Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException:
> Cannot construct instance of `java.util.LinkedHashMap` (although at least one
> Creator exists):
> no String-argument constructor/factory method to deserialize from String
> value ('1')
> {noformat}
> *Cause:* {{buildSchema()}} with {{useHeader=false}} produces an empty
> {{CsvSchema}} with no columns. jackson-dataformat-csv then presents each row
> as an array of strings rather than an object, which cannot bind to {{Map}},
> so the entire untyped {{useHeader=false}} path is broken, not just an edge
> case.
> *Possible resolutions:*
> # Implement the documented behavior: peek at the first row to determine the
> column count and generate names (e.g. {{column1}}..{{columnN}}), building the
> schema from those.
> # Return a list of string lists (one per row) when {{useHeader}} is false,
> and adjust the docs accordingly.
> # Keep current behavior but fix the javadoc and fail fast with a clear error
> message.
> Since the module is still {{@Incubating}}, any of these can be adopted
> without compatibility concerns.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)