Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible race condition #424

Closed
jshowel opened this issue Nov 17, 2020 · 1 comment
Closed

Possible race condition #424

jshowel opened this issue Nov 17, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@jshowel
Copy link

jshowel commented Nov 17, 2020

I can't reliably reproduce the issue, but I am frequently getting this exception:

e: com.univocity.parsers.common.TextParsingException: java.lang.IllegalStateException - Error reading from input
Parser Configuration: CsvParserSettings:
	Auto configuration enabled=true
	Auto-closing enabled=true
	Autodetect column delimiter=true
	Autodetect quotes=true
	Column reordering enabled=true
	Delimiters for detection=[]
	Empty value=null
	Escape unquoted values=false
	Header extraction enabled=true
	Headers=null
	Ignore leading whitespaces=true
	Ignore leading whitespaces in quotes=false
	Ignore trailing whitespaces=true
	Ignore trailing whitespaces in quotes=false
	Input buffer size=1048576
	Input reading on separate thread=false
	Keep escape sequences=false
	Keep quotes=false
	Length of content displayed on error=-1
	Line separator detection enabled=true
	Maximum number of characters per column=-1
	Maximum number of columns=1000000
	Normalize escaped line separators=true
	Null value=null
	Number of records to read=all
	Processor=....UnivocityDelimitedInputStreamParser$$anon$1
	Restricting data in exceptions=false
	RowProcessor error handler=null
	Selected fields=none
	Skip bits as whitespace=true
	Skip empty lines=true
	Unescaped quote handling=nullFormat configuration:
	CsvFormat:
		Comment character=#
		Field delimiter=,
		Line separator (normalized)=\n
		Line separator sequence=\n
		Quote character="
		Quote escape character="
		Quote escape escape character=null
Internal state when error was thrown: line=0, column=0, record=0
	com.univocity.parsers.common.AbstractParser.handleException(AbstractParser.java:398)
	com.univocity.parsers.common.AbstractParser.beginParsing(AbstractParser.java:273)
	com.univocity.parsers.common.AbstractParser.parse(AbstractParser.java:128)
	com.univocity.parsers.common.AbstractParser.parse(AbstractParser.java:755)
	....UnivocityDelimitedInputStreamParser.parse(UnivocityDelimitedInputStreamParser.scala:82)
	....ParsingActor$$anonfun$receive$1.applyOrElse(ParsingActor.scala:78)
	akka.actor.Actor.aroundReceive(Actor.scala:539)
	akka.actor.Actor.aroundReceive$(Actor.scala:537)
	....ParsingActor.aroundReceive(ParsingActor.scala:55)
	akka.actor.ActorCell.receiveMessage(ActorCell.scala:614)
	akka.actor.ActorCell.invoke(ActorCell.scala:583)
	akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
	akka.dispatch.Mailbox.run(Mailbox.scala:229)
	akka.dispatch.Mailbox.exec(Mailbox.scala:241)
	akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

which is caused by:

Caused by: java.io.IOException: Stream closed

when I don't set the char encoding for a CsvParser. Only setting the encoding stopped this from occurring,

setReadInputOnSeparateThread(false)

did not, as was mentioned in #194 . My CsvParser setup looks like:

private def getParser(rowProcessor: RowProcessor): CsvParser = {
    val parserSettings = new CsvParserSettings()
    parserSettings.detectFormatAutomatically()
    parserSettings.setMaxColumns(maxColumns)
    parserSettings.setMaxCharsPerColumn(maxCharsPerColumn)
    parserSettings.setProcessor(rowProcessor)
    parserSettings.setReadInputOnSeparateThread(false)

    if (hasHeaders) {
      parserSettings.setHeaderExtractionEnabled(hasHeaders)
    }

    new CsvParser(parserSettings)
  }
val parser = getParser(rowProcessor)
parser.parse(inputStream)

I am using version 2.9.0, and am yet to see the issue when I set the encoding with parser.parse(inputStream, "UTF8"). Please let me know if any additional info would be helpful or perhaps was some configuration error I made.

jbax added a commit that referenced this issue Dec 15, 2020
@jbax
Copy link
Member

jbax commented Dec 15, 2020

Thank you for reporting the bug. I was able to reproduce it consistently and I find it incredible that no one has reported that one before you. Anyway, it's been fixed and I'm releasing a 2.9.1-SNAPSHOT build now which you can use to test. Thank you for using our parsers!

@jbax jbax closed this as completed Dec 15, 2020
@jbax jbax added the bug label Dec 15, 2020
@jbax jbax added this to the 2.9.1 milestone Dec 15, 2020
@jbax jbax self-assigned this Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants