Skip to content

Commit

Permalink
fix index out of range, closes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
juancgalvis committed Jul 28, 2021
1 parent 6b0c90f commit 18bfa13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions getbycorrelid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ func TestCorrelIDParsing(t *testing.T) {
msg.SetJMSCorrelationID(testCorrel)
assert.Equal(t, testCorrel, msg.GetJMSCorrelationID())

// Empty correlationID
testCorrel = "000000000000000000000000000000000000000000000000"
msg.SetJMSCorrelationID(testCorrel)
assert.Equal(t, "", msg.GetJMSCorrelationID())

}
6 changes: 2 additions & 4 deletions mqjms/MessageImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ func (msg *MessageImpl) GetJMSCorrelationID() string {
// Here we identify any padding zero bytes to trim off so that we can try
// to turn it back into a string.
realLength := len(correlIDBytes)
if realLength > 0 {
for correlIDBytes[realLength-1] == 0 {
realLength--
}
for realLength > 0 && correlIDBytes[realLength-1] == 0 {
realLength--
}

// Attempt to decode the content back into a string.
Expand Down

0 comments on commit 18bfa13

Please sign in to comment.