mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Use multiple catch, try-with-resources, replace system.out and e.printStackTrace
This commit is contained in:
1 parent
10ca404e9e
commit
93025510ae
27 files changed
+62
-132
No files matched your search
@@ -700,11 +700,7 @@ public class FMLCommonHandler
|
||||
task.run();
|
||||
task.get(); // Forces the exception to be thrown if any
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
FMLLog.log.fatal("Exception caught executing FutureTask: {}", e.toString(), e);
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
FMLLog.log.fatal("Exception caught executing FutureTask: {}", e.toString(), e);
|
||||
}
|
||||
|
||||
@@ -320,15 +320,10 @@ public class FMLModContainer implements ModContainer
|
||||
if (propsFile.exists() && propsFile.isFile())
|
||||
{
|
||||
version = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propsFile);
|
||||
try
|
||||
try (FileInputStream fis = new FileInputStream(propsFile))
|
||||
{
|
||||
version.load(fis);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
return version;
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ import static org.objectweb.asm.Type.BOOLEAN_TYPE;
|
||||
import static org.objectweb.asm.Type.getMethodDescriptor;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -92,7 +93,7 @@ public class EventSubscriptionTransformer implements IClassTransformer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
FMLLog.log.error("Error building events.", e);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
FMLLog.log.error("Error getting patched resource:", e);
|
||||
}
|
||||
}
|
||||
public void mergeSuperMaps(String name, @Nullable String superName, String[] interfaces)
|
||||
|
||||
@@ -46,25 +46,17 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
{
|
||||
List<ModContainer> foundMods = Lists.newArrayList();
|
||||
FMLLog.log.debug("Examining file {} for potential mods", candidate.getModContainer().getName());
|
||||
JarFile jar = null;
|
||||
try
|
||||
try (JarFile jar = new JarFile(candidate.getModContainer()))
|
||||
{
|
||||
jar = new JarFile(candidate.getModContainer());
|
||||
|
||||
ZipEntry modInfo = jar.getEntry("mcmod.info");
|
||||
MetadataCollection mc = null;
|
||||
if (modInfo != null)
|
||||
{
|
||||
FMLLog.log.trace("Located mcmod.info file in file {}", candidate.getModContainer().getName());
|
||||
InputStream inputStream = jar.getInputStream(modInfo);
|
||||
try
|
||||
try (InputStream inputStream = jar.getInputStream(modInfo))
|
||||
{
|
||||
mc = MetadataCollection.from(inputStream, candidate.getModContainer().getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -83,15 +75,10 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
ASMModParser modParser;
|
||||
try
|
||||
{
|
||||
InputStream inputStream = jar.getInputStream(ze);
|
||||
try
|
||||
try (InputStream inputStream = jar.getInputStream(ze))
|
||||
{
|
||||
modParser = new ASMModParser(inputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
}
|
||||
candidate.addClassEntry(ze.getName());
|
||||
}
|
||||
catch (LoaderException e)
|
||||
@@ -117,10 +104,6 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
{
|
||||
FMLLog.log.warn("Zip file {} failed to read properly, it will be ignored", candidate.getModContainer().getName(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(jar);
|
||||
}
|
||||
return foundMods;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class EventBus implements IEventExceptionHandler
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
;
|
||||
FMLLog.log.error("Could not find method '{}' on class '{}'", method.getName(), cls);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class EventBus implements IEventExceptionHandler
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
FMLLog.log.error("Error registering event handler: {} {} {}", owner, eventType, method, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FMLDeobfTweaker implements ITweaker {
|
||||
catch (Exception e)
|
||||
{
|
||||
// Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here
|
||||
System.out.println("A CRITICAL PROBLEM OCCURRED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
|
||||
FMLLog.log.fatal("A CRITICAL PROBLEM OCCURRED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,14 +127,9 @@ public class GenDiffSet {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
InputStream sourceZipInputStream = sourceZip.getInputStream(entry);
|
||||
try
|
||||
try (InputStream sourceZipInputStream = sourceZip.getInputStream(entry))
|
||||
{
|
||||
return ByteStreams.toByteArray(sourceZipInputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(sourceZipInputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityList.EntityEggInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry.Impl;
|
||||
|
||||
public class EntityEntry extends Impl<EntityEntry>
|
||||
@@ -79,7 +80,7 @@ public class EntityEntry extends Impl<EntityEntry>
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
FMLLog.log.error("Error creating entity.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user