@Override public void close() { for (MachineProvisioningLocation<?> provisioner : provisioners) { if (provisioner instanceof Closeable) { Streams.closeQuietly((Closeable)provisioner); } } }
@Override public void close() { for (T machine : machines) { if (machine instanceof Closeable) Streams.closeQuietly((Closeable)machine); } }
@Override public void close() throws IOException { if (content != null) { Streams.closeQuietly(content); } }
/** Destroys the given location. */ public static void destroy(Location loc) { // TODO unmanage the location, if possible? if (loc instanceof Closeable) { Streams.closeQuietly((Closeable)loc); log.debug("closed "+loc); } }
/** copies and closes both */ public static void copyClose(InputStream input, OutputStream output) { try { copy(input, output); } finally { closeQuietly(input); closeQuietly(output); } }
private static Properties loadProperties(String propertiesUrl) throws IOException { InputStream is = null; try { is = new URL(propertiesUrl).openStream(); Properties p = new Properties(); p.load(is); return p; } finally { Streams.closeQuietly(is); } }
/** returns the manifest in a JAR file, or null if no manifest contained therein */ public Manifest getManifest(File f) { JarFile jf = null; try { jf = new JarFile(f); return jf.getManifest(); } catch (IOException e) { throw Exceptions.propagateAnnotated("Unable to read "+f+" when looking for manifest", e); } finally { Streams.closeQuietly(jf); } }
public static String readFullyAndClose(Reader is) { try { return readFully(is); } finally { Streams.closeQuietly(is); } }
private void writeZipEntries(ZipOutputStream zout, Map<ZipEntry, ? extends InputStream> entries) throws IOException { for (Map.Entry<ZipEntry,? extends InputStream> ze: entries.entrySet()) { zout.putNextEntry(ze.getKey()); InputStream zin = ze.getValue(); Streams.copy(zin, zout); Streams.closeQuietly(zin); zout.closeEntry(); } }
@Beta public static void copyTo(InputStream in, File dest) { FileOutputStream out = null; try { out = new FileOutputStream(dest); Streams.copy(in, out); } catch (FileNotFoundException e) { throw Exceptions.propagate(e); } finally { Streams.closeQuietly(out); } }
@AfterMethod(alwaysRun=true) public void afterMethod() throws Exception { if (executor != null) executor.shutdownNow(); Streams.closeQuietly(machine); }
@Override @AfterMethod(alwaysRun=true) public void tearDown() throws Exception { try { if (host != null) Streams.closeQuietly(host); } finally { RecordingSshTool.clear(); super.tearDown(); } }
@AfterMethod(alwaysRun=true) @Override public void tearDown() throws Exception { if (feed != null) feed.stop(); super.tearDown(); if (loc != null) Streams.closeQuietly(loc); RecordingSshMachineLocation.execScriptCalls.clear(); }
@AfterMethod(alwaysRun=true) public void tearDown() throws Exception { if (host != null) Streams.closeQuietly(host); if (managementContext != null) Entities.destroyAll(managementContext); RecordingSshjTool.reset(); }
@AfterMethod(alwaysRun=true) @Override public void tearDown() throws Exception { if (feed != null) feed.stop(); super.tearDown(); if (loc != null) Streams.closeQuietly(loc); }
@AfterMethod(alwaysRun=true) @Override public void tearDown() throws Exception { if (feed != null) feed.stop(); super.tearDown(); if (loc != null) Streams.closeQuietly(loc); }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); } } }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); } }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); } }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); } }