teragrep / rlp_03

Java RELP Server library
GNU Affero General Public License v3.0
1 stars 5 forks source link

Coverity: CID 454007: Exceptional resource leaks (RESOURCE_LEAK) in ClientFactory.java #125

Closed StrongestNumber9 closed 7 months ago

StrongestNumber9 commented 7 months ago

Describe the bug

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 454007:  Exceptional resource leaks  (RESOURCE_LEAK)
/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java: 76 in com.teragrep.rlp_03.client.ClientFactory.open([java.net](http://java.net/).InetSocketAddress)()

________________________________________________________________________________________________________
*** CID 454007:  Exceptional resource leaks  (RESOURCE_LEAK)
/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java: 76 in com.teragrep.rlp_03.client.ClientFactory.open([java.net](http://java.net/).InetSocketAddress)()
70                 throws IOException, InterruptedException, ExecutionException {
71             // this is for returning ready connection
72             CompletableFuture<EstablishedContext> readyContextFuture = new CompletableFuture<>();
73             Consumer<EstablishedContext> establishedContextConsumer = readyContextFuture::complete;
74     
75             ClientDelegate clientDelegate = new ClientDelegate();
>>>     CID 454007:  Exceptional resource leaks  (RESOURCE_LEAK)
>>>     Variable "clientDelegate" going out of scope leaks the resource it refers to.
76             ConnectContext connectContext = connectContextFactory
77                     .create(inetSocketAddress, clientDelegate, establishedContextConsumer);
78             LOGGER.debug("registering to eventLoop <{}>", eventLoop);
79             eventLoop.register(connectContext);
80             LOGGER.debug("registered to eventLoop <{}>", eventLoop);
81             EstablishedContext establishedContext = readyContextFuture.get();
82             LOGGER.debug("returning establishedContext <{}>", establishedContext);
83             return clientDelegate.create(establishedContext);
84         }

Additional context

Reported by Coverity