Module bus.core

Class FaultHideSink

java.lang.Object
org.miaixz.bus.core.io.sink.AssignSink
org.miaixz.bus.core.io.sink.FaultHideSink
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Sink

public class FaultHideSink extends AssignSink
容错接收器,捕获底层接收器的 IOException 并标记错误状态,避免抛出异常。
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    FaultHideSink(Sink delegate)
    构造方法,初始化代理接收器。
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    关闭代理接收器,若发生错误则忽略。
    void
    刷新代理接收器,若发生错误则忽略。
    protected void
    处理异常的钩子方法,子类可重写以自定义行为。
    void
    write(Buffer source, long byteCount)
    写入数据到代理接收器,若发生错误则标记并跳过数据。

    Methods inherited from class org.miaixz.bus.core.io.sink.AssignSink

    delegate, timeout, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FaultHideSink

      public FaultHideSink(Sink delegate)
      构造方法,初始化代理接收器。
      Parameters:
      delegate - 代理的接收器
  • Method Details

    • write

      public void write(Buffer source, long byteCount) throws IOException
      写入数据到代理接收器,若发生错误则标记并跳过数据。
      Specified by:
      write in interface Sink
      Overrides:
      write in class AssignSink
      Parameters:
      source - 数据源缓冲区
      byteCount - 要写入的字节数
      Throws:
      IOException - 如果写入失败(仅在无错误时抛出)
    • flush

      public void flush() throws IOException
      刷新代理接收器,若发生错误则忽略。
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface Sink
      Overrides:
      flush in class AssignSink
      Throws:
      IOException - 如果刷新失败(仅在无错误时抛出)
    • close

      public void close() throws IOException
      关闭代理接收器,若发生错误则忽略。
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Sink
      Overrides:
      close in class AssignSink
      Throws:
      IOException - 如果关闭失败(仅在无错误时抛出)
    • onException

      protected void onException(IOException e)
      处理异常的钩子方法,子类可重写以自定义行为。
      Parameters:
      e - 发生的异常