Skip to content

Commit

Permalink
Fix unmodifable Set Exception in generating preview
Browse files Browse the repository at this point in the history
Add hint in javadoc

Fixes #9947
Fixes JabRef/jabref-issue-melting-pot#183
  • Loading branch information
Siedlerchr committed May 24, 2023
1 parent ce2bd7b commit 192dffb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue in the preferences where custom columns could be added to the entry table with no qualifier. [#9913](https://github.com/JabRef/jabref/issues/9913)
- We fixed an issue where the encoding header in a bib file was not respected when the file contained a BOM (Byte Order Mark). [#9926](https://github.com/JabRef/jabref/issues/9926)
- We fixed an issue where cli help output for import and export format was inconsistent. [koppor#429](https://github.com/koppor/jabref/issues/429)
- We fixed an issue where no preview could be generated for some entry types and led to an exception [#9947](https://github.com/JabRef/jabref/issues/9947)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
Expand Down Expand Up @@ -147,7 +148,7 @@ private CSLItemData bibEntryToCSLItemData(BibEntry originalBibEntry, BibDatabase
}
}

Set<Field> fields = entryType.map(BibEntryType::getAllFields).orElse(bibEntry.getFields());
Set<Field> fields = new LinkedHashSet<>(entryType.map(BibEntryType::getAllFields).orElse(bibEntry.getFields()));
fields.addAll(bibEntry.getFields());
for (Field key : fields) {
bibEntry.getResolvedFieldOrAlias(key, bibDatabaseContext.getDatabase())
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public Optional<String> getResolvedFieldOrAliasLatexFree(Field field, BibDatabas
}

private Optional<String> genericGetResolvedFieldOrAlias(Field field, BibDatabase database, BiFunction<BibEntry, Field, Optional<String>> getFieldOrAlias) {
if (InternalField.TYPE_HEADER == field || InternalField.OBSOLETE_TYPE_HEADER == field) {
if ((InternalField.TYPE_HEADER == field) || (InternalField.OBSOLETE_TYPE_HEADER == field)) {
return Optional.of(type.get().getDisplayName());
}

Expand Down Expand Up @@ -434,7 +434,7 @@ public Optional<FieldChange> setType(EntryType newType, EntriesEventSource event
}

/**
* Returns a set containing the names of all fields that are set for this particular entry.
* Returns an {@link Collections#unmodifiableSet(Set)} containing the names of all fields that are set for this particular entry.
*
* @return a set of existing field names
*/
Expand Down Expand Up @@ -489,7 +489,7 @@ private Optional<String> genericGetFieldOrAlias(Field field, BiFunction<BibEntry
return date.map(Date::getNormalized);
}

if (StandardField.YEAR == field || StandardField.MONTH == field || StandardField.DAY == field) {
if ((StandardField.YEAR == field) || (StandardField.MONTH == field) || (StandardField.DAY == field)) {
Optional<String> date = getFieldValue.apply(this, StandardField.DATE);
if (date.isEmpty()) {
return Optional.empty();
Expand Down

0 comments on commit 192dffb

Please sign in to comment.