Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1543

prudent mode lose efficacy since v1.2.0

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 1.2.0
    • logback-core
    • None
    • 
      

    Description

      Since v1.2.0 the prudent mode is almost useless because safeWrite never get really invoked

      before v1.2.0

      // OutputStreamAppender.java
      try {
          // skip some irrelevant codes...
          writeOut(event)
      } catch (IOException ioe) {
          this.started = false;
          addStatus(new ErrorStatus("IO failure in appender", this, ioe));
      }
      
      // and writeOut is overrided by FileAppender.java
      @Override
      protected void writeOut(E event) throws IOException {
          if (prudent) {
              safeWrite(event); // here is the point, it ensure write integrity with file lock
          } else {
              super.writeOut(event);
          }
      }

      but since v1.2.0, the code was refactored to this

      // OutputStreamAppender.java
      protected void subAppend(E event) {
          if (!isStarted()) {
              return;
          }
          try {
              // skip some irrelevant codes...
              byte[] byteArray = this.encoder.encode(event);
              writeBytes(byteArray); // there is no guarantee to safe write
          } catch (IOException ioe) {
              this.started = false;
              addStatus(new ErrorStatus("IO failure in appender", this, ioe));
          }
      }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            nico_wen nico_wen
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: