What does it mean when Java could not read the lastModifiedTime attribute on Windows?

206 views Asked by At

A customer has lots of following stacktraces appearing in the logs of my application. It runs on WildFly 18 and JDK 11 on Windows Server.

2022-10-14 14:36:19,382 ERROR [io.undertow.request] (default I/O-2) UT005071: Undertow request failed HttpServerExchange{ GET /application/images/gray/qtip/nul}: java.lang.RuntimeException: java.nio.file.FileSystemException: C:\PROGRAM\SAUSAGE\wildfly-gui\standalone\tmp\vfs\temp\temp5bd4c0db725d6b53\content-d8575e88ce594507\images\gray\qtip\nul: The parameter is incorrect.

    at [email protected]//io.undertow.server.handlers.resource.PathResource.getLastModified(PathResource.java:65)
    at [email protected]//org.wildfly.extension.undertow.deployment.ServletResource.getLastModified(ServletResource.java:61)
    at [email protected]//io.undertow.server.handlers.resource.CachedResource.<init>(CachedResource.java:59)
    at [email protected]//io.undertow.server.handlers.resource.CachingResourceManager.getResource(CachingResourceManager.java:119)
    at [email protected]//io.undertow.server.handlers.resource.CachingResourceManager.getResource(CachingResourceManager.java:32)
    at [email protected]//io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:96)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:146)
    at [email protected]//io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
    at [email protected]//io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
    at [email protected]//org.wildfly.extension.undertow.Host$OptionsHandler.handleRequest(Host.java:399)
    at [email protected]//io.undertow.server.handlers.HttpContinueReadHandler.handleRequest(HttpContinueReadHandler.java:65)
    at [email protected]//io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72)
    at [email protected]//io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at [email protected]//io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at [email protected]//org.wildfly.extension.undertow.Host$AcmeResourceHandler.handleRequest(Host.java:421)
    at [email protected]//org.wildfly.extension.undertow.Host$HostRootHandler.handleRequest(Host.java:430)
    at [email protected]//io.undertow.server.handlers.NameVirtualHostHandler.handleRequest(NameVirtualHostHandler.java:64)
    at [email protected]//io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
    at [email protected]//io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
    at [email protected]//org.wildfly.extension.undertow.Server$DefaultHostHandler.handleRequest(Server.java:190)
    at [email protected]//io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
    at [email protected]//io.undertow.server.handlers.DisallowedMethodsHandler.handleRequest(DisallowedMethodsHandler.java:61)
    at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
    at [email protected]//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
    at [email protected]//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
    at [email protected]//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
    at [email protected]//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
    at [email protected]//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
    at [email protected]//io.undertow.protocols.ssl.SslConduit$SslReadReadyHandler.readReady(SslConduit.java:1176)
    at [email protected]//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
    at [email protected]//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Caused by: java.nio.file.FileSystemException: C:\PROGRAM\SAUSAGE\wildfly-gui\standalone\tmp\vfs\temp\temp5bd4c0db725d6b53\content-d8575e88ce594507\images\gray\qtip\nul: The parameter is incorrect.

    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
    at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:198)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1764)
    at java.base/java.nio.file.Files.getLastModifiedTime(Files.java:2315)
    at [email protected]//io.undertow.server.handlers.resource.PathResource.getLastModified(PathResource.java:63)
    ... 36 more

So always the method getLastModifiedTime triggers this issue. Does this mean that there are issues with permissions problems? I guess that my Java program doesn't have the sufficient rights to access these files, but I'm not sure about this.

Can someone help me?

1

There are 1 answers

0
VGR On

If we look at the underlying exception:

java.nio.file.FileSystemException: C:\PROGRAM\SAUSAGE\wildfly-gui\standalone\tmp\vfs\temp\temp5bd4c0db725d6b53\content-d8575e88ce594507\images\gray\qtip\nul: The parameter is incorrect.

We can see that the file’s final path component is nul. That name is not allowed in Windows at all, which is the reason for the cryptic exception message (which probably came from Windows, not from Java). This is documented at https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file :

Do not use the following reserved names for the name of a file:

CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

Solution: don’t name a file nul.