HADOOP-10517. Merging change r1592855 from trunk to branch-2.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1592856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bfe689c00b
commit
7a0d71916d
|
@ -116,6 +116,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
HADOOP-10541. InputStream in MiniKdc#initKDCServer for minikdc.ldiff is not
|
HADOOP-10541. InputStream in MiniKdc#initKDCServer for minikdc.ldiff is not
|
||||||
closed. (Swarnim Kulkarni via cnauroth)
|
closed. (Swarnim Kulkarni via cnauroth)
|
||||||
|
|
||||||
|
HADOOP-10517. InputStream is not closed in two methods of JarFinder.
|
||||||
|
(Ted Yu via cnauroth)
|
||||||
|
|
||||||
Release 2.4.1 - UNRELEASED
|
Release 2.4.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -39,17 +39,24 @@ import java.util.zip.ZipOutputStream;
|
||||||
*/
|
*/
|
||||||
public class JarFinder {
|
public class JarFinder {
|
||||||
|
|
||||||
private static void copyToZipStream(InputStream is, ZipEntry entry,
|
private static void copyToZipStream(File file, ZipEntry entry,
|
||||||
ZipOutputStream zos) throws IOException {
|
ZipOutputStream zos) throws IOException {
|
||||||
zos.putNextEntry(entry);
|
InputStream is = new FileInputStream(file);
|
||||||
byte[] arr = new byte[4096];
|
try {
|
||||||
int read = is.read(arr);
|
zos.putNextEntry(entry);
|
||||||
while (read > -1) {
|
byte[] arr = new byte[4096];
|
||||||
zos.write(arr, 0, read);
|
int read = is.read(arr);
|
||||||
read = is.read(arr);
|
while (read > -1) {
|
||||||
|
zos.write(arr, 0, read);
|
||||||
|
read = is.read(arr);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} finally {
|
||||||
|
zos.closeEntry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is.close();
|
|
||||||
zos.closeEntry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void jarDir(File dir, String relativePath, ZipOutputStream zos)
|
public static void jarDir(File dir, String relativePath, ZipOutputStream zos)
|
||||||
|
@ -66,8 +73,7 @@ public class JarFinder {
|
||||||
new Manifest().write(new BufferedOutputStream(zos));
|
new Manifest().write(new BufferedOutputStream(zos));
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
} else {
|
} else {
|
||||||
InputStream is = new FileInputStream(manifestFile);
|
copyToZipStream(manifestFile, manifestEntry, zos);
|
||||||
copyToZipStream(is, manifestEntry, zos);
|
|
||||||
}
|
}
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
zipDir(dir, relativePath, zos, true);
|
zipDir(dir, relativePath, zos, true);
|
||||||
|
@ -94,8 +100,7 @@ public class JarFinder {
|
||||||
String path = relativePath + f.getName();
|
String path = relativePath + f.getName();
|
||||||
if (!path.equals(JarFile.MANIFEST_NAME)) {
|
if (!path.equals(JarFile.MANIFEST_NAME)) {
|
||||||
ZipEntry anEntry = new ZipEntry(path);
|
ZipEntry anEntry = new ZipEntry(path);
|
||||||
InputStream is = new FileInputStream(f);
|
copyToZipStream(f, anEntry, zos);
|
||||||
copyToZipStream(is, anEntry, zos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue