You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileSystemException on Windows: Files.copy(REPLACE_EXISTING) fails in deploySingleResource #1
On Windows servers, Localization.deploySingleResource fails every startup with:
java.nio.file.FileSystemException: plugins\ClickMobs\lang\en_US.json: O arquivo já está sendo usado por outro processo at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92) at java.base/java.nio.file.Files.copy(Files.java:2849) at de.clickism.configured.localization.Localization.deploySingleResource(Localization.java:483) at de.clickism.configured.localization.Localization.deployLocalizationFile(Localization.java:296) at de.clickism.configured.localization.Localization.deployOrGenerateLocalizationFile(Localization.java:285) at de.clickism.configured.localization.Localization.load(Localization.java:256)
Root Cause
In deploySingleResource, Files.copy(in, destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING) internally calls deleteIfExists before copying. On Windows, deleteIfExists requires exclusive access to the file. The file handle hasn't been fully released by the JVM from the preceding config.load() call in deployOrGenerateLocalizationFile, even though the reader was closed.
This creates a permanent loop on every startup:
config.load() reads the lang file
Version mismatch detected (local file has "version" key but Config looks for "_version")
deploySingleResource tries Files.copy(REPLACE_EXISTING) → fails because deleteIfExists can't get exclusive access on Windows
Suggested Fix
Replace Files.copy with Files.newOutputStream using TRUNCATE_EXISTING, which overwrites the file in-place without requiring deletion:
protectedbooleandeploySingleResource(Class<?> clazz, StringresourcePath, StringdestinationPath) {
Configured.LOGGER.info("Deploying resource '" + resourcePath + "' to '" + destinationPath + "'...");
try (InputStreamin = clazz.getResourceAsStream(resourcePath)) {
if (in == null) thrownewFileNotFoundException("Resource not found: " + resourcePath
+ ". Local file will be used instead.");
FiledestinationFile = newFile(destinationPath);
FiledestinationDirectory = destinationFile.getParentFile();
if (destinationDirectory != null) {
Files.createDirectories(destinationDirectory.toPath());
}
try (OutputStreamout = Files.newOutputStream(destinationFile.toPath(),
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING)) {
byte[] buffer = newbyte[8192];
intbytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
}
returntrue;
} catch (IOExceptione) {
Configured.LOGGER.log(Level.SEVERE, "Failed to deploy resource: " + e.getMessage(), e);
returnfalse;
}
}
EnvironmentOS: WindowsJava: 21+
Configuredversion: 0.3Reproduces: Everyserverstartup
Activity