Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-55759] Updates #61

Merged
merged 4 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.121.2</jenkins.version>
<java.level>8</java.level>
<workflow-step-api.version>2.14</workflow-step-api.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<workflow-step-api.version>2.16</workflow-step-api.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -94,7 +93,7 @@
<!-- Require upper bound dependencies error -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.30</version>
<version>2.31</version>
</dependency>
<dependency>
<!-- Require upper bound dependencies error -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.tools.ant.types.selectors.SelectorUtils;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -132,13 +129,10 @@ public Map<String, String> invoke(File zipFile, VirtualChannel channel) throws I
destination.mkdirs();
}
PrintStream logger = listener.getLogger();
ZipFile zip = null;
boolean doGlob = !StringUtils.isBlank(glob);
Map<String, String> strMap = new TreeMap<String, String>();
try {
try (ZipFile zip = new ZipFile(zipFile, Charset.forName(charset))) {
logger.println("Extracting from " + zipFile.getAbsolutePath());
Charset charsetForZip = Charset.forName(charset);
zip = new ZipFile(zipFile, charsetForZip);
Enumeration<? extends ZipEntry> entries = zip.entries();
Integer fileCount = 0;
while (entries.hasMoreElements()) {
Expand Down Expand Up @@ -196,7 +190,7 @@ public Map<String, String> invoke(File zipFile, VirtualChannel channel) throws I
return null;
}
} finally {
IOUtils.closeQuietly(zip);
logger.flush();
}
}

Expand All @@ -220,9 +214,7 @@ public TestZipFileCallable(TaskListener listener) {
@Override
public Boolean invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
PrintStream logger = listener.getLogger();
ZipFile zip = null;
try {
zip = new ZipFile(f);
try (ZipFile zip = new ZipFile(f)) {
logger.print("Checking ");
logger.print(zip.size());
logger.print(" zipped entries in ");
Expand Down Expand Up @@ -254,8 +246,7 @@ public Boolean invoke(File f, VirtualChannel channel) throws IOException, Interr
listener.error("Error validating zip file: " + e.getMessage());
return false;
} finally {
//according to docs this should also close all open streams.
IOUtils.closeQuietly(zip);
logger.flush();
}
}
}
Expand Down