当前位置: 首页>>代码示例>>Java>>正文


Java IOException.addSuppressed方法代码示例

本文整理汇总了Java中java.io.IOException.addSuppressed方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.addSuppressed方法的具体用法?Java IOException.addSuppressed怎么用?Java IOException.addSuppressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.addSuppressed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import java.io.IOException; //导入方法依赖的package包/类
public Unfiltered next()
{
    try
    {
        return nextInternal();
    }
    catch (IOException e)
    {
        try
        {
            closeInternal();
        }
        catch (IOException suppressed)
        {
            e.addSuppressed(suppressed);
        }
        sstable.markSuspect();
        throw new CorruptSSTableException(e, reader.file.getPath());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:AbstractSSTableIterator.java

示例2: setup

import java.io.IOException; //导入方法依赖的package包/类
@Override
public void setup() {
	logging.debug("Connection setup for " + socket);
	try {
		logging.trace("SendingService setup..");
		synchronized (this) {
			this.sendingService.setup(socket.getOutputStream(), toSend);
			logging.trace("SendingService was successfully setup!");
			logging.trace("ReceivingService setup..");
			this.receivingService.setup(this, getSession());
		}
		logging.trace("ReceivingService was successfully setup!");
		logging.trace("Adding Call-Back-Hook to ReceivingService");
		receivingService.addReceivingCallback(new DefaultReceiveCallback());
	} catch (IOException e) {
		try {
			logging.warn("Encountered Exception while ConnectionSetup!");
			logging.catching(e);
			close();
		} catch (IOException e1) {
			e.addSuppressed(e1);
			logging.fatal("Encountered Exception while cleaning up over a previously encountered Exception!", e1);
		}
		throw new ClientCreationFailedException(e);
	}
	setup = true;
}
 
开发者ID:ThorbenKuck,项目名称:NetCom2,代码行数:28,代码来源:AbstractConnection.java

示例3: close

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Closes all currently open files.
 * Calling this method will not prevent the factory to open new files, i.e. this method can be called multiple times and is not idempotent.
 * 
 * @throws IOException
 */
@Override
public synchronized void close() throws IOException {
	IOException exception = new IOException("At least one open file could not be closed.");
	for (Iterator<Map.Entry<Long, OpenFile>> it = openFiles.entrySet().iterator(); it.hasNext();) {
		Map.Entry<Long, OpenFile> entry = it.next();
		OpenFile openFile = entry.getValue();
		LOG.warn("Closing unclosed file {}", openFile);
		try {
			openFile.close();
		} catch (IOException e) {
			exception.addSuppressed(e);
		}
		it.remove();
	}
	if (exception.getSuppressed().length > 0) {
		throw exception;
	}
}
 
开发者ID:cryptomator,项目名称:fuse-nio-adapter,代码行数:25,代码来源:OpenFileFactory.java

示例4: readLastCommittedSegmentInfos

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Read the last segments info from the commit pointed to by the searcher manager
 */
protected static SegmentInfos readLastCommittedSegmentInfos(final SearcherManager sm, final Store store) throws IOException {
    IndexSearcher searcher = sm.acquire();
    try {
        IndexCommit latestCommit = ((DirectoryReader) searcher.getIndexReader()).getIndexCommit();
        return Lucene.readSegmentInfos(latestCommit);
    } catch (IOException e) {
        // Fall back to reading from the store if reading from the commit fails
        try {
            return store.readLastCommittedSegmentsInfo();
        } catch (IOException e2) {
            e2.addSuppressed(e);
            throw e2;
        }
    } finally {
        sm.release(searcher);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:Engine.java

示例5: closeAll

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Closes all the provided closeables.
 * @throws IOException if any of the close methods throws an IOException.
 *         The first IOException is thrown with subsequent exceptions
 *         added as suppressed exceptions.
 */
public static void closeAll(Closeable... closeables) throws IOException {
    IOException exception = null;
    for (Closeable closeable : closeables) {
        try {
            closeable.close();
        } catch (IOException e) {
            if (exception != null)
                exception.addSuppressed(e);
            else
                exception = e;
        }
    }
    if (exception != null)
        throw exception;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:Utils.java

示例6: readLastCommittedSegmentInfos

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Read the last segments info from the commit pointed to by the searcher manager
 */
protected static SegmentInfos readLastCommittedSegmentInfos(final SearcherManager sm, final Store store) throws IOException {
    IndexSearcher searcher = sm.acquire();
    try {
        IndexCommit latestCommit = ((DirectoryReader) searcher.getIndexReader()).getIndexCommit();
        return Lucene.readSegmentInfos(latestCommit);
    } catch (IOException e) {
        // Fall back to reading from the store if reading from the commit fails
        try {
            return store. readLastCommittedSegmentsInfo();
        } catch (IOException e2) {
            e2.addSuppressed(e);
            throw e2;
        }
    } finally {
        sm.release(searcher);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:Engine.java

示例7: getTemplateText

import java.io.IOException; //导入方法依赖的package包/类
private String getTemplateText(
    Filer filer,
    TypeElement templateType,
    PackageElement packageElement) throws IOException {
  CharSequence relativeName = templateType.getSimpleName() + ".generator";
  CharSequence packageName = packageElement.getQualifiedName();
  List<Exception> suppressed = Lists.newArrayList();
  try {
    return filer.getResource(StandardLocation.SOURCE_PATH, packageName, relativeName)
        .getCharContent(true)
        .toString();
  } catch (Exception cannotGetFromSourcePath) {
    suppressed.add(cannotGetFromSourcePath);
    try {
      return filer.getResource(StandardLocation.CLASS_OUTPUT, packageName, relativeName)
          .getCharContent(true)
          .toString();
    } catch (Exception cannotGetFromOutputPath) {
      suppressed.add(cannotGetFromOutputPath);
      try {
        return filer.getResource(StandardLocation.CLASS_PATH,
            "",
            packageName.toString().replace('.', '/') + '/' + relativeName)
            .getCharContent(true)
            .toString();
      } catch (IOException cannotGetFromClasspath) {
        for (Exception e : suppressed) {
          cannotGetFromClasspath.addSuppressed(e);
        }
        throw cannotGetFromClasspath;
      }
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:Processor.java

示例8: RawChannelImpl

import java.io.IOException; //导入方法依赖的package包/类
RawChannelImpl(HttpClientImpl client,
               HttpConnection connection,
               ByteBuffer initial)
        throws IOException
{
    this.client = client;
    this.connection = connection;
    SocketChannel chan = connection.channel();
    client.cancelRegistration(chan);
    // Constructing a RawChannel is supposed to have a "hand over"
    // semantics, in other words if construction fails, the channel won't be
    // needed by anyone, in which case someone still needs to close it
    try {
        chan.configureBlocking(false);
    } catch (IOException e) {
        try {
            chan.close();
        } catch (IOException e1) {
            e.addSuppressed(e1);
        }
        throw e;
    }
    // empty the initial buffer into our own copy.
    synchronized (initialLock) {
        this.initial = initial.hasRemaining()
                ? Utils.copy(initial)
                : Utils.EMPTY_BYTEBUFFER;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:RawChannelImpl.java

示例9: writeAtomic

import java.io.IOException; //导入方法依赖的package包/类
private void writeAtomic(final String blobName, final BytesReference bytesRef) throws IOException {
    final String tempBlobName = "pending-" + blobName + "-" + UUIDs.randomBase64UUID();
    try (InputStream stream = bytesRef.streamInput()) {
        snapshotsBlobContainer.writeBlob(tempBlobName, stream, bytesRef.length());
        snapshotsBlobContainer.move(tempBlobName, blobName);
    } catch (IOException ex) {
        // temporary blob creation or move failed - try cleaning up
        try {
            snapshotsBlobContainer.deleteBlob(tempBlobName);
        } catch (IOException e) {
            ex.addSuppressed(e);
        }
        throw ex;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:BlobStoreRepository.java

示例10: failStoreIfCorrupted

import java.io.IOException; //导入方法依赖的package包/类
private void failStoreIfCorrupted(Exception e) {
    if (e instanceof CorruptIndexException || e instanceof IndexFormatTooOldException || e instanceof IndexFormatTooNewException) {
        try {
            store.markStoreCorrupted((IOException) e);
        } catch (IOException inner) {
            inner.addSuppressed(e);
            logger.warn("store cannot be marked as corrupted", inner);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:BlobStoreRepository.java

示例11: closeIntoReader

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Closes this writer and transfers its underlying file channel to a new immutable {@link TranslogReader}
 * @return a new {@link TranslogReader}
 * @throws IOException if any of the file operations resulted in an I/O exception
 */
public TranslogReader closeIntoReader() throws IOException {
    // make sure to acquire the sync lock first, to prevent dead locks with threads calling
    // syncUpTo() , where the sync lock is acquired first, following by the synchronize(this)
    //
    // Note: While this is not strictly needed as this method is called while blocking all ops on the translog,
    //       we do this to for correctness and preventing future issues.
    synchronized (syncLock) {
        synchronized (this) {
            try {
                sync(); // sync before we close..
            } catch (IOException e) {
                try {
                    closeWithTragicEvent(e);
                } catch (Exception inner) {
                    e.addSuppressed(inner);
                }
                throw e;
            }
            if (closed.compareAndSet(false, true)) {
                return new TranslogReader(getLastSyncedCheckpoint(), channel, path, getFirstOperationOffset());
            } else {
                throw new AlreadyClosedException("translog [" + getGeneration() + "] is already closed (path [" + path + "]", tragedy);
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:TranslogWriter.java

示例12: checkJar

import java.io.IOException; //导入方法依赖的package包/类
static JarFile checkJar(JarFile jar) throws IOException {
    if (System.getSecurityManager() != null && !DISABLE_JAR_CHECKING
        && !zipAccess.startsWithLocHeader(jar)) {
        IOException x = new IOException("Invalid Jar file");
        try {
            jar.close();
        } catch (IOException ex) {
            x.addSuppressed(ex);
        }
        throw x;
    }

    return jar;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:URLClassPath.java

示例13: deleteFileTreeWithRetry

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Deletes a directory and its subdirectories, retrying if necessary.
 *
 * @param dir  the directory to delete
 *
 * @throws  IOException
 *          If an I/O error occurs. Any such exceptions are caught
 *          internally. If only one is caught, then it is re-thrown.
 *          If more than one exception is caught, then the second and
 *          following exceptions are added as suppressed exceptions of the
 *          first one caught, which is then re-thrown.
 */
public static void deleteFileTreeWithRetry(Path dir) throws IOException {
    IOException ioe = null;
    final List<IOException> excs = deleteFileTreeUnchecked(dir);
    if (!excs.isEmpty()) {
        ioe = excs.remove(0);
        for (IOException x : excs) {
            ioe.addSuppressed(x);
        }
    }
    if (ioe != null) {
        throw ioe;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:FileUtils.java

示例14: close

import java.io.IOException; //导入方法依赖的package包/类
/**
* Closes this URLClassLoader, so that it can no longer be used to load
* new classes or resources that are defined by this loader.
* Classes and resources defined by any of this loader's parents in the
* delegation hierarchy are still accessible. Also, any classes or resources
* that are already loaded, are still accessible.
* <p>
* In the case of jar: and file: URLs, it also closes any files
* that were opened by it. If another thread is loading a
* class when the {@code close} method is invoked, then the result of
* that load is undefined.
* <p>
* The method makes a best effort attempt to close all opened files,
* by catching {@link IOException}s internally. Unchecked exceptions
* and errors are not caught. Calling close on an already closed
* loader has no effect.
* <p>
* @exception IOException if closing any file opened by this class loader
* resulted in an IOException. Any such exceptions are caught internally.
* If only one is caught, then it is re-thrown. If more than one exception
* is caught, then the second and following exceptions are added
* as suppressed exceptions of the first one caught, which is then re-thrown.
*
* @exception SecurityException if a security manager is set, and it denies
*   {@link RuntimePermission}{@code ("closeClassLoader")}
*
* @since 1.7
*/
public void close() throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new RuntimePermission("closeClassLoader"));
    }
    List<IOException> errors = ucp.closeLoaders();

    // now close any remaining streams.

    synchronized (closeables) {
        Set<Closeable> keys = closeables.keySet();
        for (Closeable c : keys) {
            try {
                c.close();
            } catch (IOException ioex) {
                errors.add(ioex);
            }
        }
        closeables.clear();
    }

    if (errors.isEmpty()) {
        return;
    }

    IOException firstex = errors.remove(0);

    // Suppress any remaining exceptions

    for (IOException error: errors) {
        firstex.addSuppressed(error);
    }
    throw firstex;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:63,代码来源:URLClassLoader.java

示例15: release

import java.io.IOException; //导入方法依赖的package包/类
IOException release(
        final IOException ex,
        final FileNode buffer)
throws IOException {
    try {
        buffer.release();
    } catch (final IOException ex2) {
        ex.addSuppressed(ex2);
    }
    return ex;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:12,代码来源:FileOutputSocket.java


注:本文中的java.io.IOException.addSuppressed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。