Java 7 syntax
git-svn-id: https://svn.apache.org/repos/asf/tomcat/maven-plugin/trunk@1854807 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java
index 1a2d64e..64262ec 100644
--- a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java
+++ b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/AbstractExecWarMojo.java
@@ -590,17 +590,17 @@
}
- 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()] );
}
diff --git a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java
index e141ef4..e4e4040 100644
--- a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java
+++ b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/run/RunMojo.java
@@ -325,7 +325,7 @@
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 @@
{
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 @@
{
try
{
- List<WebResource> webResources = new ArrayList<WebResource>();
+ List<WebResource> webResources = new ArrayList<>();
for ( String directory : directories )
{
@@ -610,14 +610,14 @@
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 @@
throws MojoExecutionException
{
- List<String> jarPaths = new ArrayList<String>();
+ List<String> jarPaths = new ArrayList<>();
try
{
diff --git a/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java b/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
index d70dee8..b32f4eb 100644
--- a/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
+++ b/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/PasswordUtil.java
@@ -107,7 +107,7 @@
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 ) );
diff --git a/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java b/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
index 0ccd4a2..48f7ffd 100644
--- a/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
+++ b/tomcat8-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat8Runner.java
@@ -124,7 +124,7 @@
/**
* 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 @@
}
}
- 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
+ try (FileInputStream fileInputStream = new FileInputStream(file))
{
- properties.load( fileInputStream );
- }
- finally
- {
- 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
+ try (FileOutputStream fileOutputStream = new FileOutputStream(file))
{
- properties.store( fileOutputStream, "Timestamp file for executable war/jar" );
- }
- finally
- {
- fileOutputStream.close();
+ properties.store(fileOutputStream, "Timestamp file for executable war/jar");
}
}
}