Close various resource inputstreams

This commit is contained in:
Adam
2021-07-04 15:14:05 -04:00
parent 6b11afd907
commit 5d420ae57b
12 changed files with 76 additions and 44 deletions

View File

@@ -29,6 +29,7 @@ import com.google.common.io.CharSource;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
@@ -50,8 +51,13 @@ public class SkyboxTest
@Test
public void testLoadActual() throws IOException
{
long start = System.nanoTime();
Skybox skybox = new Skybox(SkyboxPlugin.class.getResourceAsStream("skybox.txt"), "skybox.txt");
long start;
Skybox skybox;
try (InputStream in = SkyboxPlugin.class.getResourceAsStream("skybox.txt"))
{
start = System.nanoTime();
skybox = new Skybox(in, "skybox.txt");
}
log.info("Parse took {}ms", (System.nanoTime() - start) / 1_000_000);
String skyboxFile = System.getProperty("skyboxExport");

View File

@@ -25,19 +25,24 @@
*/
package net.runelite.client.plugins.worldmap;
import java.io.IOException;
import java.io.InputStream;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
public class TeleportLocationDataTest
{
@Test
public void testResources()
public void testResources() throws IOException
{
for (TeleportLocationData data : TeleportLocationData.values())
{
String path = data.getIconPath();
assertNotNull(path);
assertNotNull(path, getClass().getResourceAsStream(path));
try (InputStream in = getClass().getResourceAsStream(path))
{
assertNotNull(in);
}
}
}
}