From 24c69a26eaa3a21cbd51a02de24724b49fb4100e Mon Sep 17 00:00:00 2001 From: mihi <mihi> Date: Wed, 14 Apr 2004 23:26:59 +0000 Subject: [PATCH] untabify [mihi] --- apps/tests/EchoServer.java | 40 +++---- apps/tests/GuaranteedBug.java | 158 +++++++++++++------------- apps/tests/echotester/EchoTester.java | 2 +- 3 files changed, 100 insertions(+), 100 deletions(-) diff --git a/apps/tests/EchoServer.java b/apps/tests/EchoServer.java index 45a6d05444..1ffe8f2e35 100644 --- a/apps/tests/EchoServer.java +++ b/apps/tests/EchoServer.java @@ -12,33 +12,33 @@ import java.net.*; public class EchoServer extends Thread { public static void main(String[] args) throws IOException { - ServerSocket ss = new ServerSocket(Integer.parseInt(args[0])); - while (true) { - Socket s = ss.accept(); - new EchoServer(s); - } + ServerSocket ss = new ServerSocket(Integer.parseInt(args[0])); + while (true) { + Socket s = ss.accept(); + new EchoServer(s); + } } private Socket s; public EchoServer(Socket s) { - this.s=s; - start(); + this.s=s; + start(); } public void run() { - try { - InputStream in = s.getInputStream(); - OutputStream out = s.getOutputStream(); - byte[] b = new byte[4096]; - int len; - while ((len = in.read(b)) != -1) { - out.write(b, 0, len); - } - } catch (SocketException ex) { - // nothing - } catch (IOException ex) { - ex.printStackTrace(); - } + try { + InputStream in = s.getInputStream(); + OutputStream out = s.getOutputStream(); + byte[] b = new byte[4096]; + int len; + while ((len = in.read(b)) != -1) { + out.write(b, 0, len); + } + } catch (SocketException ex) { + // nothing + } catch (IOException ex) { + ex.printStackTrace(); + } } } diff --git a/apps/tests/GuaranteedBug.java b/apps/tests/GuaranteedBug.java index 5acf937c0d..147b845267 100644 --- a/apps/tests/GuaranteedBug.java +++ b/apps/tests/GuaranteedBug.java @@ -10,97 +10,97 @@ public class GuaranteedBug { public void reproduce() { - try { - Destination d1 = null; - // first client (receiver) - if (true) { // smaller scope for variables ... - I2PClient client = I2PClientFactory.createClient(); - ByteArrayOutputStream keyStream = - new ByteArrayOutputStream(512); - d1 = client.createDestination(keyStream); - ByteArrayInputStream in = - new ByteArrayInputStream(keyStream.toByteArray()); - Properties opts = new Properties(); - opts.setProperty(I2PClient.PROP_RELIABILITY, - I2PClient.PROP_RELIABILITY_GUARANTEED); - opts.setProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); - opts.setProperty(I2PClient.PROP_TCP_PORT, "7654"); - I2PSession session = client.createSession(in, opts); - session.connect(); - session.setSessionListener(new PacketCounter()); - } - // second client (sender) - I2PClient client = I2PClientFactory.createClient(); - ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512); - Destination d2 = client.createDestination(keyStream); - ByteArrayInputStream in = - new ByteArrayInputStream(keyStream.toByteArray()); - Properties opts = new Properties(); - opts.setProperty(I2PClient.PROP_RELIABILITY, - I2PClient.PROP_RELIABILITY_GUARANTEED); - opts.setProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); - opts.setProperty(I2PClient.PROP_TCP_PORT, "7654"); - I2PSession session = client.createSession(in, opts); - session.connect(); - session.setSessionListener(new DummyListener()); - for (int i=0;i<1000; i++) { - byte[] msg = (""+i).getBytes("ISO-8859-1"); - session.sendMessage(d1,msg); - System.out.println(">>"+i); - } - } catch (IOException ex) { - ex.printStackTrace(); - } catch (I2PException ex) { - ex.printStackTrace(); - } + try { + Destination d1 = null; + // first client (receiver) + if (true) { // smaller scope for variables ... + I2PClient client = I2PClientFactory.createClient(); + ByteArrayOutputStream keyStream = + new ByteArrayOutputStream(512); + d1 = client.createDestination(keyStream); + ByteArrayInputStream in = + new ByteArrayInputStream(keyStream.toByteArray()); + Properties opts = new Properties(); + opts.setProperty(I2PClient.PROP_RELIABILITY, + I2PClient.PROP_RELIABILITY_GUARANTEED); + opts.setProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); + opts.setProperty(I2PClient.PROP_TCP_PORT, "7654"); + I2PSession session = client.createSession(in, opts); + session.connect(); + session.setSessionListener(new PacketCounter()); + } + // second client (sender) + I2PClient client = I2PClientFactory.createClient(); + ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512); + Destination d2 = client.createDestination(keyStream); + ByteArrayInputStream in = + new ByteArrayInputStream(keyStream.toByteArray()); + Properties opts = new Properties(); + opts.setProperty(I2PClient.PROP_RELIABILITY, + I2PClient.PROP_RELIABILITY_GUARANTEED); + opts.setProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1"); + opts.setProperty(I2PClient.PROP_TCP_PORT, "7654"); + I2PSession session = client.createSession(in, opts); + session.connect(); + session.setSessionListener(new DummyListener()); + for (int i=0;i<1000; i++) { + byte[] msg = (""+i).getBytes("ISO-8859-1"); + session.sendMessage(d1,msg); + System.out.println(">>"+i); + } + } catch (IOException ex) { + ex.printStackTrace(); + } catch (I2PException ex) { + ex.printStackTrace(); + } } public static void main(String[] args) { - new GuaranteedBug().reproduce(); + new GuaranteedBug().reproduce(); } // ------------------------------------------------------- public class DummyListener implements I2PSessionListener { - public void disconnected(I2PSession session) { - System.err.println("Disconnected: "+session); - } + public void disconnected(I2PSession session) { + System.err.println("Disconnected: "+session); + } - public void errorOccurred(I2PSession session, String message, - Throwable error) { - System.err.println("Error: "+session+"/"+message); - error.printStackTrace(); - } + public void errorOccurred(I2PSession session, String message, + Throwable error) { + System.err.println("Error: "+session+"/"+message); + error.printStackTrace(); + } - public void messageAvailable(I2PSession session, int msgId, - long size) { - System.err.println("Message here? "+session); - } + public void messageAvailable(I2PSession session, int msgId, + long size) { + System.err.println("Message here? "+session); + } - public void reportAbuse(I2PSession session, int severity) { - System.err.println("Abuse: "+severity+"/"+session); - } + public void reportAbuse(I2PSession session, int severity) { + System.err.println("Abuse: "+severity+"/"+session); + } } public class PacketCounter extends DummyListener { - private int lastPacket = -1; - public void messageAvailable(I2PSession session, int msgId, - long size) { - try { - byte msg[] = session.receiveMessage(msgId); - String m = new String(msg, "ISO-8859-1"); - int no = Integer.parseInt(m); - if (no != ++lastPacket) { - System.out.println("ERROR: <<"+no); - } else { - System.out.println("<<"+no); - } - } catch (NumberFormatException ex) { - ex.printStackTrace(); - } catch (I2PException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } - } + private int lastPacket = -1; + public void messageAvailable(I2PSession session, int msgId, + long size) { + try { + byte msg[] = session.receiveMessage(msgId); + String m = new String(msg, "ISO-8859-1"); + int no = Integer.parseInt(m); + if (no != ++lastPacket) { + System.out.println("ERROR: <<"+no); + } else { + System.out.println("<<"+no); + } + } catch (NumberFormatException ex) { + ex.printStackTrace(); + } catch (I2PException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } } } diff --git a/apps/tests/echotester/EchoTester.java b/apps/tests/echotester/EchoTester.java index 1fc0607d72..750ccb7ba6 100644 --- a/apps/tests/echotester/EchoTester.java +++ b/apps/tests/echotester/EchoTester.java @@ -104,7 +104,7 @@ public class EchoTester extends Thread { } } catch (InterruptedException ex) { ex.printStackTrace(); - System.exit(1); // treat these errors as fatal + System.exit(1); // treat these errors as fatal } catch (IOException ex) { ex.printStackTrace(); System.exit(1); // treat these errors as fatal -- GitLab