[jboss-jira] [JBoss JIRA] (ELY-924) Coverity static analysis: Resource leak in LdapSecurityRealm (Elytron)
Ilia Vassilev (JIRA)
issues at jboss.org
Mon Feb 6 09:19:01 EST 2017
[ https://issues.jboss.org/browse/ELY-924?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ilia Vassilev moved WFLY-7964 to ELY-924:
-----------------------------------------
Project: WildFly Elytron (was: WildFly)
Key: ELY-924 (was: WFLY-7964)
Component/s: (was: Security)
Affects Version/s: 1.1.0.Beta21
(was: 11.0.0.Alpha1)
> Coverity static analysis: Resource leak in LdapSecurityRealm (Elytron)
> ----------------------------------------------------------------------
>
> Key: ELY-924
> URL: https://issues.jboss.org/browse/ELY-924
> Project: WildFly Elytron
> Issue Type: Bug
> Affects Versions: 1.1.0.Beta21
> Reporter: Martin Choma
> Assignee: Ilia Vassilev
> Priority: Critical
>
> Coverity static-analysis scan found resource leak in LdapSecurityRealm.getIdentity().
> It has to be in try-with-resources, because Stream<LdapIdentity> has registered close handler, where NamingEnumeration.close() is called. Looking into one possible implementation http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/com/sun/jndi/ldap/LdapNamingEnumeration.java#LdapNamingEnumeration It would be safer to call close() explicitelly.
> However chained stream statement is used in try, which cause 2 Stream objects to be created. But only one of them is closed. Stream created by ldapSearch.search(context) (with exlicitely registered close handler) is not closed.
> {code:java|title=LdapSecurityRealm.java}
> try (
> Stream<LdapIdentity> identityStream = ldapSearch.search(context)
> .map(result -> new LdapIdentity(result.getNameInNamespace()))
> ) {
> LdapIdentity identity = identityStream.findFirst().orElse(null);
> {code}
> https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=8553877&defectInstanceId=2139014&mergedDefectId=1397422
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list