protected void doStop() throws Exception { super.doStop(); if (additionalApplicationContext != null) { LOG.debug("Stopping Additional ApplicationContext: {}", additionalApplicationContext.getId()); IOHelper.close(additionalApplicationContext); } if (applicationContext != null) { LOG.debug("Stopping Spring ApplicationContext: {}", applicationContext.getId()); IOHelper.close(applicationContext); } }
protected void findLocations(Set<String> locations, ClassLoader classLoader) throws IOException { Enumeration<URL> resources = classLoader.getResources(LOCATION_PROPERTIES); while (resources.hasMoreElements()) { URL url = resources.nextElement(); BufferedReader reader = IOHelper.buffered(new InputStreamReader(url.openStream(), UTF8)); try { while (true) { String line = reader.readLine(); if (line == null) { break; } line = line.trim(); if (line.startsWith("#") || line.length() == 0) { continue; } locations.add(line); } } finally { IOHelper.close(reader, null, LOG); } } }
OutputStream os = new FileOutputStream(file, false); IOHelper.copyAndCloseInput(is, os); IOHelper.close(os);
@Override public void onDone(Exchange exchange) { IOHelper.close(s3Object); } });
@Override protected void doStop() throws Exception { if (client != null) { IOHelper.close(client); client = null; } }
@Override public void close() throws IOException { IOHelper.close(asn1InputStream); asn1InputStream = null; }
private void checkNullAnswer(T answer) { if (answer == null && asn1InputStream != null) { IOHelper.close(asn1InputStream); asn1InputStream = null; } }
@Override public void close() throws IOException { IOHelper.close(tarInputStream); tarInputStream = null; }
@Override public boolean exists() { InputStream is = resolver.loadResourceAsStream(path); if (is != null) { IOHelper.close(is); } return is != null; }
@Override protected void doStop() throws Exception { if (is != null) { IOHelper.close(is); } super.doStop(); } }
private DefaultExchangeHolder decode(CamelContext camelContext, byte[] dataIn) throws IOException, ClassNotFoundException { ByteArrayInputStream bytesIn = new ByteArrayInputStream(dataIn); ObjectInputStream objectIn = null; Object obj = null; try { objectIn = new ClassLoadingAwareObjectInputStream(camelContext, bytesIn); obj = objectIn.readObject(); } finally { IOHelper.close(objectIn); } return (DefaultExchangeHolder)obj; }
public void stop() { File file = getFile(); LOG.debug("Stopping LevelDB using file: {}", file); if (db != null) { IOHelper.close(db); db = null; } } }
@Override public void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException { InputStream is = exchange.getIn().getHeader(RemoteFileComponent.REMOTE_FILE_INPUT_STREAM, InputStream.class); if (is != null) { try { IOHelper.close(is); client.completePendingCommand(); } catch (IOException e) { throw new GenericFileOperationFailedException(e.getMessage(), e); } } }
@Deprecated public static PGPPublicKey findPublicKeyWithKeyId(CamelContext context, String filename, byte[] keyRing, long keyid, boolean forEncryption) throws IOException, PGPException, NoSuchProviderException { InputStream is = determineKeyRingInputStream(context, filename, keyRing, forEncryption); PGPPublicKey pubKey; try { pubKey = findPublicKeyWithKeyId(is, keyid); } finally { IOHelper.close(is); } return pubKey; }
public static List<PGPPublicKey> findPublicKeys(CamelContext context, String filename, byte[] keyRing, List<String> userids, boolean forEncryption) throws IOException, PGPException, NoSuchProviderException { InputStream is = determineKeyRingInputStream(context, filename, keyRing, forEncryption); try { return findPublicKeys(is, userids, forEncryption); } finally { IOHelper.close(is); } }
public static List<PGPSecretKeyAndPrivateKeyAndUserId> findSecretKeysWithPrivateKeyAndUserId(CamelContext context, String keychainFilename, byte[] secKeyRing, Map<String, String> sigKeyUserId2Password, String provider) throws IOException, PGPException, NoSuchProviderException { InputStream keyChainInputStream = determineKeyRingInputStream(context, keychainFilename, secKeyRing, false); try { return findSecretKeysWithPrivateKeyAndUserId(keyChainInputStream, sigKeyUserId2Password, provider); } finally { IOHelper.close(keyChainInputStream); } }
public Object unmarshal(Exchange exchange, InputStream inputStream) throws IOException { CSVParser parser = new CSVParser(new InputStreamReader(inputStream, IOHelper.getCharsetName(exchange)), format); try { return asList(parser.iterator(), converter); } finally { IOHelper.close(parser); } }
/** * Loads a private key from a Java keystore depending on this loader's properties. */ public PrivateKey loadPrivateKey() throws Exception { InputStream input = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), keyStoreLocation); try { return loadPrivateKey(input); } finally { IOHelper.close(input); } }
private void write(ChannelExec c, String name, InputStream data, ScpConfiguration cfg) throws IOException { OutputStream os = c.getOutputStream(); InputStream is = c.getInputStream(); try { writeFile(name, data, os, is, cfg); } finally { IOHelper.close(is, os); } }
@Override public void doStop() throws Exception { if (executor != null) { endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor); executor = null; } ServiceHelper.stopAndShutdownService(fileWatcher); lines.clear(); // do not close regular inputStream as it may be System.in etc. IOHelper.close(inputStreamToClose); super.doStop(); }