lewismc closed pull request #18: SDAP-73
URL: https://github.com/apache/incubator-sdap-mudrod/pull/18
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
b/core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
index 80b0856..0efd3ee 100644
--- a/core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
+++ b/core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
@@ -173,34 +173,35 @@ private String decompressSVMWithSGDModel(String
archiveName) throws IOException
throw new IOException("Unable to locate " + archiveName + " as a
classpath resource.");
}
File tempDir = Files.createTempDirectory("mudrod").toFile();
- assert tempDir.setWritable(true);
+ boolean bWritable = tempDir.setWritable(true);
+ assert bWritable;
File archiveFile = new File(tempDir, archiveName);
FileUtils.copyURLToFile(scmArchive, archiveFile);
// Decompress archive
- int bufferSize = 512000;
- @SuppressWarnings("resource")
- ZipInputStream zipIn = new ZipInputStream(new
FileInputStream(archiveFile));
- ZipEntry entry;
- while ((entry = zipIn.getNextEntry()) != null) {
- File f = new File(tempDir, entry.getName());
- // If the entry is a directory, create the directory.
- if (entry.isDirectory() && !f.exists()) {
- boolean created = f.mkdirs();
- if (!created) {
- LOG.error("Unable to create directory '{}', during extraction of
archive contents.", f.getAbsolutePath());
- }
- } else if (!entry.isDirectory()) {
- boolean created = f.getParentFile().mkdirs();
- if (!created && !f.getParentFile().exists()) {
- LOG.error("Unable to create directory '{}', during extraction of
archive contents.", f.getParentFile().getAbsolutePath());
- }
- int count;
- byte data[] = new byte[bufferSize];
- FileOutputStream fos = new FileOutputStream(new File(tempDir,
entry.getName()), false);
- try (BufferedOutputStream dest = new BufferedOutputStream(fos,
bufferSize)) {
- while ((count = zipIn.read(data, 0, bufferSize)) != -1) {
- dest.write(data, 0, count);
+ int buffer_size = 512000;
+ try (ZipInputStream zipIn = new ZipInputStream(new
FileInputStream(archiveFile))) {
+ ZipEntry entry;
+ while ((entry = zipIn.getNextEntry()) != null) {
+ File f = new File(tempDir, entry.getName());
+ // If the entry is a directory, create the directory.
+ if (entry.isDirectory() && !f.exists()) {
+ boolean created = f.mkdirs();
+ if (!created) {
+ LOG.error("Unable to create directory '{}', during extraction of
archive contents.", f.getAbsolutePath());
+ }
+ } else if (!entry.isDirectory()) {
+ boolean created = f.getParentFile().mkdirs();
+ if (!created && !f.getParentFile().exists()) {
+ LOG.error("Unable to create directory '{}', during extraction of
archive contents.", f.getParentFile().getAbsolutePath());
+ }
+ int count;
+ byte data[] = new byte[buffer_size];
+ FileOutputStream fos = new FileOutputStream(new File(tempDir,
entry.getName()), false);
+ try (BufferedOutputStream dest = new BufferedOutputStream(fos,
buffer_size)) {
+ while ((count = zipIn.read(data, 0, buffer_size)) != -1) {
+ dest.write(data, 0, count);
+ }
}
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services