### Question:
SparkRunnerClassLoader extends URLClassLoader { @Override public InputStream getResourceAsStream(String name) { URL url = getResource(name); if (url == null) { return null; } try { URLConnection urlConn = url.openConnection(); urlConn.setUseCaches(false); InputStream is = urlConn.getInputStream(); closeablesLock.lock(); try { closeables.putIfAbsent(is, null); } finally { closeablesLock.unlock(); } return is; } catch (IOException e) { return null; } } SparkRunnerClassLoader(URL[] urls, @Nullable ClassLoader parent, boolean rewriteYarnClient); @Override InputStream getResourceAsStream(String name); @Override void close();  }### Answer:
@Test(expected = IOException.class) public void testCloseResourceStream() throws IOException { List<URL> urls = ClassLoaders.getClassLoaderURLs(getClass().getClassLoader(), new ArrayList<URL>()); URL[] urlArray = urls.toArray(new URL[urls.size()]); SparkRunnerClassLoader cl = new SparkRunnerClassLoader(urlArray, getClass().getClassLoader(), false); InputStream is = cl.getResourceAsStream("org/apache/spark/SparkContext.class"); Assert.assertNotNull(is); Closeables.closeQuietly(cl); is.read(); }