This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git

commit 0d5a7a4e32386a71f2d6ca602017a624926e2c2f
Author: Olivier Lamy <[email protected]>
AuthorDate: Tue Sep 9 10:05:59 2025 +1000

    fix upgrade, remove those useless final
    
    Signed-off-by: Olivier Lamy <[email protected]>
---
 pom.xml                                            |  1 +
 .../apache/maven/plugins/shade/DefaultShader.java  |  3 +
 .../apache/maven/plugins/shade/mojo/ShadeMojo.java |  1 +
 .../maven/plugins/shade/DefaultShaderTest.java     | 91 +++++++++++-----------
 .../shade/relocation/SimpleRelocatorTest.java      | 10 +--
 .../resource/ManifestResourceTransformerTest.java  | 12 +--
 .../resource/ServiceResourceTransformerTest.java   | 12 +--
 .../shade/resource/rule/TransformerTesterRule.java | 49 ++++++------
 8 files changed, 92 insertions(+), 87 deletions(-)

diff --git a/pom.xml b/pom.xml
index a457b63..de6c4ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,7 @@
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
       <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.15.1</version>
       <scope>provided</scope>
     </dependency>
 
diff --git a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java 
b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
index d8a9c65..5400b42 100644
--- a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
+++ b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
@@ -256,6 +256,7 @@ public class DefaultShader implements Shader {
         }
     }
 
+    @SuppressWarnings("checkstyle:ParameterNumber")
     private void shadeDir(
             ShadeRequest shadeRequest,
             Set<String> resources,
@@ -320,6 +321,7 @@ public class DefaultShader implements Shader {
         }
     }
 
