You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2003/05/08 01:07:37 UTC

cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/net XMLSocketNode.java

sdeboy      2003/05/07 16:07:37

  Modified:    src/java/org/apache/log4j/net XMLSocketNode.java
  Log:
  temporarily fixing java.util.logging socket support
  
  Revision  Changes    Path
  1.4       +18 -17    jakarta-log4j-sandbox/src/java/org/apache/log4j/net/XMLSocketNode.java
  
  Index: XMLSocketNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/net/XMLSocketNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLSocketNode.java	5 May 2003 18:30:05 -0000	1.3
  +++ XMLSocketNode.java	7 May 2003 23:07:36 -0000	1.4
  @@ -53,7 +53,6 @@
   import org.apache.log4j.plugins.Receiver;
   import org.apache.log4j.spi.*;
   
  -import java.io.BufferedInputStream;
   import java.io.IOException;
   import java.io.InputStream;
   
  @@ -128,14 +127,14 @@
       listener = _listener;
     }
   
  -  public void run() {
  +    public void run() {
       LoggingEvent event;
       Logger remoteLogger;
       Exception listenerException = null;
  -    InputStream bis = null;
  +    InputStream is = null;
   
       if ((this.receiver == null) || (this.decoder == null)) {
  -      bis = null;
  +      is = null;
         listenerException =
           new Exception(
             "No receiver or decoder provided.  Cannot process xml socket events");
  @@ -144,27 +143,30 @@
       }
   
       try {
  -      bis = new BufferedInputStream(socket.getInputStream());
  +      is = socket.getInputStream();
       } catch (Exception e) {
  -      bis = null;
  +      is = null;
         listenerException = e;
         logger.error("Exception opening ObjectInputStream to " + socket, e);
       }
   
  -    if (bis != null) {
  +    if (is != null) {
         String remoteInfo =
           socket.getInetAddress().getHostName() + ":" + socket.getPort();
   
         try {
           StringBuffer buf = new StringBuffer();
  -
  -        while (true) {
  -          while (bis.available() > 0) {
  -            byte[] b = new byte[1024];
  -            int readCount = bis.read(b);
  -            buf.append(new String(b));
  +            boolean readloop=true;
  +            while (readloop) {
  +                byte[] b=new byte[1024];
  +                is.read(b);
  +                String s=new String(b).trim();
  +                if (s.equals("")) {
  +                    readloop=false;
  +                } else {
  +                    buf.append(s);
  +                } 
             }
  -
             if (buf.length() > 0) {
               Vector v = decoder.decodeEvents(buf.toString());
   
  @@ -201,7 +203,6 @@
   
               buf.setLength(0);
             }
  -        }
         } catch (java.io.EOFException e) {
           logger.info("Caught java.io.EOFException closing conneciton.");
           listenerException = e;
  @@ -220,8 +221,8 @@
   
       // close the socket
       try {
  -      if (bis != null) {
  -        bis.close();
  +      if (is != null) {
  +        is.close();
         }
       } catch (Exception e) {
         //logger.info("Could not close connection.", e);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org