/** * Closes any object if that object implements {@link AutoCloseable}, while suppressing any IOExceptions it will * generate. The given {@code closeable} may be {@code null}, in which case nothing happens. * * @param closeable the object to be closed */ public static void closeQuietlyIfCloseable(Object closeable) { if (closeable instanceof AutoCloseable) { closeQuietly((AutoCloseable) closeable); } }
/** * Shut down this processor. This will deregister the processor with the {@link EventBus}. */ @Override public void shutDown() { IOUtils.closeQuietly(eventBusRegistration); eventBusRegistration = null; }
/** * Method to invoke when the application shuts down. This closes all event streams used for event store tracking. */ @PreDestroy public void shutDown() { tailingConsumers.forEach(IOUtils::closeQuietly); IOUtils.closeQuietly(producer); cleanupService.shutdownNow(); }
/** * Initialize the RevisionResolver to look for the version in the Meta Data of the artifact with given * {@code groupId} and {@code artifactId}. * * @param groupId The groupId as defined in the pom.xml file of the module * @param artifactId The artifactId as defined in the pom.xml file of the module * @param classLoader The class loader to load the artifact configuration with * @throws IOException When an exception occurs reading from the maven configuration file */ public MavenArtifactRevisionResolver(String groupId, String artifactId, ClassLoader classLoader) throws IOException { final InputStream propFile = classLoader.getResourceAsStream( "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties"); if (propFile != null) { try { Properties mavenProps = new Properties(); mavenProps.load(propFile); version = mavenProps.getProperty("version"); } finally { closeQuietly(propFile); } } else { version = null; } }
private Properties loadDefaultPropertyFile() { Properties properties = new Properties(); InputStream resources = null; try { resources = SQLErrorCodesResolver.class.getResourceAsStream(SQL_ERROR_CODES_PROPERTIES); properties.load(resources); } catch (IOException e) { throw new AxonConfigurationException("Unable to read from a file that should be ", e); } finally { IOUtils.closeQuietly(resources); } return properties; } }
@After public void tearDown() { closeQuietly(connection); }
closeQuietly(eventStream); eventStream = null; doSleepFor(SECONDS.toMillis(errorWaitTime)); closeQuietly(eventStream); releaseToken(segment);
@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } if (UnknownSerializedType.class.isAssignableFrom(classForType(serializedObject.getType()))) { return (T) new UnknownSerializedType(this, serializedObject); } SerializedObject<InputStream> converted = converter.convert(serializedObject, InputStream.class); ObjectInputStream ois = null; try { ois = new ObjectInputStream(converted.getData()); return (T) ois.readObject(); } catch (ClassNotFoundException | IOException e) { throw new SerializationException("An error occurred while deserializing: " + e.getMessage(), e); } finally { IOUtils.closeQuietly(ois); } }
/** * Closes any object if that object implements {@link AutoCloseable}, while suppressing any IOExceptions it will * generate. The given {@code closeable} may be {@code null}, in which case nothing happens. * * @param closeable the object to be closed */ public static void closeQuietlyIfCloseable(Object closeable) { if (closeable instanceof AutoCloseable) { closeQuietly((AutoCloseable) closeable); } }
/** * Closes any object if that object implements {@link AutoCloseable}, while suppressing any IOExceptions it will * generate. The given {@code closeable} may be {@code null}, in which case nothing happens. * * @param closeable the object to be closed */ public static void closeQuietlyIfCloseable(Object closeable) { if (closeable instanceof AutoCloseable) { closeQuietly((AutoCloseable) closeable); } }
/** * Shut down this processor. This will deregister the processor with the {@link EventBus}. */ @Override public void shutDown() { IOUtils.closeQuietly(eventBusRegistration); eventBusRegistration = null; } }
/** * Shut down this processor. This will deregister the processor with the {@link EventBus}. */ @Override public void shutDown() { IOUtils.closeQuietly(eventBusRegistration); eventBusRegistration = null; }
/** * Method to invoke when the application shuts down. This closes all event streams used for event store tracking. */ @PreDestroy public void shutDown() { tailingConsumers.forEach(IOUtils::closeQuietly); IOUtils.closeQuietly(producer); cleanupService.shutdownNow(); }
/** * Method to invoke when the application shuts down. This closes all event streams used for event store tracking. */ @PreDestroy public void shutDown() { tailingConsumers.forEach(IOUtils::closeQuietly); IOUtils.closeQuietly(producer); cleanupService.shutdownNow(); }
/** * Initialize the RevisionResolver to look for the version in the Meta Data of the artifact with given * {@code groupId} and {@code artifactId}. * * @param groupId The groupId as defined in the pom.xml file of the module * @param artifactId The artifactId as defined in the pom.xml file of the module * @param classLoader The class loader to load the artifact configuration with * @throws IOException When an exception occurs reading from the maven configuration file */ public MavenArtifactRevisionResolver(String groupId, String artifactId, ClassLoader classLoader) throws IOException { final InputStream propFile = classLoader.getResourceAsStream( "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties"); if (propFile != null) { try { Properties mavenProps = new Properties(); mavenProps.load(propFile); version = mavenProps.getProperty("version"); } finally { closeQuietly(propFile); } } else { version = null; } }
/** * Initialize the RevisionResolver to look for the version in the Meta Data of the artifact with given * {@code groupId} and {@code artifactId}. * * @param groupId The groupId as defined in the pom.xml file of the module * @param artifactId The artifactId as defined in the pom.xml file of the module * @param classLoader The class loader to load the artifact configuration with * @throws IOException When an exception occurs reading from the maven configuration file */ public MavenArtifactRevisionResolver(String groupId, String artifactId, ClassLoader classLoader) throws IOException { final InputStream propFile = classLoader.getResourceAsStream( "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties"); if (propFile != null) { try { Properties mavenProps = new Properties(); mavenProps.load(propFile); version = mavenProps.getProperty("version"); } finally { closeQuietly(propFile); } } else { version = null; } }
private Properties loadDefaultPropertyFile() { Properties properties = new Properties(); InputStream resources = null; try { resources = SQLErrorCodesResolver.class.getResourceAsStream(SQL_ERROR_CODES_PROPERTIES); properties.load(resources); } catch (IOException e) { throw new AxonConfigurationException("Unable to read from a file that should be ", e); } finally { IOUtils.closeQuietly(resources); } return properties; } }
private Properties loadDefaultPropertyFile() { Properties properties = new Properties(); InputStream resources = null; try { resources = SQLErrorCodesResolver.class.getResourceAsStream(SQL_ERROR_CODES_PROPERTIES); properties.load(resources); } catch (IOException e) { throw new AxonConfigurationException("Unable to read from a file that should be ", e); } finally { IOUtils.closeQuietly(resources); } return properties; } }
@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } SerializedObject<InputStream> converted = converter.convert(serializedObject, InputStream.class); ObjectInputStream ois = null; try { ois = new ObjectInputStream(converted.getData()); return (T) ois.readObject(); } catch (ClassNotFoundException | IOException e) { throw new SerializationException("An error occurred while deserializing: " + e.getMessage(), e); } finally { IOUtils.closeQuietly(ois); } }
@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } if (UnknownSerializedType.class.isAssignableFrom(classForType(serializedObject.getType()))) { return (T) new UnknownSerializedType(this, serializedObject); } SerializedObject<InputStream> converted = converter.convert(serializedObject, InputStream.class); ObjectInputStream ois = null; try { ois = new ObjectInputStream(converted.getData()); return (T) ois.readObject(); } catch (ClassNotFoundException | IOException e) { throw new SerializationException("An error occurred while deserializing: " + e.getMessage(), e); } finally { IOUtils.closeQuietly(ois); } }