本文整理了Java中java.io.IOException.addSuppressed()
方法的一些代码示例,展示了IOException.addSuppressed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOException.addSuppressed()
方法的具体详情如下:
包路径:java.io.IOException
类名称:IOException
方法名:addSuppressed
暂无
代码示例来源:origin: apache/kafka
/**
* 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 {
if (closeable != null)
closeable.close();
} catch (IOException e) {
if (exception != null)
exception.addSuppressed(e);
else
exception = e;
}
}
if (exception != null)
throw exception;
}
代码示例来源:origin: apache/kafka
/**
* Attempts to move source to target atomically and falls back to a non-atomic move if it fails.
*
* @throws IOException if both atomic and non-atomic moves fail
*/
public static void atomicMoveWithFallback(Path source, Path target) throws IOException {
try {
Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
} catch (IOException outer) {
try {
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
log.debug("Non-atomic move of {} to {} succeeded after atomic move failed due to {}", source, target,
outer.getMessage());
} catch (IOException inner) {
inner.addSuppressed(outer);
throw inner;
}
}
}
代码示例来源:origin: apache/nifi
private static void close(final Closeable... closeables) throws IOException {
IOException ioe = null;
for (final Closeable closeable : closeables) {
if (closeable == null) {
continue;
}
try {
closeable.close();
} catch (final IOException e) {
if (ioe == null) {
ioe = e;
} else {
ioe.addSuppressed(e);
}
}
}
if (ioe != null) {
throw ioe;
}
}
代码示例来源:origin: jenkinsci/jenkins
Files.move(tmpPath, destPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e1) {
e1.addSuppressed(e);
LOGGER.log(Level.WARNING, "Unable to move {0} to {1}. Attempting to delete {0} and abandoning.",
new Path[]{tmpPath, destPath});
Files.deleteIfExists(tmpPath);
} catch (IOException e2) {
e2.addSuppressed(e1);
LOGGER.log(Level.WARNING, "Unable to delete {0}, good bye then!", tmpPath);
throw e2;
代码示例来源:origin: neo4j/neo4j
private static void markAsFailed( DatabaseIndex<? extends IndexReader> index, IndexEntryConflictException conflict )
{
try
{
index.markAsFailed( conflict.getMessage() );
}
catch ( IOException ioe )
{
ioe.addSuppressed( conflict );
throw new UncheckedIOException( ioe );
}
}
代码示例来源:origin: apache/nifi
private void forEachStream(final StreamProcessor proc) throws IOException {
IOException exception = null;
for (final OutputStream out : streamMap.values()) {
try {
proc.process(out);
} catch (final IOException ioe) {
if (exception == null) {
exception = ioe;
} else {
ioe.addSuppressed(exception);
exception = ioe;
}
}
}
if (exception != null) {
throw exception;
}
}
代码示例来源:origin: commons-io/commons-io
close();
} catch (final IOException e) {
ioe.addSuppressed(e);
代码示例来源:origin: apache/incubator-druid
e.addSuppressed(e2);
代码示例来源:origin: neo4j/neo4j
/**
* Opens all {@link Directory lucene directories} contained in the {@link #getIndexFolder() index folder}.
*
* @return the map from file system {@link File directory} to the corresponding {@link Directory lucene directory}.
* @throws IOException if opening of some lucene directory (via {@link DirectoryFactory#open(File)}) fails.
*/
public Map<File,Directory> openIndexDirectories() throws IOException
{
Map<File,Directory> directories = new LinkedHashMap<>();
try
{
for ( File dir : listFolders() )
{
directories.put( dir, directoryFactory.open( dir ) );
}
}
catch ( IOException oe )
{
try
{
IOUtils.closeAll( directories.values() );
}
catch ( Exception ce )
{
oe.addSuppressed( ce );
}
throw oe;
}
return directories;
}
代码示例来源:origin: neo4j/neo4j
private void closeAndCollectExceptions( int channelIndex, IOException exception ) throws IOException
{
if ( channelIndex == channels.length )
{
if ( exception != null )
{
throw exception;
}
return;
}
try
{
channels[channelIndex].close();
}
catch ( IOException e )
{
if ( exception == null )
{
exception = e;
}
else
{
exception.addSuppressed( e );
}
}
closeAndCollectExceptions( channelIndex + 1, exception );
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @deprecated Specific to {@link Mode#REMOTING}.
*/
@Deprecated
/*package*/ CLI(CLIConnectionFactory factory) throws IOException, InterruptedException {
URL jenkins = factory.jenkins;
this.httpsProxyTunnel = factory.httpsProxyTunnel;
this.authorization = factory.authorization;
ExecutorService exec = factory.exec;
ownsPool = exec==null;
pool = exec!=null ? exec : Executors.newCachedThreadPool(new NamingThreadFactory(Executors.defaultThreadFactory(), "CLI.pool"));
Channel _channel;
try {
_channel = connectViaCliPort(jenkins, getCliTcpPort(jenkins));
} catch (IOException e) {
LOGGER.log(Level.FINE, "Failed to connect via CLI port. Falling back to HTTP", e);
try {
_channel = connectViaHttp(jenkins);
} catch (IOException e2) {
e.addSuppressed(e2);
throw e;
}
}
this.channel = _channel;
// execute the command
entryPoint = (CliEntryPoint)_channel.waitForRemoteProperty(CliEntryPoint.class.getName());
if(entryPoint.protocolVersion()!=CliEntryPoint.VERSION)
throw new IOException(Messages.CLI_VersionMismatch());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
static void test(final String[] args, final String config) {
// System.out.println(System.getProperty("java.class.path"));
try (final LoggerContext ctx = Configurator
.initialize(ConsoleAppenderDefaultSuppressedThrowable.class.getName(), config)) {
final IOException ioEx = new IOException("test suppressed");
ioEx.addSuppressed(new IOException("test suppressed 1", new IOException("test 1")));
final IOException ioEx2 = new IOException("test 2");
ioEx2.addSuppressed(new IOException("test 3"));
ioEx.addSuppressed(new IOException("test suppressed 2", ioEx2));
final IOException e = new IOException("test", ioEx);
LOG.error("Error message {}, suppressed?", "Hi", e);
System.out.println("printStackTrace");
e.printStackTrace();
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Note: Must be called while synchronizing on the MuninnPageCache instance.
*/
private void ensureThreadsInitialised() throws IOException
{
if ( threadsInitialised )
{
return;
}
threadsInitialised = true;
try
{
scheduler.schedule( Group.PAGE_CACHE, new EvictionTask( this ) );
}
catch ( Exception e )
{
IOException exception = new IOException( e );
try
{
close();
}
catch ( Exception closeException )
{
exception.addSuppressed( closeException );
}
throw exception;
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public LineIterator next()
{
if (!hasNext()) {
throw new NoSuchElementException();
}
final OpenedObject<T> openedObject = fetcher.next();
try {
return new ResourceCloseableLineIterator(
new InputStreamReader(
wrapObjectStream(openedObject.getObject(), openedObject.getObjectStream()),
StandardCharsets.UTF_8
),
openedObject.getResourceCloser()
);
}
catch (IOException e) {
try {
openedObject.getResourceCloser().close();
}
catch (Throwable t) {
e.addSuppressed(t);
}
throw new RuntimeException(e);
}
}
},
代码示例来源:origin: neo4j/neo4j
@Override
public void run()
{
try
{
String line;
while ( (line = in.readLine()) != null )
{
if ( !quiet )
{
out.write( prefix + line + "\n" );
out.flush();
}
}
}
catch ( IOException exc )
{
exc.addSuppressed( stackTraceOfOrigin );
failureHandler.handle( exc );
}
}
}
代码示例来源:origin: Alluxio/alluxio
@Override
public void cancel() throws IOException {
if (mClosed) {
return;
}
releaseCurrentChunk();
IOException exception = null;
for (DataWriter dataWriter : mDataWriters) {
try {
dataWriter.cancel();
} catch (IOException e) {
if (exception != null) {
exception.addSuppressed(e);
}
}
}
if (exception != null) {
throw exception;
}
close();
}
代码示例来源:origin: wildfly/wildfly
@Override
public void terminateReads() throws IOException {
if (tls) {
try {
sslEngine.closeInbound();
} catch (IOException ex) {
try {
super.terminateReads();
} catch (IOException e2) {
e2.addSuppressed(ex);
throw e2;
}
throw ex;
}
}
super.terminateReads();
}
代码示例来源:origin: wildfly/wildfly
@Override
public void terminateWrites() throws IOException {
if (!tls) {
super.terminateWrites();
return;
}
try {
sslEngine.closeOutbound();
flush();
} catch (IOException e) {
try {
super.truncateWrites();
} catch (IOException e2) {
e2.addSuppressed(e);
throw e2;
}
throw e;
}
}
代码示例来源:origin: neo4j/neo4j
ioe.addSuppressed( e );
throw ioe;
代码示例来源:origin: jenkinsci/jenkins
} catch (ExecutionException x) {
e.addSuppressed(x);
throw e;
} catch (TimeoutException ignored) {
内容来源于网络,如有侵权,请联系作者删除!