use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project jmxtrans by jmxtrans.
the class SocketAllocator method deallocate.
@Override
public void deallocate(SocketPoolable poolable) throws Exception {
Closer closer = Closer.create();
try {
closer.register(poolable.getSocket());
closer.register(poolable.getWriter());
} catch (Throwable t) {
throw closer.rethrow(t);
} finally {
closer.close();
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project jmxtrans by jmxtrans.
the class TCPEchoServer method start.
// server is only stopped when interrupted. Might be ugly, but good enough for a test server.
@SuppressWarnings("squid:S2189")
public void start() {
checkState(thread == null, "Server already started");
thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Closer closer = Closer.create();
try {
server = closer.register(new ServerSocket(0));
while (true) {
processRequests(server);
}
} catch (Throwable t) {
throw closer.rethrow(t);
} finally {
closer.close();
server = null;
}
} catch (IOException ioe) {
log.error("Exception in TCP echo server", ioe);
}
}
});
thread.start();
try {
synchronized (startSynchro) {
startSynchro.wait(1000);
}
} catch (InterruptedException interrupted) {
log.error("TCP Echo server seems to take too long to start", interrupted);
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project gradle by gradle.
the class DefaultBuildCacheController method close.
@Override
public void close() throws IOException {
if (!closed) {
closed = true;
Closer closer = Closer.create();
closer.register(local);
closer.register(remote);
closer.close();
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project scheduling by ow2-proactive.
the class SchedulerClient method renewSession.
@Override
public void renewSession() throws NotConnectedException {
Closer closer = Closer.create();
try {
LoginForm loginForm = new LoginForm();
loginForm.setUsername(connectionInfo.getLogin());
loginForm.setPassword(connectionInfo.getPassword());
if (connectionInfo.getCredentialFile() != null) {
FileInputStream inputStream = new FileInputStream(connectionInfo.getCredentialFile());
closer.register(inputStream);
loginForm.setCredential(inputStream);
}
sid = restApi().loginOrRenewSession(sid, loginForm);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
closer.close();
} catch (IOException e) {
// ignore
}
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project scheduling by ow2-proactive.
the class VFSZipper method zip.
public static void zip(FileObject file, OutputStream out) throws IOException {
Closer closer = Closer.create();
try {
closer.register(out);
InputStream in = file.getContent().getInputStream();
closer.register(in);
ByteStreams.copy(in, out);
} catch (IOException ioe) {
throw closer.rethrow(ioe);
} finally {
closer.close();
}
}
Aggregations