You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by eb...@apache.org on 2019/03/05 01:03:29 UTC

svn commit: r1854807 - in /tomcat/maven-plugin/trunk: tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/ tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/

Author: ebourg
Date: Tue Mar  5 01:03:29 2019
New Revision: 1854807

URL: http://svn.apache.org/viewvc?rev=1854807&view=rev
Log:
Java 7 syntax

Modified:
    tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java
    tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java
    tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
    tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java

Modified: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java?rev=1854807&r1=1854806&r2=1854807&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java Tue Mar  5 01:03:29 2019
@@ -590,17 +590,17 @@ public abstract class AbstractExecWarMoj
 
     }
 
-    protected String[] toStringArray( List list )
+    protected String[] toStringArray( List<String> list )
     {
         if ( list == null || list.isEmpty() )
         {
             return new String[0];
         }
-        List<String> res = new ArrayList<String>( list.size() );
+        List<String> res = new ArrayList<>( list.size() );
 
-        for ( Iterator ite = list.iterator(); ite.hasNext(); )
+        for ( String s : list )
         {
-            res.add( (String) ite.next() );
+            res.add( s );
         }
         return res.toArray( new String[res.size()] );
     }

Modified: tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java?rev=1854807&r1=1854806&r2=1854807&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java Tue Mar  5 01:03:29 2019
@@ -325,7 +325,7 @@ public class RunMojo
 
             final List<String> jarPaths = extractJars( classLoaderEntries );
 
-            List<URL> urls = new ArrayList<URL>( jarPaths.size() );
+            List<URL> urls = new ArrayList<>( jarPaths.size() );
 
             for ( String jarPath : jarPaths )
             {
@@ -411,8 +411,8 @@ public class RunMojo
                         {
                             Enumeration<URL> enumeration =
                                 urlClassLoader.findResources( StringUtils.removeStart( path, "/" ) );
-                            List<URL> urlsFound = new ArrayList<URL>();
-                            List<WebResource> webResources = new ArrayList<WebResource>();
+                            List<URL> urlsFound = new ArrayList<>();
+                            List<WebResource> webResources = new ArrayList<>();
                             while ( enumeration.hasMoreElements() )
                             {
                                 URL url = enumeration.nextElement();
@@ -439,7 +439,7 @@ public class RunMojo
                     {
                         try
                         {
-                            List<WebResource> webResources = new ArrayList<WebResource>();
+                            List<WebResource> webResources = new ArrayList<>();
 
                             for ( String directory : directories )
                             {
@@ -610,14 +610,14 @@ public class RunMojo
                         if ( StringUtils.equalsIgnoreCase( "/WEB-INF/lib/", path ) )
                         {
                             // adding outputDirectory as well?
-                            return new HashSet<String>( jarPaths );
+                            return new HashSet<>( jarPaths );
                         }
 
                         File filePath = new File( getWarSourceDirectory(), path );
 
                         if ( filePath.isDirectory() )
                         {
-                            Set<String> paths = new HashSet<String>();
+                            Set<String> paths = new HashSet<>();
 
                             String[] files = filePath.list();
                             if ( files == null )
@@ -682,7 +682,7 @@ public class RunMojo
         throws MojoExecutionException
     {
 
-        List<String> jarPaths = new ArrayList<String>();
+        List<String> jarPaths = new ArrayList<>();
 
         try
         {

Modified: tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java?rev=1854807&r1=1854806&r2=1854807&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java (original)
+++ tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java Tue Mar  5 01:03:29 2019
@@ -107,7 +107,7 @@ public class PasswordUtil
             if ( obj instanceof String )
             {
                 String key = (String) obj;
-                String value = (String) props.getProperty( key );
+                String value = props.getProperty( key );
                 if ( value != null && value.startsWith( __OBFUSCATE ) )
                 {
                     System.setProperty( key, deobfuscate( value ) );

Modified: tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java?rev=1854807&r1=1854806&r2=1854807&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java (original)
+++ tomcat/maven-plugin/trunk/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java Tue Mar  5 01:03:29 2019
@@ -124,7 +124,7 @@ public class Tomcat8Runner
     /**
      * key = context of the webapp, value = war path on file system
      */
-    Map<String, String> webappWarPerContext = new HashMap<String, String>();
+    Map<String, String> webappWarPerContext = new HashMap<>();
 
     public Tomcat8Runner()
     {
@@ -789,38 +789,25 @@ public class Tomcat8Runner
         }
     }
 
-    private Properties loadProperties( File file )
-        throws FileNotFoundException, IOException
+    private Properties loadProperties( File file ) throws IOException
     {
         Properties properties = new Properties();
         if ( file.exists() )
         {
-
-            FileInputStream fileInputStream = new FileInputStream( file );
-            try
-            {
-                properties.load( fileInputStream );
-            }
-            finally
+            try (FileInputStream fileInputStream = new FileInputStream(file))
             {
-                fileInputStream.close();
+                properties.load(fileInputStream);
             }
 
         }
         return properties;
     }
 
-    private void saveProperties( Properties properties, File file )
-        throws FileNotFoundException, IOException
+    private void saveProperties( Properties properties, File file ) throws IOException
     {
-        FileOutputStream fileOutputStream = new FileOutputStream( file );
-        try
-        {
-            properties.store( fileOutputStream, "Timestamp file for executable war/jar" );
-        }
-        finally
+        try (FileOutputStream fileOutputStream = new FileOutputStream(file))
         {
-            fileOutputStream.close();
+            properties.store(fileOutputStream, "Timestamp file for executable war/jar");
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org