You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/09/08 16:32:28 UTC

[plc4x] branch develop updated: fix(plc4go/connection-cache): fix NPE on connection close

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new cc322f09f fix(plc4go/connection-cache): fix NPE on connection close
cc322f09f is described below

commit cc322f09f4295a7c5020e3fcc183c77986b568aa
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Sep 8 18:32:20 2022 +0200

    fix(plc4go/connection-cache): fix NPE on connection close
---
 plc4go/pkg/api/cache/plc_connection_cache.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plc4go/pkg/api/cache/plc_connection_cache.go b/plc4go/pkg/api/cache/plc_connection_cache.go
index 64c261526..71c77e307 100644
--- a/plc4go/pkg/api/cache/plc_connection_cache.go
+++ b/plc4go/pkg/api/cache/plc_connection_cache.go
@@ -218,12 +218,16 @@ func (t *plcConnectionCache) Close() <-chan PlcConnectionCacheCloseResult {
 				case _ = <-leaseResults:
 					log.Debug().Str("connectionString", container.connectionString).Msg("Gracefully closing connection ...")
 					// Give back the connection.
-					container.connection.Close()
+					if container.connection != nil {
+						container.connection.Close()
+					}
 				// If we're timing out brutally kill the connection.
 				case <-closeTimeout.C:
 					log.Debug().Str("connectionString", container.connectionString).Msg("Forcefully closing connection ...")
 					// Forcefully close this connection.
-					container.connection.Close()
+					if container.connection != nil {
+						container.connection.Close()
+					}
 				}
 
 				responseDeliveryTimeout := time.NewTimer(10 * time.Millisecond)