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/14 11:25:39 UTC
[plc4x] branch develop updated: fix(plc4go/connection-cache): fix panic when a initialized connection is returned
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 8b13c4ab1 fix(plc4go/connection-cache): fix panic when a initialized connection is returned
8b13c4ab1 is described below
commit 8b13c4ab1af785e2e493c881133063bf0ebcf28b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Sep 14 13:25:32 2022 +0200
fix(plc4go/connection-cache): fix panic when a initialized connection is returned
---
plc4go/pkg/api/cache/plc_connection_container.go | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/plc4go/pkg/api/cache/plc_connection_container.go b/plc4go/pkg/api/cache/plc_connection_container.go
index e61eda54c..5d97cf796 100644
--- a/plc4go/pkg/api/cache/plc_connection_container.go
+++ b/plc4go/pkg/api/cache/plc_connection_container.go
@@ -104,6 +104,7 @@ func (t *connectionContainer) connect() {
for _, waitingClient := range t.queue {
waitingClient <- _default.NewDefaultPlcConnectionConnectResult(nil, connectionResult.GetErr())
}
+ t.queue = nil
}
}
}
@@ -150,14 +151,14 @@ func (t *connectionContainer) returnConnection(state cachedPlcConnectionState) e
// 1) The connection failed to get established (No connection has a lock anyway)
// 2) The connection is returned, then the one returning it already has a lock on it.
// If the connection is marked as "invalid", destroy it and remove it from the cache.
- if state == StateInvalid {
+ switch state {
+ case StateInitialized, StateInvalid:
// TODO: Perhaps do a maximum number of retries and then call failConnection()
log.Debug().Str("connectionString", t.connectionString).
- Msg("Client returned invalid connection, reconnecting.")
+ Msgf("Client returned a %s connection, reconnecting.", state)
t.connect()
- } else {
- log.Debug().Str("connectionString", t.connectionString).
- Msg("Client returned valid connection.")
+ default:
+ log.Debug().Str("connectionString", t.connectionString).Msg("Client returned valid connection.")
}
// Check how many others are waiting for this connection.