felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r999076 - in /felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote: Shell.java TerminalPrintStream.java TerminalReader.java
Date Mon, 20 Sep 2010 19:28:38 GMT
Author: rickhall
Date: Mon Sep 20 19:28:38 2010
New Revision: 999076

URL: http://svn.apache.org/viewvc?rev=999076&view=rev
Log:
Handle exceptions better in TerminalPrintStream. (FELIX-2604)

Modified:
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalPrintStream.java
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalReader.java

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java?rev=999076&r1=999075&r2=999076&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java (original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java Mon Sep
20 19:28:38 2010
@@ -19,10 +19,10 @@ package org.apache.felix.shell.remote;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.net.Socket;
-import org.apache.felix.service.command.CommandProcessor;
-import org.apache.felix.service.command.CommandSession;
 
 import org.apache.felix.shell.ShellService;
+import org.apache.felix.service.command.CommandProcessor;
+import org.apache.felix.service.command.CommandSession;
 
 /**
  * Implements the shell.

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalPrintStream.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalPrintStream.java?rev=999076&r1=999075&r2=999076&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalPrintStream.java
(original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalPrintStream.java
Mon Sep 20 19:28:38 2010
@@ -16,10 +16,8 @@
  */
 package org.apache.felix.shell.remote;
 
-import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.net.SocketException;
 
 /**
  * Class implementing a <tt>TerminalPrintStream</tt>.
@@ -38,45 +36,54 @@ class TerminalPrintStream extends PrintS
     {
         super(tout);
         m_services = services;
-    }//constructor
+    }
 
     public void print(String str)
     {
-        try
-        {
-            byte[] bytes = str.getBytes();
-            out.write(bytes, 0, bytes.length);
-            flush();
-        }
-        catch (Exception ex)
+        if (out != null)
         {
-            if (!m_isClosed)
+            try
             {
-                m_services.error("TerminalPrintStream::print()", ex);
+                byte[] bytes = str.getBytes();
+                out.write(bytes, 0, bytes.length);
+                flush();
+            }
+            catch (Exception ex)
+            {
+                if (!m_isClosed)
+                {
+                    m_services.error("TerminalPrintStream::print()", ex);
+                }
             }
         }
-    }//print
+    }
 
     public void println(String str)
     {
         print(str + "\r\n");
-    }//println
+    }
 
     public void flush()
     {
-        try
+        if (out != null)
         {
-            out.flush();
-        }
-        catch (IOException ex)
-        {
-            m_services.error("TerminalPrintStream::println()", ex);
+            try
+            {
+                out.flush();
+            }
+            catch (Exception ex)
+            {
+                if (!m_isClosed)
+                {
+                    m_services.error("TerminalPrintStream::println()", ex);
+                }
+            }
         }
-    }//flush
+    }
 
     public void close()
     {
         m_isClosed = true;
         super.close();
     }
-}//class TerminalPrintStream
+}
\ No newline at end of file

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalReader.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalReader.java?rev=999076&r1=999075&r2=999076&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalReader.java
(original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/TerminalReader.java
Mon Sep 20 19:28:38 2010
@@ -29,8 +29,8 @@ import java.io.Reader;
  */
 class TerminalReader extends Reader
 {
-    protected InputStream m_in;
-    protected PrintStream m_out;
+    protected final InputStream m_in;
+    protected final PrintStream m_out;
     protected boolean m_echo = false;
     protected boolean m_eof = false;
 
@@ -169,6 +169,7 @@ class TerminalReader extends Reader
     {
         m_in.close();
     }//close
+
     /**
      * <b>Bell</b><br>
      * The ANSI defined byte code for the NVT bell.



Mime
View raw message