[jboss-jira] [JBoss JIRA] (WFLY-7828) Coverity static analysis: Resource leaks in ProviderLoaderService (Elytron subsystem)

Ilia Vassilev (JIRA) issues at jboss.org
Wed Dec 21 10:45:00 EST 2016


     [ https://issues.jboss.org/browse/WFLY-7828?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ilia Vassilev moved ELY-841 to WFLY-7828:
-----------------------------------------

    Project: WildFly  (was: WildFly Elytron)
        Key: WFLY-7828  (was: ELY-841)


> Coverity static analysis: Resource leaks in ProviderLoaderService (Elytron subsystem)
> -------------------------------------------------------------------------------------
>
>                 Key: WFLY-7828
>                 URL: https://issues.jboss.org/browse/WFLY-7828
>             Project: WildFly
>          Issue Type: Bug
>            Reporter: Josef Cacek
>            Assignee: Ilia Vassilev
>            Priority: Critical
>              Labels: static_analysis
>
> Coverity static-analysis scan found 2 resource leaks in {{ProviderLoaderService}} class.
> 1)
> https://scan7.coverity.com/reports.htm#v16159/p12663/fileInstanceId=6892104&defectInstanceId=1794528&mergedDefectId=1388484
> Following code is used in `load` method:
> {code:java}
> if (provider == null) {
>     provider = providerClazz.newInstance();
>     if (configurationStreamSupplier != null) {
>         try (InputStream is = configurationStreamSupplier.get()) {
>             provider.load(configurationStreamSupplier.get());
>         }
>     }
> }
> {code}
> The load method should use `is` instance instead of calling the supplier again.
> 2)
> https://scan7.coverity.com/reports.htm#v16159/p12663/fileInstanceId=6892104&defectInstanceId=1794527&mergedDefectId=1388483
> Following code is used in `toInputStream` method:
> {code:java}
> SecurityActions.doPrivileged((PrivilegedExceptionAction<InputStream>) () -> new FileInputStream(file) );
> return new FileInputStream(file);
> {code}
> There should be probably just:
> {code:java}
> return SecurityActions.doPrivileged((PrivilegedExceptionAction<InputStream>) () -> new FileInputStream(file) );
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list