Re: RFR: 8268222: javax/xml/jaxp/unittest/transform/Bug6216226Test.java failed, cannot delete file
On Fri, 4 Jun 2021 08:50:09 GMT, Daniel Fuchs wrote: >> Revert changes in StreamResult.java made through >> https://github.com/openjdk/jdk/pull/4318 since it was creating a file stream >> on behalf of the Transformer, which resulted in a leaking file handle >> because the Transformer would only close files it opened. >> >> This change instead replace the problematic file-uri-url-file conversion >> code with nio Paths. While we generally don't make such changes if it's not >> necessary as Apache still supports older versions of the JDK, we are okay >> with a code level 8. > > src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java > line 52: > >> 50: import java.net.UnknownServiceException; >> 51: import java.nio.file.Path; >> 52: import java.nio.file.Paths; > > Nit: you should not need to use Paths. `Paths.get(URI)` just calls > `Path.of(URI)` Right, but Path.of was introduced in JDK 11. I hope to avoid more advanced features if we can keep the code level at 8. There had been previous cases where we stayed at 8. So far, only a few classes need to be modified for java.xml to compile at 8. - PR: https://git.openjdk.java.net/jdk/pull/4353
Re: RFR: 8268222: javax/xml/jaxp/unittest/transform/Bug6216226Test.java failed, cannot delete file
On Fri, 4 Jun 2021 05:14:13 GMT, Joe Wang wrote: > Revert changes in StreamResult.java made through > https://github.com/openjdk/jdk/pull/4318 since it was creating a file stream > on behalf of the Transformer, which resulted in a leaking file handle because > the Transformer would only close files it opened. > > This change instead replace the problematic file-uri-url-file conversion code > with nio Paths. While we generally don't make such changes if it's not > necessary as Apache still supports older versions of the JDK, we are okay > with a code level 8. Using `Path` instead of trying to handcraft a URL is a much better alternative. src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java line 52: > 50: import java.net.UnknownServiceException; > 51: import java.nio.file.Path; > 52: import java.nio.file.Paths; Nit: you should not need to use Paths. `Paths.get(URI)` just calls `Path.of(URI)` src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java line 516: > 514: if (systemId.startsWith("file:")) { > 515: try{ > 516: Path p = Paths.get(new URI(systemId)); I suggest using `Path.of(new URI(systemId));` here. - Marked as reviewed by dfuchs (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4353
RFR: 8268222: javax/xml/jaxp/unittest/transform/Bug6216226Test.java failed, cannot delete file
Revert changes in StreamResult.java made through https://github.com/openjdk/jdk/pull/4318 since it was creating a file stream on behalf of the Transformer, which resulted in a leaking file handle because the Transformer would only close files it opened. This change instead replace the problematic file-uri-url-file conversion code with nio Paths. While we generally don't make such changes if it's not necessary as Apache still supports older versions of the JDK, we are okay with a code level 8. - Commit messages: - 8268222: javax/xml/jaxp/unittest/transform/Bug6216226Test.java failed, cannot delete file Changes: https://git.openjdk.java.net/jdk/pull/4353/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk=4353=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8268222 Stats: 37 lines in 2 files changed: 2 ins; 24 del; 11 mod Patch: https://git.openjdk.java.net/jdk/pull/4353.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4353/head:pull/4353 PR: https://git.openjdk.java.net/jdk/pull/4353