Archived
0

Sonar: [squid:S3725] Replace with a call to the "toFile().exists()" method

This commit is contained in:
2019-02-11 15:29:41 +03:00
parent 74f725eec4
commit 63b68c481b
3 changed files with 5 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkProvider; import mc.core.world.chunk.ChunkProvider;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@@ -20,7 +21,7 @@ public class AnvilChunkProvider implements ChunkProvider {
public AnvilChunkProvider(String mapPath) { public AnvilChunkProvider(String mapPath) {
Path pathMap = Paths.get(mapPath); Path pathMap = Paths.get(mapPath);
if (Files.exists(pathMap)) { if (pathMap.toFile().exists()) {
log.info("Use Anvil map from \"{}\"", pathMap); log.info("Use Anvil map from \"{}\"", pathMap);
this.setRegionManager(new RegionManager(pathMap.resolve("region"))); this.setRegionManager(new RegionManager(pathMap.resolve("region")));
} else { } else {

View File

@@ -32,7 +32,7 @@ public class RegionManager {
return regions.get(xz); return regions.get(xz);
} else { } else {
Path regionFilePath = regionFilesPath.resolve("r." + x + "." + z + ".mca"); Path regionFilePath = regionFilesPath.resolve("r." + x + "." + z + ".mca");
if (Files.exists(regionFilePath)) { if (regionFilePath.toFile().exists()) {
try { try {
Region region = new Region(regionFilePath.toFile()); Region region = new Region(regionFilePath.toFile());
regions.put(xz, region); regions.put(xz, region);

View File

@@ -7,6 +7,7 @@ import org.apache.commons.io.IOUtils;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext;
import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -17,7 +18,7 @@ public class Main {
private static ApplicationContext createContext() { private static ApplicationContext createContext() {
final String springXml = System.getProperty("springConfig", "./spring.xml"); final String springXml = System.getProperty("springConfig", "./spring.xml");
if (!Files.exists(Paths.get(springXml))) { if (!(new File(springXml)).exists()) {
log.info("File \"{}\" not found. Get default config.", springXml); log.info("File \"{}\" not found. Get default config.", springXml);
try (FileOutputStream fos = new FileOutputStream(springXml)) { try (FileOutputStream fos = new FileOutputStream(springXml)) {
IOUtils.copy(Main.class.getResourceAsStream("/spring.xml"), fos); IOUtils.copy(Main.class.getResourceAsStream("/spring.xml"), fos);