mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Fix some resources that are never closed, close in a finally block (#3637)
This commit is contained in:
1 parent
9fe6385e1f
commit
376f172990
14 files changed
+200
-114
No files matched your search
@@ -62,6 +62,7 @@ import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.FMLInjectionData;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
/**
|
||||
* This class offers advanced configurations capabilities, allowing to provide
|
||||
@@ -1055,20 +1056,8 @@ public class Configuration
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (buffer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
buffer.close();
|
||||
} catch (IOException e){}
|
||||
}
|
||||
if (input != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
} catch (IOException e){}
|
||||
}
|
||||
IOUtils.closeQuietly(buffer);
|
||||
IOUtils.closeQuietly(input);
|
||||
}
|
||||
|
||||
resetChangedState();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class Java6Utils
|
||||
{
|
||||
/**
|
||||
* {@link ZipFile} does not implement {@link Closeable} on Java 6.
|
||||
* This method is the same as {@link IOUtils#closeQuietly(Closeable)} but works on {@link ZipFile} on Java 6.
|
||||
*/
|
||||
public static void closeZipQuietly(@Nullable ZipFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package net.minecraftforge.fml.client;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -103,6 +104,7 @@ import net.minecraftforge.fml.common.registry.PersistentRegistryManager;
|
||||
import net.minecraftforge.fml.common.toposort.ModSortingException;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -290,9 +292,17 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
|
||||
String optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
|
||||
Map<String,Object> dummyOptifineMeta = ImmutableMap.<String,Object>builder().put("name", "Optifine").put("version", optifineVersion).build();
|
||||
ModMetadata optifineMetadata = MetadataCollection.from(getClass().getResourceAsStream("optifinemod.info"),"optifine").getMetadataForId("optifine", dummyOptifineMeta);
|
||||
optifineContainer = new DummyModContainer(optifineMetadata);
|
||||
FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion());
|
||||
InputStream optifineModInfoInputStream = getClass().getResourceAsStream("optifinemod.info");
|
||||
try
|
||||
{
|
||||
ModMetadata optifineMetadata = MetadataCollection.from(optifineModInfoInputStream, "optifine").getMetadataForId("optifine", dummyOptifineMeta);
|
||||
optifineContainer = new DummyModContainer(optifineMetadata);
|
||||
FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features", optifineContainer.getVersion());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(optifineModInfoInputStream);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.minecraftforge.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -53,6 +54,7 @@ import net.minecraftforge.fml.common.versioning.VersionParser;
|
||||
import net.minecraftforge.fml.common.versioning.VersionRange;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -286,7 +288,15 @@ public class FMLModContainer implements ModContainer
|
||||
if (versionFile != null)
|
||||
{
|
||||
version = new Properties();
|
||||
version.load(source.getInputStream(versionFile));
|
||||
InputStream sourceInputStream = source.getInputStream(versionFile);
|
||||
try
|
||||
{
|
||||
version.load(sourceInputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(sourceInputStream);
|
||||
}
|
||||
}
|
||||
source.close();
|
||||
}
|
||||
@@ -297,8 +307,14 @@ public class FMLModContainer implements ModContainer
|
||||
{
|
||||
version = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propsFile);
|
||||
version.load(fis);
|
||||
fis.close();
|
||||
try
|
||||
{
|
||||
version.load(fis);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
return version;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -59,6 +60,7 @@ import net.minecraftforge.fml.common.versioning.VersionParser;
|
||||
import net.minecraftforge.fml.relauncher.ModListHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
@@ -213,7 +215,15 @@ public class Loader
|
||||
}
|
||||
|
||||
minecraft = new MinecraftDummyContainer(MC_VERSION);
|
||||
mcp = new MCPDummyContainer(MetadataCollection.from(getClass().getResourceAsStream("/mcpmod.info"), "MCP").getMetadataForId("mcp", null));
|
||||
InputStream mcpModInputStream = getClass().getResourceAsStream("/mcpmod.info");
|
||||
try
|
||||
{
|
||||
mcp = new MCPDummyContainer(MetadataCollection.from(mcpModInputStream, "MCP").getMetadataForId("mcp", null));
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(mcpModInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.fml.common.asm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.CodeSource;
|
||||
import java.security.cert.Certificate;
|
||||
@@ -28,6 +28,8 @@ import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import net.minecraftforge.common.util.Java6Utils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
@@ -113,7 +115,15 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
mcJarFile = new JarFile(mcPath,true);
|
||||
mcJarFile.getManifest();
|
||||
JarEntry cbrEntry = mcJarFile.getJarEntry("net/minecraft/client/ClientBrandRetriever.class");
|
||||
ByteStreams.toByteArray(mcJarFile.getInputStream(cbrEntry));
|
||||
InputStream mcJarFileInputStream = mcJarFile.getInputStream(cbrEntry);
|
||||
try
|
||||
{
|
||||
ByteStreams.toByteArray(mcJarFileInputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(mcJarFileInputStream);
|
||||
}
|
||||
Certificate[] certificates = cbrEntry.getCertificates();
|
||||
certCount = certificates != null ? certificates.length : 0;
|
||||
if (certificates!=null)
|
||||
@@ -136,17 +146,7 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (mcJarFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mcJarFile.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
// Noise
|
||||
}
|
||||
}
|
||||
Java6Utils.closeZipQuietly(mcJarFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+3
-21
@@ -45,6 +45,7 @@ import java.util.zip.ZipOutputStream;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraftforge.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
@@ -469,27 +470,8 @@ public class AccessTransformer implements IClassTransformer
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (outJar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
outJar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (inJar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
inJar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
IOUtils.closeQuietly(outJar);
|
||||
IOUtils.closeQuietly(inJar);
|
||||
}
|
||||
}
|
||||
Multimap<String, Modifier> getModifiers()
|
||||
|
||||
+3
-21
@@ -35,6 +35,7 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -269,27 +270,8 @@ public class MarkerTransformer implements IClassTransformer
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (outJar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
outJar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (inJar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
inJar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
IOUtils.closeQuietly(outJar);
|
||||
IOUtils.closeQuietly(inJar);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.ModContainerFactory;
|
||||
import net.minecraftforge.fml.common.discovery.asm.ASMModParser;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
@@ -73,8 +74,14 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
|
||||
try
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(metadata);
|
||||
mc = MetadataCollection.from(fis,modDir.getName());
|
||||
fis.close();
|
||||
try
|
||||
{
|
||||
mc = MetadataCollection.from(fis, modDir.getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fis);
|
||||
}
|
||||
FMLLog.fine("Found an mcmod.info file in directory %s", modDir.getName());
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -101,11 +108,11 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
|
||||
if (match.matches())
|
||||
{
|
||||
ASMModParser modParser = null;
|
||||
FileInputStream fis = null;
|
||||
try
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
fis = new FileInputStream(file);
|
||||
modParser = new ASMModParser(fis);
|
||||
fis.close();
|
||||
candidate.addClassEntry(path+file.getName());
|
||||
}
|
||||
catch (LoaderException e)
|
||||
@@ -115,7 +122,11 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Throwables.propagate(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(fis);
|
||||
}
|
||||
|
||||
modParser.validate();
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
|
||||
package net.minecraftforge.fml.common.discovery;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import net.minecraftforge.common.util.Java6Utils;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.LoaderException;
|
||||
import net.minecraftforge.fml.common.MetadataCollection;
|
||||
@@ -30,6 +32,7 @@ import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.ModContainerFactory;
|
||||
import net.minecraftforge.fml.common.discovery.asm.ASMModParser;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -54,7 +57,15 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
if (modInfo != null)
|
||||
{
|
||||
FMLLog.finer("Located mcmod.info file in file %s", candidate.getModContainer().getName());
|
||||
mc = MetadataCollection.from(jar.getInputStream(modInfo), candidate.getModContainer().getName());
|
||||
InputStream inputStream = jar.getInputStream(modInfo);
|
||||
try
|
||||
{
|
||||
mc = MetadataCollection.from(inputStream, candidate.getModContainer().getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,7 +84,15 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
ASMModParser modParser;
|
||||
try
|
||||
{
|
||||
modParser = new ASMModParser(jar.getInputStream(ze));
|
||||
InputStream inputStream = jar.getInputStream(ze);
|
||||
try
|
||||
{
|
||||
modParser = new ASMModParser(inputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
}
|
||||
candidate.addClassEntry(ze.getName());
|
||||
}
|
||||
catch (LoaderException e)
|
||||
@@ -101,16 +120,7 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jar.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
Java6Utils.closeZipQuietly(jar);
|
||||
}
|
||||
return foundMods;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.minecraftforge.fml.common.patcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -30,6 +31,7 @@ import java.util.jar.JarFile;
|
||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import net.minecraftforge.fml.repackage.com.nothome.delta.Delta;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -40,6 +42,8 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GenDiffSet {
|
||||
|
||||
private static final List<String> RESERVED_NAMES = Arrays.asList("CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9");
|
||||
@@ -78,8 +82,7 @@ public class GenDiffSet {
|
||||
String sourceClassName = name.replace('/', '.');
|
||||
String targetClassName = remapper.map(name).replace('/', '.');
|
||||
JarEntry entry = sourceZip.getJarEntry(jarName);
|
||||
|
||||
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
|
||||
byte[] vanillaBytes = toByteArray(sourceZip, entry);
|
||||
byte[] patchedBytes = Files.toByteArray(targetFile);
|
||||
|
||||
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
|
||||
@@ -117,4 +120,21 @@ public class GenDiffSet {
|
||||
sourceZip.close();
|
||||
}
|
||||
|
||||
private static byte[] toByteArray(JarFile sourceZip, @Nullable JarEntry entry) throws IOException
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
InputStream sourceZipInputStream = sourceZip.getInputStream(entry);
|
||||
try
|
||||
{
|
||||
return ByteStreams.toByteArray(sourceZipInputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(sourceZipInputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import java.io.FileFilter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@@ -55,6 +56,7 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
@@ -464,9 +466,19 @@ public class CoreModManager {
|
||||
try
|
||||
{
|
||||
Files.createParentDirs(target);
|
||||
FileOutputStream targ = new FileOutputStream(target);
|
||||
ByteStreams.copy(jar.getInputStream(jarEntry), targ);
|
||||
targ.close();
|
||||
FileOutputStream targetOutputStream = null;
|
||||
InputStream jarInputStream = null;
|
||||
try
|
||||
{
|
||||
targetOutputStream = new FileOutputStream(target);
|
||||
jarInputStream = jar.getInputStream(jarEntry);
|
||||
ByteStreams.copy(jarInputStream, targetOutputStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(targetOutputStream);
|
||||
IOUtils.closeQuietly(jarInputStream);
|
||||
}
|
||||
FMLRelaunchLog.log(Level.DEBUG, "Extracted ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath());
|
||||
result.put(dep,target);
|
||||
} catch (IOException e)
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package net.minecraftforge.fml.repackage.com.nothome.delta;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import static net.minecraftforge.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_INT;
|
||||
import static net.minecraftforge.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_UBYTE;
|
||||
import static net.minecraftforge.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_USHORT;
|
||||
@@ -70,16 +72,16 @@ public class GDiffPatcher {
|
||||
throws IOException
|
||||
{
|
||||
RandomAccessFileSeekableSource source =new RandomAccessFileSeekableSource(new RandomAccessFile(sourceFile, "r"));
|
||||
InputStream patch = new FileInputStream(patchFile);
|
||||
OutputStream output = new FileOutputStream(outputFile);
|
||||
InputStream patch = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
patch = new FileInputStream(patchFile);
|
||||
output = new FileOutputStream(outputFile);
|
||||
patch(source, patch, output);
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
source.close();
|
||||
patch.close();
|
||||
output.close();
|
||||
IOUtils.closeQuietly(source);
|
||||
IOUtils.closeQuietly(patch);
|
||||
IOUtils.closeQuietly(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.server.dedicated.PendingCommand;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.util.text.translation.LanguageMap;
|
||||
import net.minecraft.world.storage.SaveFormatOld;
|
||||
import net.minecraftforge.common.util.Java6Utils;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.IFMLSidedHandler;
|
||||
@@ -259,15 +260,7 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(stream);
|
||||
try
|
||||
{
|
||||
if (zip != null)
|
||||
zip.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// shush
|
||||
}
|
||||
Java6Utils.closeZipQuietly(zip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user