Skip to content

Commit 845b703

Browse files
[azeventhubs] Fixed bug where AMQP sessions weren't being closed. (Azure#24198)
Fixes Azure#24195
1 parent 569cb10 commit 845b703

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

sdk/messaging/azeventhubs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 1.3.1 (TBD)
4+
5+
### Bugs Fixed
6+
7+
- Removed a memory leak that could occur when the ConsumerClient was unable to open a partition. (PR#24198)
8+
39
## 1.3.0 (2025-02-11)
410

511
### Features Added

sdk/messaging/azeventhubs/internal/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
package internal
55

66
// Version is the semantic version number
7-
const Version = "v1.3.0"
7+
const Version = "v1.3.1"

sdk/messaging/azeventhubs/internal/links.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,19 @@ func (ls *linkState[LinkT]) Close(ctx context.Context) error {
365365
ls.cancelAuth()
366366
}
367367

368+
var linkCloseErr error
369+
368370
if ls.link != nil {
369-
return ls.Link().Close(ctx)
371+
// we're more interested in a link failing to close than we are in
372+
// the session.
373+
linkCloseErr = ls.Link().Close(ctx)
370374
}
371375

372-
return nil
376+
if ls.session != nil {
377+
_ = ls.session.Close(ctx)
378+
}
379+
380+
return linkCloseErr
373381
}
374382

375383
func (ls *linkState[LinkT]) PartitionID() string {

sdk/messaging/azeventhubs/internal/links_unit_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func TestLinks_ConnectionRecovery(t *testing.T) {
134134
ns.EXPECT().NegotiateClaim(test.NotCancelled, gomock.Any()).Return(cancelNegotiateClaim, negotiateClaimCtx.Done(), nil)
135135
ns.EXPECT().NewAMQPSession(test.NotCancelled).Return(session, uint64(1), nil)
136136

137+
session.EXPECT().Close(gomock.Any())
138+
137139
receiver.EXPECT().LinkName().Return("link1").AnyTimes()
138140

139141
links := NewLinks(ns, "managementPath", func(partitionID string) string {
@@ -226,6 +228,8 @@ func TestLinks_closeWithTimeout(t *testing.T) {
226228
ns.EXPECT().NegotiateClaim(test.NotCancelled, gomock.Any()).Return(cancelNegotiateClaim, negotiateClaimCtx.Done(), nil)
227229
ns.EXPECT().NewAMQPSession(test.NotCancelled).Return(session, uint64(1), nil)
228230

231+
session.EXPECT().Close(gomock.Any())
232+
229233
receiver.EXPECT().LinkName().Return("link1").AnyTimes()
230234

231235
links := NewLinks(ns, "managementPath", func(partitionID string) string {
@@ -271,6 +275,7 @@ func TestLinks_linkRecoveryOnly(t *testing.T) {
271275
cancelNegotiateClaim, negotiateClaimCtx.Done(), nil,
272276
)
273277
fakeNS.EXPECT().NewAMQPSession(test.NotCancelled).Return(session, uint64(1), nil)
278+
session.EXPECT().Close(gomock.Any())
274279

275280
fakeReceiver.EXPECT().LinkName().Return("link1").AnyTimes()
276281

@@ -306,6 +311,7 @@ func TestLinks_linkRecoveryFailsWithLinkFailure(t *testing.T) {
306311
cancelNegotiateClaim, negotiateClaimCtx.Done(), nil,
307312
)
308313
fakeNS.EXPECT().NewAMQPSession(test.NotCancelled).Return(session, uint64(1), nil)
314+
session.EXPECT().Close(gomock.Any())
309315

310316
fakeReceiver.EXPECT().LinkName().Return("link1").AnyTimes()
311317

0 commit comments

Comments
 (0)