SynchronizedCountingQuietWriter.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:logging 作者:
public final void write(final String string) {
  if (string == null) {
    /*
     * Create an exception here so that a stack trace is available for
     * debugging purposes.
     */
    errorHandler.error("Attempt to write null - see Log4J bug list.",
        new RuntimeException("Fault in Log4J Layout"),
        ErrorCode.WRITE_FAILURE);
    return;
  }
  try {
    synchronized (lock) {
      final int length = string.length();
      out.write(string, 0, length);
      this.charCount += length;
    }
  } catch (IOException e) {
    if (e instanceof InterruptedIOException) {
      Thread.currentThread().interrupt();
    }
    errorHandler.error("Failed to write [" + string + "].", e,
        ErrorCode.WRITE_FAILURE);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号