Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-8503

Coverity static analysis: Resource leak in LdapSecurityRealm (Elytron)

    XMLWordPrintable

Details

    Description

      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 is good close() is called.

      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.

      LdapSecurityRealm.java
      try (
      Stream<LdapIdentity> identityStream = ldapSearch.search(context)
          .map(result -> new LdapIdentity(result.getNameInNamespace()))
           ) {
              LdapIdentity identity = identityStream.findFirst().orElse(null);
      

      https://scan7.coverity.com/reports.htm#v23632/p11778/fileInstanceId=8553877&defectInstanceId=2139014&mergedDefectId=1397422

      Attachments

        Issue Links

          Activity

            People

              rhn-support-ivassile Ilia Vassilev
              mchoma@redhat.com Martin Choma
              Martin Choma Martin Choma
              Martin Choma Martin Choma
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: