[Japi-cvs] SF.net SVN: japi: [515] libs
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-07-07 09:54:42
|
Revision: 515 http://svn.sourceforge.net/japi/?rev=515&view=rev Author: christianhujer Date: 2007-07-07 02:54:41 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Updated Copier and Forwarder to match new code conventions / warnings policy. Modified Paths: -------------- libs/io/trunk/src/net/sf/japi/io/Copier.java libs/net/trunk/src/net/sf/japi/net/Forwarder.java Modified: libs/io/trunk/src/net/sf/japi/io/Copier.java =================================================================== --- libs/io/trunk/src/net/sf/japi/io/Copier.java 2007-07-07 09:49:53 UTC (rev 514) +++ libs/io/trunk/src/net/sf/japi/io/Copier.java 2007-07-07 09:54:41 UTC (rev 515) @@ -21,12 +21,12 @@ package net.sf.japi.io; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.IOException; /** A Runnable that copies from an InputStream to an OutputStream. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class Copier implements Runnable { Modified: libs/net/trunk/src/net/sf/japi/net/Forwarder.java =================================================================== --- libs/net/trunk/src/net/sf/japi/net/Forwarder.java 2007-07-07 09:49:53 UTC (rev 514) +++ libs/net/trunk/src/net/sf/japi/net/Forwarder.java 2007-07-07 09:54:41 UTC (rev 515) @@ -21,33 +21,34 @@ package net.sf.japi.net; +import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; -import java.io.IOException; import net.sf.japi.io.Copier; /** This class forwards incoming TCP connections to another host and port. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class Forwarder implements Runnable { /** Main program. * @param args command line arguments (currently ignored) + * @throws IOException In case of I/O problems. */ public static void main(final String... args) throws IOException { - ServerSocket serverSocket = null; - serverSocket = new ServerSocket(Integer.parseInt(args[0])); + final ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[0])); + //noinspection InfiniteLoopStatement while (true) { final Socket server = serverSocket.accept(); - Socket client = null; try { - client = new Socket(args[1], Integer.parseInt(args[2])); + final Socket client = new Socket(args[1], Integer.parseInt(args[2])); new Forwarder(client, server).start(); } catch (final IOException e) { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { server.close(); } catch (final Exception ignore) { /* ignore */ } - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { client.close(); } catch (final Exception ignore) { /* ignore */ } + try { + server.close(); + } catch (final IOException ignore) { + /* ignore */ + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |