java.io.IOException.getSuppressed()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中java.io.IOException.getSuppressed()方法的一些代码示例,展示了IOException.getSuppressed()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOException.getSuppressed()方法的具体详情如下:
包路径:java.io.IOException
类名称:IOException
方法名:getSuppressed

IOException.getSuppressed介绍

暂无

代码示例

代码示例来源:origin: apache/kafka

static void checkException(IOException e, TestCloseable... closeablesWithException) {
    assertEquals(closeablesWithException[0].closeException, e);
    Throwable[] suppressed = e.getSuppressed();
    assertEquals(closeablesWithException.length - 1, suppressed.length);
    for (int i = 1; i < closeablesWithException.length; i++)
      assertEquals(closeablesWithException[i].closeException, suppressed[i - 1]);
  }
}

代码示例来源:origin: apache/asterixdb

public static void safeCopyFile(File child, File destChild) throws IOException {
    forceMkdirs(destChild.getParentFile());
    IOException ioException = null;
    while (true) {
      try {
        FileUtils.copyFile(child, destChild);
        return;
      } catch (IOException e) {
        if (ioException == null) {
          ioException = e;
        } else {
          ioException.addSuppressed(e);
        }
        if (ioException.getSuppressed().length >= MAX_COPY_ATTEMPTS) {
          LOGGER.warn("Unable to copy {} to {} after " + MAX_COPY_ATTEMPTS + " attempts; skipping file",
              child, destChild, e);
          return;
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

Throwable[] suppressed = e.getSuppressed();
if (GenericUtils.length(suppressed) > 0) {
  for (Throwable t : suppressed) {

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
public void destroy() {
  // NOTE !!! DO NOT NULL-IFY THE PROCESS SINCE "exitValue" is called subsequently
  if (process != null) {
    log.debug("Destroy process for " + cmdValue);
    process.destroy();
  }
  IOException e = IoUtils.closeQuietly(getInputStream(), getOutputStream(), getErrorStream());
  if (e != null) {
    if (log.isDebugEnabled()) {
      log.debug(e.getClass().getSimpleName() + " while destroy streams of '" + this + "': " + e.getMessage());
    }
    if (log.isTraceEnabled()) {
      Throwable[] suppressed = e.getSuppressed();
      if (GenericUtils.length(suppressed) > 0) {
        for (Throwable t : suppressed) {
          log.trace("Suppressed " + t.getClass().getSimpleName() + ") while destroy streams of '" + this + "': " + t.getMessage());
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

Throwable[] suppressed = e.getSuppressed();
if (GenericUtils.length(suppressed) > 0) {
  for (Throwable t : suppressed) {

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
public void destroy() {
  // NOTE !!! DO NOT NULL-IFY THE PROCESS SINCE "exitValue" is called subsequently
  if (process != null) {
    log.debug("Destroy process for " + cmdValue);
    process.destroy();
  }
  IOException e = IoUtils.closeQuietly(getInputStream(), getOutputStream(), getErrorStream());
  if (e != null) {
    if (log.isDebugEnabled()) {
      log.debug(e.getClass().getSimpleName() + " while destroy streams of '" + this + "': " + e.getMessage());
    }
    if (log.isTraceEnabled()) {
      Throwable[] suppressed = e.getSuppressed();
      if (GenericUtils.length(suppressed) > 0) {
        for (Throwable t : suppressed) {
          log.trace("Suppressed " + t.getClass().getSimpleName() + ") while destroy streams of '" + this + "': " + t.getMessage());
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
protected void preClose() {
  if (!isEofSent()) {
    log.debug("close({}) prevent sending EOF", this);
  }
  try {
    signalChannelClosed(null);
  } finally {
    // clear the listeners since we are closing the channel (quicker GC)
    this.channelListeners.clear();
  }
  IOException err = IoUtils.closeQuietly(getLocalWindow(), getRemoteWindow());
  if (err != null) {
    if (log.isDebugEnabled()) {
      log.debug("Failed (" + err.getClass().getSimpleName() + ") to pre-close window(s) of " + this + ": " + err.getMessage());
    }
    if (log.isTraceEnabled()) {
      Throwable[] suppressed = err.getSuppressed();
      if (GenericUtils.length(suppressed) > 0) {
        for (Throwable t : suppressed) {
          log.trace("Suppressed " + t.getClass().getSimpleName() + ") while pre-close window(s) of " + this + ": " + t.getMessage());
        }
      }
    }
  }
  super.preClose();
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
protected void preClose() {
  if (!isEofSent()) {
    log.debug("close({}) prevent sending EOF", this);
  }
  try {
    signalChannelClosed(null);
  } finally {
    // clear the listeners since we are closing the channel (quicker GC)
    this.channelListeners.clear();
    // clear the attributes since we close the channel
    clearAttributes();
  }
  IOException err = IoUtils.closeQuietly(getLocalWindow(), getRemoteWindow());
  if (err != null) {
    if (log.isDebugEnabled()) {
      log.debug("Failed (" + err.getClass().getSimpleName() + ") to pre-close window(s) of " + this + ": " + err.getMessage());
    }
    if (log.isTraceEnabled()) {
      Throwable[] suppressed = err.getSuppressed();
      if (GenericUtils.length(suppressed) > 0) {
        for (Throwable t : suppressed) {
          log.trace("Suppressed " + t.getClass().getSimpleName() + ") while pre-close window(s) of " + this + ": " + t.getMessage());
        }
      }
    }
  }
  super.preClose();
}

相关文章