[logback-dev] Why ResilientOutputStreamBase does not write the log message after attempt the recovery?

Ceki Gülcü ceki at qos.ch
Tue Apr 13 16:52:43 CEST 2010


Hi Tom,

Good question. There is no airtight justification for not wiring the
message, but I'll try anyway. First, it's OK to lose a message because
recovery is attempted only for broken channels. If it wasn't for the
successful attempt, all subsequent messages would be lost too. That
explains why it's not wrong to return after every recovery attempt
even successful ones. As for the why, ResilientOutputStream is the
result of several iterations and the code evolved to its present
state.

While working on issue LBCORE-148, i.e. refactoring SocketAppender to
use a resilient stream, returning after recovery attempts proved to be
quite useful but that was just accidental, not by design.

I hope this answers your question,

On 13/04/2010 10:42 AM, Tom Liu wrote:
> Hi logback-dev,
>
> I wonder why ResilientOutputStreamBase does not try to write the log
> message after attempt the recovery?
> What's the consideration here?
>
> public void write(byte b[], int off, int len) {
>      if (isPresumedInError()) {
>        if (!recoveryCoordinator.isTooSoon()) {
>          attemptRecovery();
>        }
>        return; // return regardless of the success of the recovery attempt
>      }
>
>      try {
>        os.write(b, off, len);
>        postSuccessfulWrite();
>      } catch (IOException e) {
>        postIOFailure(e);
>      }
>    }
>
> Thanks very much,
> Tom




More information about the logback-dev mailing list