Closed yn-tadpole closed 3 years ago
Looks related to https://github.com/eclipse-vertx/vert.x/issues/3510
It's not a duplicate question. The problem is actually this:
Let's assume that the static folder structure is as follows.
/static/ /static/js/... (20 files) /static/imgs/...(100 files) /static/index.html
When cache is disabled, every request for index.html file will cause all files in js and imgs folders to be re copied to the vertx-cache/... folder. If index.html References to other files in imgs folder will result in a nightmarish cycle.
Please check the following codes: at io.vertx.core.file.impl.FileResolver.unpackFromFileURL(FileResolver.java:240) ~[vertx-core-3.9.2.jar:3.9.2] at io.vertx.core.file.impl.FileResolver.unpackFromFileURL(FileResolver.java:248) ~[vertx-core-3.9.2.jar:3.9.2] at io.vertx.core.file.impl.FileResolver.unpackUrlResource(FileResolver.java:212) ~[vertx-core-3.9.2.jar:3.9.2] at io.vertx.core.file.impl.FileResolver.resolveFile(FileResolver.java:171) ~[vertx-core-3.9.2.jar:3.9.2]
Can you please share a small reproducer?
@tsegismont and @yn-tadpole, this may look like a very ineffective piece of code, but it is like this by design. Let me explain it a bit further, disable the file cache isn't a feature users do on a live system, usually it is a development feature, where you want to be able to change resources at runtime and the changes are visible without a restart.
So when the the cache is disabled and the /index.html
is requested we need to refresh everything under that path because, there is no knowledge on the vert.x side if the goal of the user is to perform a directory listing. If this is the case, the listing would be wrong because we only extracted a single file.
You are right :)
When file caching is disabled (by set FileSystemOptions.setFileCachingEnabled (false) or -Dvertx.disableFileCaching=true). Every time a static resource is requested, the file will be written to the vertx cache directory, which often causes the file to be occupied and an exception is thrown.
io.vertx.core.VertxException: java.nio.file.FileSystemException: ...(filePath)...: The process cannot access the file because it is being used by another process.