+    @SuppressWarnings("checkstyle:ParameterNumber")
     private void shadeJar(
             ShadeRequest shadeRequest,
             Set<String> resources,
@@ -381,6 +383,7 @@ public class DefaultShader implements Shader {
         return false;
     }
 
+    @SuppressWarnings("checkstyle:ParameterNumber")
     private void shadeJarEntry(
             ShadeRequest shadeRequest,
             Set<String> resources,
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java 
b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index 115cab2..312c76a 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -447,6 +447,7 @@ public class ShadeMojo extends AbstractMojo {
     /**
      * @throws MojoExecutionException in case of an error.
      */
+    @SuppressWarnings("checkstyle:methodlength")
     @Override
     public void execute() throws MojoExecutionException {
         if (skip) {
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java 
b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
index 06395d1..ed14ddf 100644
--- a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
+++ b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java
@@ -31,6 +31,7 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.nio.file.attribute.FileTime;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
@@ -93,37 +94,37 @@ public class DefaultShaderTest {
             new String[] {"org/codehaus/plexus/util/xml/Xpp3Dom", 
"org/codehaus/plexus/util/xml/pull.*"};
 
     @ClassRule
-    public static final TemporaryFolder tmp = new TemporaryFolder();
+    public static final TemporaryFolder TEMPORARY_FOLDER = new 
TemporaryFolder();
 
-    private final String NEWLINE = "\n";
+    private static final String NEWLINE = "\n";
 
     @Test
     public void testNoopWhenNotRelocated() throws IOException, 
MojoExecutionException {
-        final File plexusJar = new 
File("src/test/jars/plexus-utils-1.4.1.jar");
-        final File shadedOutput = new 
File("target/foo-custom_testNoopWhenNotRelocated.jar");
+        File plexusJar = new File("src/test/jars/plexus-utils-1.4.1.jar");
+        File shadedOutput = new 
File("target/foo-custom_testNoopWhenNotRelocated.jar");
 
-        final Set<File> jars = new LinkedHashSet<>();
+        Set<File> jars = new LinkedHashSet<>();
         jars.add(new File("src/test/jars/test-project-1.0-SNAPSHOT.jar"));
         jars.add(plexusJar);
 
-        final Relocator relocator = new SimpleRelocator(
+        Relocator relocator = new SimpleRelocator(
                 "org/codehaus/plexus/util/cli",
                 "relocated/plexus/util/cli",
-                Collections.<String>emptyList(),
-                Collections.<String>emptyList());
+                Collections.emptyList(),
+                Collections.emptyList());
 
-        final ShadeRequest shadeRequest = new ShadeRequest();
+        ShadeRequest shadeRequest = new ShadeRequest();
         shadeRequest.setJars(jars);
         shadeRequest.setRelocators(Collections.singletonList(relocator));
-        
shadeRequest.setResourceTransformers(Collections.<ResourceTransformer>emptyList());
-        shadeRequest.setFilters(Collections.<Filter>emptyList());
+        shadeRequest.setResourceTransformers(Collections.emptyList());
+        shadeRequest.setFilters(Collections.emptyList());
         shadeRequest.setUberJar(shadedOutput);
 
-        final DefaultShader shader = newShader();
+        DefaultShader shader = newShader();
         shader.shade(shadeRequest);
 
-        try (final JarFile originalJar = new JarFile(plexusJar);
-                final JarFile shadedJar = new JarFile(shadedOutput)) {
+        try (JarFile originalJar = new JarFile(plexusJar);
+                JarFile shadedJar = new JarFile(shadedOutput)) {
             // ASM processes all class files. In doing so, it modifies them, 
even when not relocating anything.
             // Before MSHADE-391, the processed files were written to the uber 
JAR, which did no harm, but made it
             // difficult to find out by simple file comparison, if a file was 
actually relocated or not. Now, Shade
@@ -141,7 +142,7 @@ public class DefaultShaderTest {
                     "relocated/plexus/util/cli/Arg.class"));
         }
         int result = 0;
-        for (final String msg : debugMessages.getAllValues()) {
+        for (String msg : debugMessages.getAllValues()) {
             if ("Rewrote class bytecode: 
org/codehaus/plexus/util/cli/Arg.class".equals(msg)) {
                 result |= 1;
             } else if ("Keeping original class bytecode: 
org/codehaus/plexus/util/Expand.class".equals(msg)) {
@@ -153,15 +154,15 @@ public class DefaultShaderTest {
 
     @Test
     public void testOverlappingResourcesAreLogged() throws IOException, 
MojoExecutionException {
-        final DefaultShader shader = newShader();
+        DefaultShader shader = newShader();
 
         // we will shade two jars and expect to see META-INF/MANIFEST.MF 
overlaps, this will always be true
         // but this can lead to a broken deployment if intended for OSGi or 
so, so even this should be logged
-        final Set<File> set = new LinkedHashSet<>();
+        Set<File> set = new LinkedHashSet<>();
         set.add(new File("src/test/jars/test-project-1.0-SNAPSHOT.jar"));
         set.add(new File("src/test/jars/plexus-utils-1.4.1.jar"));
 
-        final ShadeRequest shadeRequest = new ShadeRequest();
+        ShadeRequest shadeRequest = new ShadeRequest();
         shadeRequest.setJars(set);
         shadeRequest.setRelocators(Collections.<Relocator>emptyList());
         
shadeRequest.setResourceTransformers(Collections.<ResourceTransformer>emptyList());
@@ -215,9 +216,9 @@ public class DefaultShaderTest {
 
             ShadeRequest shadeRequest = new ShadeRequest();
             shadeRequest.setJars(set);
-            shadeRequest.setRelocators(Collections.<Relocator>emptyList());
-            
shadeRequest.setResourceTransformers(Collections.<ResourceTransformer>singletonList(transformer));
-            shadeRequest.setFilters(Collections.<Filter>emptyList());
+            shadeRequest.setRelocators(Collections.emptyList());
+            
shadeRequest.setResourceTransformers(Collections.singletonList(transformer));
+            shadeRequest.setFilters(Collections.emptyList());
             shadeRequest.setUberJar(new 
File("target/foo-custom_testOverlappingResourcesAreLogged.jar"));
 
             DefaultShader shaderWithTransformer = newShader();
@@ -226,7 +227,7 @@ public class DefaultShaderTest {
             assertThat(warnMessages.getAllValues().size(), is(0));
 
             DefaultShader shaderWithoutTransformer = newShader();
-            
shadeRequest.setResourceTransformers(Collections.<ResourceTransformer>emptyList());
+            shadeRequest.setResourceTransformers(Collections.emptyList());
             shaderWithoutTransformer.shade(shadeRequest);
 
             assertThat(
@@ -292,33 +293,33 @@ public class DefaultShaderTest {
 
     @Test
     public void testHandleDirectory() throws Exception {
-        final File dir = tmp.getRoot();
+        final File dir = TEMPORARY_FOLDER.getRoot();
         // explode src/test/jars/test-artifact-1.0-SNAPSHOT.jar in this temp 
dir
-        try (final JarInputStream in =
-                new JarInputStream(new 
FileInputStream("src/test/jars/test-artifact-1.0-SNAPSHOT.jar"))) {
+        try (JarInputStream in =
+                new 
JarInputStream(Files.newInputStream(Paths.get("src/test/jars/test-artifact-1.0-SNAPSHOT.jar"))))
 {
             JarEntry nextJarEntry;
             while ((nextJarEntry = in.getNextJarEntry()) != null) {
                 if (nextJarEntry.isDirectory()) {
                     continue;
                 }
-                final File out = new File(dir, nextJarEntry.getName());
+                File out = new File(dir, nextJarEntry.getName());
                 forceMkdir(out.getParentFile());
-                try (final OutputStream outputStream = new 
FileOutputStream(out)) {
+                try (OutputStream outputStream = 
Files.newOutputStream(out.toPath())) {
                     IOUtil.copy(in, outputStream, (int) 
Math.max(nextJarEntry.getSize(), 512));
                 }
             }
         }
 
         // do shade
-        final File shade = new File("target/testHandleDirectory.jar");
+        File shade = new File("target/testHandleDirectory.jar");
         shaderWithPattern("org/shaded/plexus/util", shade, new String[0], 
singleton(dir));
 
         // ensure directory was shaded properly
-        try (final JarFile jar = new JarFile(shade)) {
-            final List<String> entries = new ArrayList<>();
-            final Enumeration<JarEntry> jarEntryEnumeration = jar.entries();
+        try (JarFile jar = new JarFile(shade)) {
+            List<String> entries = new ArrayList<>();
+            Enumeration<JarEntry> jarEntryEnumeration = jar.entries();
             while (jarEntryEnumeration.hasMoreElements()) {
-                final JarEntry jarEntry = jarEntryEnumeration.nextElement();
+                JarEntry jarEntry = jarEntryEnumeration.nextElement();
                 if (jarEntry.isDirectory()) {
                     continue;
                 }
@@ -346,8 +347,8 @@ public class DefaultShaderTest {
 
         List<Relocator> relocators = new ArrayList<>();
 
-        relocators.add(new SimpleRelocator(
-                "org/codehaus/plexus/util/", "_plexus/util/__", null, 
Collections.<String>emptyList()));
+        relocators.add(
+                new SimpleRelocator("org/codehaus/plexus/util/", 
"_plexus/util/__", null, Collections.emptyList()));
 
         List<ResourceTransformer> resourceTransformers = new ArrayList<>();
 
@@ -373,8 +374,8 @@ public class DefaultShaderTest {
             assertEquals("", c.getMethod("clean", String.class).invoke(o, 
(String) null));
 
             // now, check that its source file was rewritten:
-            final String[] source = {null};
-            final ClassReader classReader = new 
ClassReader(cl.getResourceAsStream("_plexus/util/__StringUtils.class"));
+            String[] source = {null};
+            ClassReader classReader = new 
ClassReader(cl.getResourceAsStream("_plexus/util/__StringUtils.class"));
             classReader.accept(
                     new ClassVisitor(Opcodes.ASM4) {
                         @Override
@@ -448,9 +449,9 @@ public class DefaultShaderTest {
 
         ShadeRequest shadeRequest = new ShadeRequest();
         shadeRequest.setJars(new 
LinkedHashSet<>(Collections.singleton(outerJar)));
-        shadeRequest.setFilters(new ArrayList<Filter>());
-        shadeRequest.setRelocators(new ArrayList<Relocator>());
-        shadeRequest.setResourceTransformers(new 
ArrayList<ResourceTransformer>());
+        shadeRequest.setFilters(new ArrayList<>());
+        shadeRequest.setRelocators(new ArrayList<>());
+        shadeRequest.setResourceTransformers(new ArrayList<>());
         File shadedFile = temporaryFolder.newFile("shaded.jar");
         shadeRequest.setUberJar(shadedFile);
 
@@ -522,7 +523,7 @@ public class DefaultShaderTest {
 
         temporaryFolder.create();
         File innerJar = temporaryFolder.newFile(innerJarFileName);
-        try (JarOutputStream jos = new JarOutputStream(new 
FileOutputStream(innerJar))) {
+        try (JarOutputStream jos = new 
JarOutputStream(Files.newOutputStream(innerJar.toPath()))) {
             jos.putNextEntry(new JarEntry("foo.txt"));
             byte[] bytes = "c1".getBytes(StandardCharsets.UTF_8);
             len = bytes.length;
@@ -532,9 +533,9 @@ public class DefaultShaderTest {
 
         ShadeRequest shadeRequest = new ShadeRequest();
         shadeRequest.setJars(new 
LinkedHashSet<>(Collections.singleton(innerJar)));
-        shadeRequest.setFilters(new ArrayList<Filter>());
-        shadeRequest.setRelocators(new ArrayList<Relocator>());
-        shadeRequest.setResourceTransformers(new 
ArrayList<ResourceTransformer>());
+        shadeRequest.setFilters(new ArrayList<>());
+        shadeRequest.setRelocators(new ArrayList<>());
+        shadeRequest.setResourceTransformers(new ArrayList<>());
         File shadedFile = temporaryFolder.newFile("shaded.jar");
         shadeRequest.setUberJar(shadedFile);
 
@@ -620,9 +621,9 @@ public class DefaultShaderTest {
 
     private boolean areEqual(final JarFile jar1, final JarFile jar2, final 
String entry1, String entry2)
             throws IOException {
-        try (final InputStream s1 = jar1.getInputStream(
+        try (InputStream s1 = jar1.getInputStream(
                         requireNonNull(jar1.getJarEntry(entry1), entry1 + " in 
" + jar1.getName()));
-                final InputStream s2 = jar2.getInputStream(
+                InputStream s2 = jar2.getInputStream(
                         requireNonNull(jar2.getJarEntry(entry2), entry2 + " in 
" + jar2.getName()))) {
             return Arrays.equals(IOUtil.toByteArray(s1), 
IOUtil.toByteArray(s2));
         }
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java
 
b/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java
index 0d5968d..9f7c29d 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java
@@ -183,7 +183,7 @@ public class SimpleRelocatorTest {
         
assertTrue(relocator.canRelocatePath("META-INF/maven/com-foo-bar/artifactId/pom.xml"));
     }
 
-    private static final String sourceFile = "package 
org.apache.maven.hello;\n" + "package org.objectweb.asm;\n"
+    private static final String SOURCE_FILE = "package 
org.apache.maven.hello;\n" + "package org.objectweb.asm;\n"
             + "\n"
             + "import foo.bar.Bar;\n"
             + "import zot.baz.Baz;\n"
@@ -216,7 +216,7 @@ public class SimpleRelocatorTest {
             + "  }\n"
             + "}\n";
 
-    private static final String relocatedFile = "package 
com.acme.maven.hello;\n" + "package aj.org.objectweb.asm;\n"
+    private static final String RELOCATED_FILE = "package 
com.acme.maven.hello;\n" + "package aj.org.objectweb.asm;\n"
             + "\n"
             + "import foo.bar.Bar;\n"
             + "import zot.baz.Baz;\n"
@@ -257,7 +257,7 @@ public class SimpleRelocatorTest {
                 Arrays.asList("foo.bar", "zot.baz"),
                 Arrays.asList("irrelevant.exclude", 
"org.apache.maven.exclude1", "org.apache.maven.sub.exclude2"),
                 true);
-        assertEquals(sourceFile, relocator.applyToSourceContent(sourceFile));
+        assertEquals(SOURCE_FILE, relocator.applyToSourceContent(SOURCE_FILE));
     }
 
     @Test
@@ -275,8 +275,8 @@ public class SimpleRelocatorTest {
         // Make sure not to replace 'foo' package by path-like 'shaded/foo'
         SimpleRelocator fooRelocator = new SimpleRelocator("foo", 
"shaded.foo", null, Arrays.asList("foo.bar"));
         assertEquals(
-                relocatedFile,
+                RELOCATED_FILE,
                 
fooRelocator.applyToSourceContent(asmRelocator.applyToSourceContent(
-                        
ioRelocator.applyToSourceContent(relocator.applyToSourceContent(sourceFile)))));
+                        
ioRelocator.applyToSourceContent(relocator.applyToSourceContent(SOURCE_FILE)))));
     }
 }
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
index 48821ff..ed14ed2 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
@@ -85,8 +85,8 @@ public class ManifestResourceTransformerTest {
 
         final ByteArrayOutputStream out = transform(manifest, relocators);
 
-        try (final JarInputStream jis = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
-            final Attributes attrs = jis.getManifest().getMainAttributes();
+        try (JarInputStream jis = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
+            Attributes attrs = jis.getManifest().getMainAttributes();
             assertEquals(
                     
"jakarta.decorator;version=\"2.0\";uses:=\"jakarta.enterprise.inject\","
                             + 
"jakarta.enterprise.context;version=\"2.0\";uses:=\"jakarta.enterprise.util,"
@@ -131,22 +131,22 @@ public class ManifestResourceTransformerTest {
         
transformer.setAdditionalAttributes(Arrays.asList("description-custom", 
"attribute-unknown"));
         final ByteArrayOutputStream out = transform(manifest, relocators);
 
-        try (final JarInputStream jis = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
-            final Attributes attrs = jis.getManifest().getMainAttributes();
+        try (JarInputStream jis = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
+            Attributes attrs = jis.getManifest().getMainAttributes();
             assertEquals("This jar uses jakarta packages", 
attrs.getValue("description-custom"));
         }
     }
 
     private ByteArrayOutputStream transform(final Manifest manifest, 
List<Relocator> relocators) throws IOException {
         final ByteArrayOutputStream mboas = new ByteArrayOutputStream();
-        try (final OutputStream mos = mboas) {
+        try (OutputStream mos = mboas) {
             manifest.write(mos);
         }
         transformer.processResource(
                 JarFile.MANIFEST_NAME, new 
ByteArrayInputStream(mboas.toByteArray()), relocators, 0);
 
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
-        try (final JarOutputStream jarOutputStream = new JarOutputStream(out)) 
{
+        try (JarOutputStream jarOutputStream = new JarOutputStream(out)) {
             transformer.modifyOutputStream(jarOutputStream);
         }
         return out;
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
index 693ba49..dd0e80e 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
@@ -44,9 +44,9 @@ import static org.junit.Assert.assertTrue;
  * Test for handling META-INF/service/...
  */
 public class ServiceResourceTransformerTest {
-    private final String NEWLINE = "\n";
+    private final String newline = "\n";
 
-    private List<Relocator> relocators = new ArrayList<Relocator>();
+    private final List<Relocator> relocators = new ArrayList<>();
 
     @Test
     public void relocatedClasses() throws Exception {
@@ -76,7 +76,7 @@ public class ServiceResourceTransformerTest {
             assertNotNull(jarEntry);
             try (InputStream entryStream = jarFile.getInputStream(jarEntry)) {
                 String xformedContent = IOUtils.toString(entryStream, "utf-8");
-                assertEquals("borg.foo.Service" + NEWLINE + 
"org.foo.exclude.OtherService" + NEWLINE, xformedContent);
+                assertEquals("borg.foo.Service" + newline + 
"org.foo.exclude.OtherService" + newline, xformedContent);
             } finally {
                 jarFile.close();
             }
@@ -91,8 +91,8 @@ public class ServiceResourceTransformerTest {
                 new SimpleRelocator("org.foo", "borg.foo", null, 
Collections.singletonList("org.foo.exclude.*"));
         relocators.add(relocator);
 
-        String content = "org.foo.Service" + NEWLINE + 
"org.foo.exclude.OtherService" + NEWLINE;
-        String contentShaded = "borg.foo.Service" + NEWLINE + 
"org.foo.exclude.OtherService" + NEWLINE;
+        String content = "org.foo.Service" + newline + 
"org.foo.exclude.OtherService" + newline;
+        String contentShaded = "borg.foo.Service" + newline + 
"org.foo.exclude.OtherService" + newline;
         byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8);
         String contentResource = "META-INF/services/org.foo.something.another";
         String contentResourceShaded = 
"META-INF/services/borg.foo.something.another";
@@ -154,7 +154,7 @@ public class ServiceResourceTransformerTest {
             assertNotNull(jarEntry);
             try (InputStream entryStream = jarFile.getInputStream(jarEntry)) {
                 String xformedContent = IOUtils.toString(entryStream, 
StandardCharsets.UTF_8);
-                assertEquals("org.eclipse1234.osgi.launch.EquinoxFactory" + 
NEWLINE, xformedContent);
+                assertEquals("org.eclipse1234.osgi.launch.EquinoxFactory" + 
newline, xformedContent);
             } finally {
                 jarFile.close();
             }
diff --git 
a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java
 
b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java
index afcba14..a566658 100644
--- 
a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java
+++ 
b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java
@@ -52,22 +52,22 @@ import static org.junit.Assert.fail;
 
 public class TransformerTesterRule implements TestRule {
     @Override
-    public Statement apply(final Statement base, final Description 
description) {
+    public Statement apply(Statement base, Description description) {
         return new Statement() {
             @Override
             public void evaluate() throws Throwable {
-                final TransformerTest spec = 
description.getAnnotation(TransformerTest.class);
+                TransformerTest spec = 
description.getAnnotation(TransformerTest.class);
                 if (spec == null) {
                     base.evaluate();
                     return;
                 }
 
-                final Map<String, String> jar;
+                Map<String, String> jar;
                 try {
-                    final ReproducibleResourceTransformer transformer = 
createTransformer(spec);
+                    ReproducibleResourceTransformer transformer = 
createTransformer(spec);
                     visit(spec, transformer);
                     jar = captureOutput(transformer);
-                } catch (final Exception ex) {
+                } catch (Exception ex) {
                     if 
(Exception.class.isAssignableFrom(spec.expectedException())) {
                         assertTrue(
                                 ex.getClass().getName(),
@@ -82,7 +82,7 @@ public class TransformerTesterRule implements TestRule {
         };
     }
 
-    private void asserts(final TransformerTest spec, final Map<String, String> 
jar) {
+    private void asserts(TransformerTest spec, Map<String, String> jar) {
         if (spec.strictMatch() && jar.size() != spec.expected().length) {
             fail("Strict match test failed: " + jar);
         }
@@ -95,14 +95,14 @@ public class TransformerTesterRule implements TestRule {
         }
     }
 
-    private Map<String, String> captureOutput(final 
ReproducibleResourceTransformer transformer) throws IOException {
-        final ByteArrayOutputStream out = new ByteArrayOutputStream();
-        try (final JarOutputStream jar = new JarOutputStream(out)) {
+    private Map<String, String> captureOutput(ReproducibleResourceTransformer 
transformer) throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try (JarOutputStream jar = new JarOutputStream(out)) {
             transformer.modifyOutputStream(jar);
         }
 
-        final Map<String, String> created = new HashMap<>();
-        try (final JarInputStream jar = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
+        Map<String, String> created = new HashMap<>();
+        try (JarInputStream jar = new JarInputStream(new 
ByteArrayInputStream(out.toByteArray()))) {
             JarEntry entry;
             while ((entry = jar.getNextJarEntry()) != null) {
                 created.put(entry.getName(), read(jar));
@@ -111,9 +111,8 @@ public class TransformerTesterRule implements TestRule {
         return created;
     }
 
-    private void visit(final TransformerTest spec, final 
ReproducibleResourceTransformer transformer)
-            throws IOException {
-        for (final Resource resource : spec.visited()) {
+    private void visit(TransformerTest spec, ReproducibleResourceTransformer 
transformer) throws IOException {
+        for (Resource resource : spec.visited()) {
             if (transformer.canTransformResource(resource.path())) {
                 transformer.processResource(
                         resource.path(),
@@ -124,9 +123,9 @@ public class TransformerTesterRule implements TestRule {
         }
     }
 
-    private String read(final JarInputStream jar) throws IOException {
-        final StringBuilder builder = new StringBuilder();
-        final byte[] buffer = new byte[512];
+    private String read(JarInputStream jar) throws IOException {
+        StringBuilder builder = new StringBuilder();
+        byte[] buffer = new byte[512];
         int read;
         while ((read = jar.read(buffer)) >= 0) {
             builder.append(new String(buffer, 0, read));
@@ -134,22 +133,22 @@ public class TransformerTesterRule implements TestRule {
         return builder.toString();
     }
 
-    private ReproducibleResourceTransformer createTransformer(final 
TransformerTest spec) {
-        final ConverterLookup lookup = new DefaultConverterLookup();
+    private ReproducibleResourceTransformer createTransformer(TransformerTest 
spec) {
+        ConverterLookup lookup = new DefaultConverterLookup();
         try {
-            final ConfigurationConverter converter = 
lookup.lookupConverterForType(spec.transformer());
-            final PlexusConfiguration configuration = new 
DefaultPlexusConfiguration("configuration");
-            for (final Property property : spec.configuration()) {
+            ConfigurationConverter converter = 
lookup.lookupConverterForType(spec.transformer());
+            PlexusConfiguration configuration = new 
DefaultPlexusConfiguration("configuration");
+            for (Property property : spec.configuration()) {
                 configuration.addChild(property.name(), property.value());
             }
-            return 
ReproducibleResourceTransformer.class.cast(converter.fromConfiguration(
+            return (ReproducibleResourceTransformer) 
converter.fromConfiguration(
                     lookup,
                     configuration,
                     spec.transformer(),
                     spec.transformer(),
                     Thread.currentThread().getContextClassLoader(),
-                    new DefaultExpressionEvaluator()));
-        } catch (final ComponentConfigurationException e) {
+                    new DefaultExpressionEvaluator());
+        } catch (ComponentConfigurationException e) {
             throw new IllegalStateException(e);
         }
     }

Reply via email to