Switch to stream-based loading#11479
Conversation
| LOGGER.warn("Could not read terms from file {}", path); | ||
| return; | ||
| } | ||
| try (Stream<String> lines = Files.lines(path, StandardCharsets.UTF_8)) { |
There was a problem hiding this comment.
Files lines does not work with graal? Tbh this looks like a major drawback here.
There was a problem hiding this comment.
BufferedReader#lines seems to be somewhat of an equivalent here...
There was a problem hiding this comment.
In line 60, I use exactly this function.
This call is only a wrapper for the call if a user supplies a file!
GraalVM does not support .class.getResource( with hacks. See oracle/graal#7682 for a longer discussion. Especially oracle/graal#7682 (comment)
The reason NativeImageFileSystem behaves like JarFileSystem, not like UnixFileSystem, is that, unlike UnixFileSystem, you can't, for example, delete a file (resource) on both NativeImageFileSystem and JarFileSystem. The resources in NativeImageFileSystem are baked into the read-only section of the image heap
|
... and the tests fail... OMG
|
| LOGGER.error(""); | ||
| description = descriptionString; | ||
| location = resourceFileName; | ||
| try (InputStream inputStream = ProtectedTermsLoader.class.getResourceAsStream(Objects.requireNonNull(resourceFileName))) { |
There was a problem hiding this comment.
You need to use getClassLoader() first, don't ask me why but for getResourceAsStream it does not work otherwise
| LOGGER.error(""); | ||
| description = descriptionString; | ||
| location = resourceFileName; | ||
| try (InputStream inputStream = ProtectedTermsLoader.class.getResourceAsStream(Objects.requireNonNull(resourceFileName))) { |
There was a problem hiding this comment.
| try (InputStream inputStream = ProtectedTermsLoader.class.getResourceAsStream(Objects.requireNonNull(resourceFileName))) { | |
| try (InputStream inputStream = ProtectedTermsLoader.class.getClassLoader().getResourceAsStream(Objects.requireNonNull(resourceFileName))) { |
There was a problem hiding this comment.
But might not work at runtime
There was a problem hiding this comment.
I tried with ./gradlew run and then protected terms. Worked.
|
For full GraalVM, we would maybe to patch // try to find style in classpath
url = CSL.class.getResource(styleName);However, I added a workaround, because this branch is only taken if the provided String is not an XML file. |
|
Assuming that JavaFX can perfectly deal with URLs coming from the classpath, we have one class left to "really" change: org.jabref.logic.citationstyle.CitationStyle#discoverCitationStyles: Here, the list could be generated during compilation time |
|
|
||
| // No SystemId required, because no relative URLs need to be resolved | ||
| Source xsltSource = new StreamSource(xsltResource); | ||
| Source xsltSource = new StreamSource(xsltResource, MathMLParser.class.getResource(XSLT_FILE_PATH).toExternalForm()); |
There was a problem hiding this comment.
OK for a workaround. - Can we do add a fake path here? Maybe, #future work
|
Proposal: Get this in to see whether there are issues. As follow up the "difficult" conversions. |
|
Use the binary to test it! |
|
The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build. |
|
Tested. Protected terms works. Think, more users should test it and we can revert if needed ^^. |
* upstream/main: Fix NPE when saving preferences (JabRef#11509) Switch to stream-based loading (JabRef#11479) Save unlinked local files dialog prefs (JabRef#11493) Add minimal support for biblatex data annotations (JabRef#11506) Fix handling of relative-file storage and auto linking (JabRef#11492) New Crowdin updates (JabRef#11504) Add missing issue numbers CSL4LibreOffice - A [GSoC '24] (JabRef#11477) Bump src/main/resources/csl-styles from `b2be5ae` to `fd6cb3e` (JabRef#11501) Bump gittools/actions from 1.1.1 to 1.2.0 (JabRef#11500) Bump com.kohlschutter.junixsocket:junixsocket-core from 2.9.1 to 2.10.0 (JabRef#11498) Bump commons-logging:commons-logging from 1.3.2 to 1.3.3 (JabRef#11499) Bump org.jsoup:jsoup from 1.17.2 to 1.18.1 (JabRef#11497) Bump com.kohlschutter.junixsocket:junixsocket-mysql from 2.9.1 to 2.10.0 (JabRef#11496) Bump org.openrewrite.recipe:rewrite-recipe-bom from 2.14.0 to 2.15.0 (JabRef#11495) FAQ updates (JabRef#11486) Update Gradle Wrapper from 8.8 to 8.9. Fix Chocolate.bib (JabRef#11491) # Conflicts: # src/main/java/org/jabref/gui/openoffice/OOBibBase.java # src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java # src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java # src/main/java/org/jabref/gui/openoffice/StyleSelectDialogViewModel.java # src/main/java/org/jabref/preferences/JabRefPreferences.java
Uses
ProtectedTermsLoader.class.getResourceAsStreaminstead ofProtectedTermsLoader.class.getResource.Refs #11298 (comment)
Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if applicable)