JDK-8285445 : cannot open file "NUL:"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version:
    7u343,8u333,11.0.1,11.0.15.1-oracle,11.0.15.1.1-oracle,11.0.16,13.0.12,15.0.8,17.0.3.1-oracle,17.0.4,18.0.1.1 7u343,8u333,11.0.1,11.0.15.1-oracle,11.0.15.1.1-oracle,11.0.16,13.0.12,15.0.8,17.0.3.1-oracle,17.0.4,18.0.1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: x86_64
  • Submitted: 2022-04-21
  • Updated: 2025-03-20
  • Resolved: 2022-06-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 15 JDK 17 JDK 18 JDK 19 JDK 7 JDK 8 Other
11.0.15.1-oracleFixed 13.0.12Fixed 15.0.8Fixed 17.0.3.1-oracleFixed 18.0.1.1Fixed 19 b20Fixed 7u343Fixed 8u333Fixed openjdk8u342,shenandoah8u342Fixed
Related Reports
CSR :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Sub Tasks
JDK-8285660 :  
Description
A DESCRIPTION OF THE PROBLEM :
with java update cpuapr2022 (8u331 11.0.15 and 18.0.1) undertow is broken for windows.

this code:
https://github.com/xnio/xnio/blob/3.x/api/src/main/java/org/xnio/channels/Channels.java#L1098
return new FileOutputStream("NUL:").getChannel();
 

is broken after this "improvement" (ticket JDK-8278356 is not public, why?)
https://github.com/openjdk/jdk/commit/395bb5b7f97f2549da89641257fe56712856b49d "8278356: Improve file creation"

2022-04-21 11:06:26,989 [XNIO-10 task-10] {} ERROR io.undertow.request.io UT005090: Unexpected failure
java.lang.NoClassDefFoundError: Could not initialize class org.xnio.channels.Channels

REGRESSION : Last worked in version 8

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run test program below.




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No Exception.

ACTUAL -
 Exception in thread "main" java.io.FileNotFoundException: Invalid file path

---------- BEGIN SOURCE ----------
import java.io.FileOutputStream;

public class NulFile {
    public static void main(String[] args) throws Exception {
        new FileOutputStream("NUL:");
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
set system property: -Djdk.io.File.enableADS=true

FREQUENCY : always



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk7u/pull/9 Date: 2022-06-29 15:03:30 +0000
29-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk8u-dev/pull/49 Date: 2022-04-28 21:22:10 +0000
28-04-2022

Fix request (8u) Clean backport, only the paths are changed. This is the fix for a regression introduced by the April CPU. The fix was verified by the updated test(see https://bugs.openjdk.java.net/browse/JDK-8285523). Review https://github.com/openjdk/jdk8u-dev/pull/49 CSR for 8-pool was approved: https://bugs.openjdk.java.net/browse/JDK-8285500
28-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk13u-dev/pull/346 Date: 2022-04-28 09:25:12 +0000
28-04-2022

Fix request (13u): clean backport. Will be targeted to July release. We should have it in 13u to align with 11 and 15 and later releases. The CSR is updated for 13-pool, too.
28-04-2022

Yes, thanks, I realised afterwards that they didn't ship JDK-8284562 & JDK-8285461 in the recent release when we did. It thus makes sense for Oracle to do a follow-up release and include other issues like this one, whereas it doesn't for OpenJDK.
28-04-2022

@andrew the 11.0.15.1-oracle(and probably others) includes fixes for other regressions: https://bugs.openjdk.java.net/issues/?jql=project%20%3D%20JDK%20AND%20fixVersion%20%3D%2011.0.15.1-oracle
26-04-2022

Sorry, but why is this being rushed into update releases? There is an option to turn off the feature already, and surely it is better to be more secure by default?
26-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk11u-dev/pull/1047 Date: 2022-04-25 22:14:09 +0000
25-04-2022

Fix request (11u) Clean backport. This is the fix for a regression introduced by the April CPU. The fix was verified by the updated test(see https://bugs.openjdk.java.net/browse/JDK-8285523). Review https://github.com/openjdk/jdk11u-dev/pull/1047 CSR for 11-pool was approved: https://bugs.openjdk.java.net/browse/JDK-8285500
25-04-2022

Fix request (15u) Clean backport. This is the fix for a regression introduced by the April CPU. The fix was verified by the updated test(see https://bugs.openjdk.java.net/browse/JDK-8285523). Review https://github.com/openjdk/jdk15u-dev/pull/198 CSR for 15-pool was approved: https://bugs.openjdk.java.net/browse/JDK-8285500
25-04-2022

@goetz Just FYI that the jdk17u-fix-yes was added before CSR approval.
25-04-2022

@mbaesken, I have started the process of the backports and requested an additional approvals in the CSR, also requested an update to the test which as of now cannot be used to verify the fix. It would be good not to duplicate the work.
25-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/358 Date: 2022-04-25 11:41:53 +0000
25-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk15u-dev/pull/198 Date: 2022-04-25 01:57:55 +0000
25-04-2022

jdk17 backport request I would like to have the patch in jdk17 as well, because the issue is present there too (after 8278356: Improve file creation). The patch applies cleanly. Seems there is also a CSR about this : https://bugs.openjdk.java.net/browse/JDK-8285500
25-04-2022

Working on the backport to the openjdk 8/11/15/17.
24-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk18u/pull/106 Date: 2022-04-23 16:08:10 +0000
23-04-2022

Changeset: 03cbb48e Author: Brian Burkhalter <bpb@openjdk.org> Date: 2022-04-23 15:51:04 +0000 URL: https://git.openjdk.java.net/jdk/commit/03cbb48e6a1d806f204a39bbdbb4bc9be9e57a41
23-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8373 Date: 2022-04-23 01:11:56 +0000
23-04-2022

A workaround is to replace "NUL:" with "NUL", or as the submitter has found, the system property to get older behavior. OutputStream.nullOutputStream(), added in Java 11, provides a output stream that discards all bytes. This is preferable to depending on the Windows specific NUL device.
22-04-2022

Hi, We observed that below program also failing with 'java.io.FileNotFoundException: Invalid file path' after upgrading to jdk8u331. import java.io.*; public class Test{ public static void main(String []args){ try { new FileOutputStream("NUL:"); System.out.println("Successful..."); }catch (FileNotFoundException e) { System.out.println(e); } } }
22-04-2022

The observations on Windows 10: JDK 8u331b05: Passed. JDK 8u331b06: Failed. FileNotFoundException thrown.
22-04-2022