Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Fix panic when specifying a nil session ID #232

Merged
merged 1 commit into from
Jun 24, 2021
Merged

Fix panic when specifying a nil session ID #232

merged 1 commit into from
Jun 24, 2021

Conversation

jhendrixMSFT
Copy link
Member

Propagate the session ID selected by the broker when a nil session ID is
specified. This requires an updated go-amqp to work.
Removed validation of EnqueuedSequenceNumber as it's not guaranteed to
be returned.

Propagate the session ID selected by the broker when a nil session ID is
specified.  This requires an updated go-amqp to work.
Removed validation of EnqueuedSequenceNumber as it's not guaranteed to
be returned.
Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One small spot where you could potentially eliminate an 'if'.

I also tend to be pretty generous with comments in the code, not sure how you feel about it. This path feels sufficiently esoteric that it could be useful.

const code = uint64(0x00000137000000C)

if !r.useSessions {
return nil, false
}

if r.sessionID == nil {
return amqp.LinkSourceFilter(name, code, nil), true
return amqp.LinkSourceFilter(sessionFilterName, code, nil), true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you don't need the 'if' here at all (ie, r.SessionID can just be passed unconditionally)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the cases of "when nil isn't nil" in Go, and comes into play with interface{}. When passing nil, the type of the value interface{} param will be nil. When passing r.sessionID, the type will be *string. So while they both could in fact be nil, their underlying types are different. This is important to the marshal function in go-amqp which differentiates between underlying types.

@jhendrixMSFT jhendrixMSFT merged commit 80fa1bc into Azure:master Jun 24, 2021
@jhendrixMSFT jhendrixMSFT deleted the nil_sessionid branch June 24, 2021 00:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants