You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Mark Payne (Jira)" <ji...@apache.org> on 2020/05/28 16:02:00 UTC

[jira] [Created] (NIFI-7494) CassandraSessionProvider leaks resources when authentication fails

Mark Payne created NIFI-7494:
--------------------------------

             Summary: CassandraSessionProvider leaks resources when authentication fails
                 Key: NIFI-7494
                 URL: https://issues.apache.org/jira/browse/NIFI-7494
             Project: Apache NiFi
          Issue Type: Bug
          Components: Extensions
            Reporter: Mark Payne


The @OnEnabled method of CassandraSessionProvider creates a few different resources:
{code:java}
Cluster newCluster = createCluster(contactPoints, sslContext, username, password, compressionType);
PropertyValue keyspaceProperty = context.getProperty(KEYSPACE).evaluateAttributeExpressions();
final Session newSession;
if (keyspaceProperty != null) {
    newSession = newCluster.connect(keyspaceProperty.getValue());
} else {
    newSession = newCluster.connect();
}
newCluster.getConfiguration().getQueryOptions().setConsistencyLevel(ConsistencyLevel.valueOf(consistencyLevel));
Metadata metadata = newCluster.getMetadata();
log.info("Connected to Cassandra cluster: {}", new Object[]{metadata.getClusterName()});

cluster = newCluster;
cassandraSession = newSession;
 {code}
If the authentication fails, an Exception is closed from newCluster.connect(). 

This is done after the `Cluster` object has been created, though, and `Cluster` is Closeable. Any Exception that is thrown by the @OnEnabled method after creating the `Cluster` must be caught and `Cluster` must be closed. The Exception can then be re-thrown.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)