Skip to content

Commit 95318b2

Browse files
committed
code inspection fixes
1 parent a506a88 commit 95318b2

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/main/java/com/falsepattern/lib/config/IConfigElementProxy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public boolean isProperty() {
2121
return proxied.isProperty();
2222
}
2323

24+
@SuppressWarnings("rawtypes")
2425
@Override
2526
public Class<? extends GuiConfigEntries.IConfigEntry> getConfigEntryClass() {
2627
return proxied.getConfigEntryClass();

src/main/java/com/falsepattern/lib/dependencies/DependencyLoader.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.io.IOException;
1010
import java.io.InputStream;
1111
import java.net.URL;
12+
import java.nio.file.Files;
1213
import java.util.HashMap;
1314
import java.util.HashSet;
1415
import java.util.Map;
@@ -94,7 +95,10 @@ public static void loadLibrary(String loadingModId,
9495
val jarName = groupId + "-" + mavenJarName;
9596
val libDir = new File(modsDir, "falsepattern");
9697
if (!libDir.exists()) {
97-
libDir.mkdirs();
98+
if (!libDir.mkdirs()) {
99+
FalsePatternLib.getLog().fatal("Failed to create directory {}", libDir);
100+
throw new RuntimeException("Failed to create directory " + libDir);
101+
}
98102
}
99103
val file = new File(libDir, jarName);
100104
if (file.exists()) {
@@ -115,7 +119,10 @@ public static void loadLibrary(String loadingModId,
115119
artifactId,
116120
preferredVersion,
117121
(suffix != null) ? ":" + suffix : "");
118-
file.delete();
122+
if (!file.delete()) {
123+
FalsePatternLib.getLog().fatal("Failed to delete file {}", file);
124+
throw new RuntimeException("Failed to delete file " + file);
125+
}
119126
}
120127
}
121128
for (var repo : mavenRepositories) {
@@ -190,7 +197,7 @@ private static void download(InputStream is, File target) throws IOException {
190197

191198
var bytesRead = 0;
192199

193-
val fileOutput = new BufferedOutputStream(new FileOutputStream(target));
200+
val fileOutput = new BufferedOutputStream(Files.newOutputStream(target.toPath()));
194201
byte[] smallBuffer = new byte[4096];
195202
while ((bytesRead = is.read(smallBuffer)) >= 0) {
196203
fileOutput.write(smallBuffer, 0, bytesRead);

src/main/java/com/falsepattern/lib/mixin/IMixinPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ default boolean loadJarOf(final ITargetedMod mod) {
102102
IMixin[] getMixinEnumValues();
103103

104104
static File findJarOf(final ITargetedMod mod) {
105-
try {
106-
return walk(MODS_DIRECTORY_PATH).filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
105+
try (val stream = walk(MODS_DIRECTORY_PATH)) {
106+
return stream.filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
107107
} catch (IOException e) {
108108
e.printStackTrace();
109109
return null;

src/main/java/com/falsepattern/lib/mixin/ITargetedMod.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface ITargetedMod {
1010

1111
boolean isLoadInDevelopment();
1212

13+
@SuppressWarnings("UnstableApiUsage")
1314
default boolean isMatchingJar(Path path) {
1415
String pathString = path.toString();
1516
String nameLowerCase = Files.getNameWithoutExtension(pathString).toLowerCase();

0 commit comments

Comments
 (0)