Author: baerrach Date: Wed Sep 21 23:27:39 2011 New Revision: 1173902 URL: http://svn.apache.org/viewvc?rev=1173902&view=rev Log: [MECLIPSE-696] Added catch of SocketException which can happend when additional config file is a URL. Fixed finally block to use IOUtil.close() instead of stream.close (which throws exceptions and was not handled correctly in the out catch block. Added EclipsePlugin.socketexception to messages
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java maven/plugins/trunk/maven-eclipse-plugin/src/main/resources/org/apache/maven/plugin/eclipse/messages.properties Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?rev=1173902&r1=1173901&r2=1173902&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java Wed Sep 21 23:27:39 2011 @@ -23,6 +23,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.SocketException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -1236,6 +1237,7 @@ public class EclipsePlugin } else { + // TODO: [MECLIPSE-696] Note: This fails behind a firewall for testProject44 inStream = file.getURL().openConnection().getInputStream(); } OutputStream outStream = new FileOutputStream( projectRelativeFile ); @@ -1245,8 +1247,8 @@ public class EclipsePlugin } finally { - inStream.close(); - outStream.close(); + IOUtil.close(inStream); + IOUtil.close(outStream); } } else @@ -1254,6 +1256,11 @@ public class EclipsePlugin FileUtils.fileWrite( projectRelativeFile.getAbsolutePath(), file.getContent() ); } } + catch ( SocketException e ) { + throw new MojoExecutionException(Messages.getString("EclipsePlugin.socketexception", //$NON-NLS-1$ + new Object[] { file.getURL(), + e.getMessage() })); + } catch ( IOException e ) { throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantwritetofile", //$NON-NLS-1$ Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/resources/org/apache/maven/plugin/eclipse/messages.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/resources/org/apache/maven/plugin/eclipse/messages.properties?rev=1173902&r1=1173901&r2=1173902&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/resources/org/apache/maven/plugin/eclipse/messages.properties (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/resources/org/apache/maven/plugin/eclipse/messages.properties Wed Sep 21 23:27:39 2011 @@ -21,6 +21,7 @@ EclipsePlugin.workspace=Using Eclipse Wo EclipsePlugin.cantcanonicalize=Can't canonicalize system path: {0} EclipsePlugin.unchangedmanifest=Not writing Manifest file as it is unchanged: {0} EclipsePlugin.invalidvminworkspace=Workspace defines a VM that does not contain a valid jre/lib/rt.jar: {0} +EclipsePlugin.socketexception=Unable to retrieve remote resource {0}: {1} EclipseSettingsWriter.wrotesettings=Wrote settings to {0} EclipseSettingsWriter.cannotcreatesettings=Cannot create settings file