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

Prefer more modern try with resources over IOUtil.close #179

Merged
merged 1 commit into from
Mar 16, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.maven.shared.release.config.ReleaseUtils;
import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
import org.apache.maven.shared.release.util.ReleaseUtil;
import org.codehaus.plexus.util.IOUtil;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -162,14 +161,9 @@ public void testExecuteWithSuppressCommitBeforeTag() throws Exception {
ReleaseResult result = phase.execute(
ReleaseUtils.buildReleaseDescriptor(builder), new DefaultReleaseEnvironment(), reactorProjects);

BufferedReader reader = null;
try {
reader = new BufferedReader(new StringReader(result.getOutput()));

try (BufferedReader reader = new BufferedReader(new StringReader(result.getOutput()))) {
assertEquals("[INFO] Removing release POM for 'artifactId'...", reader.readLine());
assertEquals("Expected EOF", null, reader.readLine());
} finally {
IOUtil.close(reader);
}

// never invoke scmProviderMock
Expand All @@ -193,18 +187,13 @@ public void testSimulateWithSuppressCommitBeforeTag() throws Exception {
ReleaseResult result = phase.simulate(
ReleaseUtils.buildReleaseDescriptor(builder), new DefaultReleaseEnvironment(), reactorProjects);

BufferedReader reader = null;
try {
reader = new BufferedReader(new StringReader(result.getOutput()));

try (BufferedReader reader = new BufferedReader(new StringReader(result.getOutput()))) {
assertEquals("[INFO] Removing release POM for 'artifactId'...", reader.readLine());
assertEquals(
"[INFO] Full run would be removing ["
+ reactorProjects.get(0).getFile().getParent() + File.separator + "release-pom.xml]",
reader.readLine());
assertEquals("Expected EOF", null, reader.readLine());
} finally {
IOUtil.close(reader);
}

// never invoke scmProviderMock
Expand Down