test/tools/jar/index/MetaInf.java
Print this page
*** 60,71 ****
}
}
static boolean contains(File jarFile, String entryName)
throws IOException {
! return new ZipFile(jarFile).getEntry(entryName) != null;
}
static void checkContains(File jarFile, String entryName)
throws IOException {
if (! contains(jarFile, entryName))
throw new Error(String.format("expected jar %s to contain %s",
--- 60,77 ----
}
}
static boolean contains(File jarFile, String entryName)
throws IOException {
! ZipFile zf = new ZipFile(jarFile);
! if ( zf != null ) {
! boolean result = zf.getEntry(entryName) != null;
! zf.close();
! return result;
}
+ return false;
+ }
static void checkContains(File jarFile, String entryName)
throws IOException {
if (! contains(jarFile, entryName))
throw new Error(String.format("expected jar %s to contain %s",
*** 92,104 ****
--- 98,114 ----
new InputStreamReader(
f.getInputStream(f.getJarEntry(INDEX))));
String line;
while ((line = index.readLine()) != null) {
if (line.equals(SERVICES)) {
+ index.close();
+ f.close();
return;
}
}
+ index.close();
+ f.close();
throw new Error(SERVICES + " not indexed.");
}
public static void main(String[] args) throws IOException {
testIndex("a.jar"); // a path with parent == null