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

Error while parsing changed file #8895

Closed
2 tasks done
MHFrey opened this issue Jun 10, 2022 · 3 comments · Fixed by #8947
Closed
2 tasks done

Error while parsing changed file #8895

MHFrey opened this issue Jun 10, 2022 · 3 comments · Fixed by #8947
Labels
import unicode unicode related issues

Comments

@MHFrey
Copy link

MHFrey commented Jun 10, 2022

JabRef version

5.6 (latest release)

Operating system

Windows

Details on version and operating system

WIndows 10 Pro 21H2

Checked with the latest development build

  • I made a backup of my libraries before testing the latest development version.
  • I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

  1. Open library
  2. Save library
  3. Check Log
  4. Close and try to reopen library
  5. Error opening file '(filename unknown)'. Input lentgh = 1

Appendix

...

Log File
Error when Saving============================================
Trust store path: C:\Users\frey\AppData\Local\org.jabref\ssl\truststore.jks
Not updating theme because it hasn't changed
Theme set to Theme{type=DEFAULT, name=''} with base css StyleSheet{jrt:/org.jabref/org/jabref/gui/Base.css}
Index path for C:\Users\frey\Documents\My_Documents\Papers\JabRef\MHF.bib is C:\Users\frey\AppData\Local\org.jabref\JabRef\lucene91
Saving library...
Library saved
Error while parsing changed file.
java.nio.charset.MalformedInputException: Input length = 1
	at java.base/java.nio.charset.CoderResult.throwException(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.read(Unknown Source)
	at java.base/java.io.InputStreamReader.read(Unknown Source)
	at java.base/java.io.BufferedReader.fill(Unknown Source)
	at java.base/java.io.BufferedReader.read(Unknown Source)
	at java.base/java.io.FilterReader.read(Unknown Source)
	at java.base/java.io.PushbackReader.read(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.read(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.consumeUncritically(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.parseFileContent(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.parse(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexImporter.importDatabase(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexImporter.importDatabase(Unknown Source)
	at [email protected]/org.jabref.logic.importer.OpenDatabase.loadDatabase(Unknown Source)
	at [email protected]/org.jabref.gui.collab.ChangeScanner.scanForChanges(Unknown Source)
	at [email protected]/org.jabref.gui.util.BackgroundTask$1.call(Unknown Source)
	at [email protected]/org.jabref.gui.util.DefaultTaskExecutor$1.call(Unknown Source)
	at [email protected]/javafx.concurrent.Task$TaskCallable.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Error when Reopening=================================================
Trust store path: C:\Users\frey\AppData\Local\org.jabref\ssl\truststore.jks
Not updating theme because it hasn't changed
Theme set to Theme{type=DEFAULT, name=''} with base css StyleSheet{jrt:/org.jabref/org/jabref/gui/Base.css}
Error opening file 'C:\Users\frey\Documents\My_Documents\Papers\JabRef\MHF.bib'
java.nio.charset.MalformedInputException: Input length = 1
	at java.base/java.nio.charset.CoderResult.throwException(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.read(Unknown Source)
	at java.base/java.io.InputStreamReader.read(Unknown Source)
	at java.base/java.io.BufferedReader.fill(Unknown Source)
	at java.base/java.io.BufferedReader.read(Unknown Source)
	at java.base/java.io.FilterReader.read(Unknown Source)
	at java.base/java.io.PushbackReader.read(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.read(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.consumeUncritically(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.parseFileContent(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexParser.parse(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexImporter.importDatabase(Unknown Source)
	at [email protected]/org.jabref.logic.importer.fileformat.BibtexImporter.importDatabase(Unknown Source)
	at [email protected]/org.jabref.logic.importer.OpenDatabase.loadDatabase(Unknown Source)
	at [email protected]/org.jabref.gui.JabRefGUI.openLastEditedDatabases(Unknown Source)
	at [email protected]/org.jabref.gui.JabRefGUI.openDatabases(Unknown Source)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
	at [email protected]/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at [email protected]/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

@Siedlerchr
Copy link
Member

Thanks for the report. The error message looks similar to #8870
There seems to be something wrong with detecting the char set.

Can you open the bib file in an application like Notepad++ and check the encoding? JabRef always tries to Write and Read in UTF-8.
And second, would it be possible for you to make the bib file available to us? (You can send it privately to [email protected]

@Siedlerchr
Copy link
Member

Siedlerchr commented Jun 11, 2022

Thanks a lot for the files. I could reproduce this on my machine as well.
The problem lies in our approach to automatically identify the charset. Later on, we try to check if the first line contains the encoding comment. However, if the wrong charset previously was identified as e.g. UTF8, but it is like UTF16BE the String comparsion fails, because java compares the chars on a byte level and those obviously don't match in different charsets.

@ThiloteE
Copy link
Member

ThiloteE commented Jun 14, 2022

Cause could maybe be: koppor#75 (comment)
Refs #8506

Siedlerchr added a commit that referenced this issue Jul 3, 2022
Siedlerchr added a commit that referenced this issue Jul 11, 2022
* Fix charset detection with utf16 and others

Fixes #8895
Fixes #8870

* checkstyöe

* Fix typo in method names

* change newlines

* get bytes

* Set newline character to LF

* Revert "get bytes"

This reverts commit 1082f8a.

* progress

* switch line sep to LF

* Please work

* Try jitpack

* Add manual build of icu4j

* Check if we have ascii in the list of charsets

* fix checkstyle

* Update external-libraries.md

* Enocde with UTF-16BE

* Fix umlaut

* Hack to get test running

* Also compare meta data

* Add enforced ignorance of malformed characters

Source: http://biercoff.com/malformedinputexception-input-length-1-exception-solution-for-scala-and-java/

Co-authored-by: Christoph <[email protected]>

* checkstyle

* IntelliJ now also renders the file correctly

* Add test

Additionally

- Replace unknown characters
- Remove obsolete wrapping classes in test

* Refine CHANGELOG.md

* Remove non-working jpackage reference

Co-authored-by: Oliver Kopp <[email protected]>
Co-authored-by: Houssem Nasri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import unicode unicode related issues
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants