Skip to content

Fixed the issue where import hangs for ris files with "ER - " failed #7737 #7755

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

Closed
wants to merge 4 commits into from

Conversation

Noname690
Copy link
Contributor

@Noname690 Noname690 commented May 19, 2021

fixed the issue where import hangs for ris files with "ER - " failed #7737

fixes #7737

The test file in issue#7737 like error1.ris and error2.ris have a same problem that the last line "ER - " with no line break(/n) , so it isn't eliminate by split("ER -.\n") , use split("ER -.*(\n)*") can solve this problem

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not created an issue at https://github.com/JabRef/user-documentation/issues or, even better, submitted a pull request to the documentation repository.

@Siedlerchr
Copy link
Member

Can you please add/extend the unit tests for that case?

@Override
public ParserResult importDatabase(BufferedReader reader) throws IOException {
List<BibEntry> bibitems = new ArrayList<>();

// use optional here, so that no exception will be thrown if the file is empty
String linesAsString = reader.lines().reduce((line, nextline) -> line + "\n" + nextline).orElse("");

String[] entries = linesAsString.replace("\u2013", "-").replace("\u2014", "--").replace("\u2015", "--")
.split("ER -.*\\n");
entries = linesAsString.replace("\u2013", "-").replace("\u2014", "--").replace("\u2015", "--")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what I meant with tests. Have a look at the RISImporterTestFiles class.
It searches for test files in /src/test/resources/org/jabref/logic/importer/fileformat that ar named with RISImporterTest....ris
and have a corresponding .bib file with the same name

So you create a minimal RIS file with the ER at the end and a corresponding bib files
This way you can test that the import succeeds without errors

@Siedlerchr Siedlerchr added the status: changes required Pull requests that are not yet complete label May 20, 2021
@Siedlerchr Siedlerchr mentioned this pull request May 29, 2021
5 tasks
@Siedlerchr
Copy link
Member

I did a follow up PR with the changes

@Siedlerchr Siedlerchr closed this May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: changes required Pull requests that are not yet complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import hangs for ris files with "ER - " field, also other bib files common from journal web sites
2 participants