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 d3b2795fd8 fix(plc4go/bacnetip): ensure proper shutdown of connections
d3b2795fd8 is described below
commit d3b2795fd8f5464e8426a24cba65977f00775402
Author: Sebastian Rühl <[email protected]>
AuthorDate: Thu Jul 2 10:11:38 2026 +0200
fix(plc4go/bacnetip): ensure proper shutdown of connections
---
plc4go/internal/bacnetip/Connection.go | 6 ++++++
plc4go/internal/bacnetip/Connection_test.go | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/plc4go/internal/bacnetip/Connection.go
b/plc4go/internal/bacnetip/Connection.go
index 952b48b4a6..2500ae2f61 100644
--- a/plc4go/internal/bacnetip/Connection.go
+++ b/plc4go/internal/bacnetip/Connection.go
@@ -128,6 +128,12 @@ func (c *Connection) Connect(ctx context.Context) error {
return nil
}
+func (c *Connection) Close() error {
+ err := c.DefaultConnection.Close()
+ c.wg.Wait()
+ return err
+}
+
func (c *Connection) passToDefaultIncomingMessageChannel() {
incomingMessageChannel :=
c.messageCodec.GetDefaultIncomingMessageChannel()
// Block (with a short timeout so the Connect loop can re-check
IsConnected
diff --git a/plc4go/internal/bacnetip/Connection_test.go
b/plc4go/internal/bacnetip/Connection_test.go
index 184d728d81..f6f260e2c5 100644
--- a/plc4go/internal/bacnetip/Connection_test.go
+++ b/plc4go/internal/bacnetip/Connection_test.go
@@ -23,6 +23,8 @@ import (
"math"
"testing"
+ "github.com/apache/plc4x/plc4go/spi/options"
+ "github.com/apache/plc4x/plc4go/spi/testutils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -67,7 +69,7 @@ func TestConnection_BuildersReturnNonNil(t *testing.T) {
func TestConnection_AddSubscriber_IsIdempotent(t *testing.T) {
conn := newTestConnection(t, map[string][]string{})
- sub := NewSubscriber(conn)
+ sub := NewSubscriber(conn,
options.WithCustomLogger(testutils.ProduceTestingLogger(t)))
conn.addSubscriber(sub)
conn.addSubscriber(sub) // second add should be a no-op
assert.Len(t, conn.subscribers, 1)