Skip to content

Commit

Permalink
Prefer more modern try with resources over IOUtil.close (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored Mar 16, 2023
1 parent 3e077e7 commit d60bbc3
Showing 1 changed file with 2 additions and 13 deletions.
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

0 comments on commit d60bbc3

Please sign in to comment.