Sorry I correct my earlier statement
synchronized(this) should be changed to
synchronized(SocketAppender.this) in my opinion.


-----Original Message-----
From: Seemantini Godbole 
Sent: Wednesday, August 15, 2001 4:27 PM
To: 'LOG4J Users Mailing List'
Subject: bug in SocketAppender?


I was looking at some code in SocketAppender, particularly the following
piece:
I understand that the SocketAppender fires another thread, Connector,
whenever it can not reach the remote server. The connector keeps trying
every now and then to connect to the remote server and it sets the value of
oos when it finally succeeds. It does a "synchronized" when it sets the
value of oos. but according to me should the synchronized be on the outer
class SocketAppender instead of connector. In essence, the statement
synchronized(this) should be changed to
synchronized(Connector.this) in my opinion.

but, then again, I may be missing something...

class Connector extends Thread {

    boolean interrupted = false;

    public
    void run() {
      Socket socket;      
      while(!interrupted) {
        try {
          sleep(reconnectionDelay);
          LogLog.debug("Attempting connection to "+address.getHostName());
          socket = new Socket(address, port);

/********The is the statement I am talking about **********/
          synchronized(this) {
            oos = new ObjectOutputStream(socket.getOutputStream()); 
            connector = null;
            break;
          }
        }
        catch(InterruptedException e) {
          LogLog.debug("Connector interrupted. Leaving loop.");
          return;
        }

Any thoughts?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to