This is an automated email from the ASF dual-hosted git repository.
lewismc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-mudrod.git
The following commit(s) were added to refs/heads/master by this push:
new 742a190 SDAP-73 (#18)
742a190 is described below
commit 742a1902daed040a38c5a344d048c15c4056706d
Author: quintinali <[email protected]>
AuthorDate: Tue Jun 5 14:22:30 2018 -0400
SDAP-73 (#18)
* solved bugs in MudrodEngine
1.Modify this "assert" statement.
2.Use try-with-resources to close ZipInputStream
* change variable name to lowercase
---
.../org/apache/sdap/mudrod/main/MudrodEngine.java | 49 +++++++++++-----------
1 file changed, 25 insertions(+), 24 deletions(-)
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 @@ public class MudrodEngine {
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);
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
[email protected].