Skip to content

Commit 295d223

Browse files
committed
check parameter
1 parent 4476701 commit 295d223

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

queue/linked_blocking_queue.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,17 @@ func (q *LinkedBlockingQueue) Clear() {
391391
// defer q.fullyUnlock()
392392
}
393393

394+
/**
395+
* @Description: create a LinkedBlockingQueue with the given capacity.
396+
if capacity is 0, it'll be replace by math.MaxInt32,
397+
if capacity is less than 0, IllegalArgumentError will be panic
398+
* @param capacity
399+
* @return *LinkedBlockingQueue
400+
*/
394401
func NewLinkedBlockingQueue(capacity int) *LinkedBlockingQueue {
402+
if capacity < 0 {
403+
panic(IllegalArgumentError)
404+
}
395405
if capacity == 0 {
396406
capacity = math.MaxInt32
397407
}

0 commit comments

Comments
 (0)