Prevent NPE if pushes/gets occur after the db is already closed #6

Merged
lunny merged 1 commits from zeripath/levelqueue:prevent-npe-when-closed into master 2022-07-29 05:47:28 +00:00
Contributor

Due to the nil-ing out of the .db fields when Close is called any
further calls to the queue/set functions will result in an NPE.

This PR protects against this.

Signed-off-by: Andrew Thornton art27@cantab.net

Due to the nil-ing out of the `.db` fields when `Close` is called any further calls to the queue/set functions will result in an NPE. This PR protects against this. Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added 1 commit 2022-07-28 20:53:35 +00:00
Prevent NPE if pushes/gets occur after the db is already closed
Due to the nil-ing out of the `.db` fields when `Close` is called any
further calls to the queue/set functions will result in an NPE.

This PR protects against this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/pr Build is passing
e7efcd331d
lunny reviewed 2022-07-29 01:58:47 +00:00
@ -301,3 +321,3 @@
defer queue.highLock.Unlock()
if !queue.closeUnderlyingDB {
if !queue.closeUnderlyingDB || queue.db == nil {
Owner

Is this really necessary?

Is this really necessary?
First-time contributor

IMO it's necessary. closeUnderlyingDB can be true or false. But the code below shouldn't access nil db.

IMO it's necessary. closeUnderlyingDB can be true or false. But the code below shouldn't access nil db.
lunny marked this conversation as resolved
@ -184,3 +184,3 @@
queue.set.lock.Lock()
defer queue.set.lock.Unlock()
if !queue.closeUnderlyingDB {
if !queue.closeUnderlyingDB || queue.db == nil {
Owner

As above.

As above.
lunny marked this conversation as resolved
wxiaoguang approved these changes 2022-07-29 02:12:07 +00:00
lunny approved these changes 2022-07-29 05:47:20 +00:00
lunny merged commit f020868cc2 into master 2022-07-29 05:47:28 +00:00
zeripath deleted branch prevent-npe-when-closed 2022-07-29 09:53:59 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/levelqueue#6
No description provided.