We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
核心阻塞队列枚举类中方法 BlockingQueueTypeEnum.createBlockingQueue(String blockingQueueName, Integer capacity) 在参数均为null时,会抛出异常
BlockingQueueTypeEnum.createBlockingQueue(String blockingQueueName, Integer capacity)
null
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because "capacity" is null
生成new LinkedBlockingQueue<T>(DEFAULT_CAPACITY);
new LinkedBlockingQueue<T>(DEFAULT_CAPACITY);
blockingQueueName
capacity
customOrDefaultQueue(Integer capacity, Predicate<CustomBlockingQueue> predicate)
return new LinkedBlockingQueue<T>(temCapacity);
of(String blockingQueueName, Integer capacity)
DEFAULT_CAPACITY
capacity <=0
IllegalArgumentException
int temCapacity = capacity;
Integer为null并赋值给int会抛出NPE。
调用方法
BlockingQueueTypeEnum.createBlockingQueue("abc", null); BlockingQueueTypeEnum.createBlockingQueue(null, null)
将temCapacity修改为Integer, 或者capacity判空的条件前置
temCapacity
Integer
The text was updated successfully, but these errors were encountered:
如果确认,请分配给我。
Sorry, something went wrong.
@LiXuemin welcome
LiXuemin
Successfully merging a pull request may close this issue.
BUG 报告
问题
核心阻塞队列枚举类中方法
BlockingQueueTypeEnum.createBlockingQueue(String blockingQueueName, Integer capacity)
在参数均为
null
时,会抛出异常预期行为
生成
new LinkedBlockingQueue<T>(DEFAULT_CAPACITY);
原因分析
正常逻辑,代码已覆盖如下各自情况
blockingQueueName
和capacity
均合法:正常生成blockingQueueName
为空,capacity
合法:会在私有方法customOrDefaultQueue(Integer capacity, Predicate<CustomBlockingQueue> predicate)
中返回默认阻塞队列return new LinkedBlockingQueue<T>(temCapacity);
blockingQueueName
合法,capacity
不合法:会在私有方法of(String blockingQueueName, Integer capacity)
中调用各阻塞队列的构造方法。capacity
为null
不同阻塞队列会调用各自无参构造方法或者使用DEFAULT_CAPACITY
;capacity <=0
会由各阻塞队列抛出IllegalArgumentException
。异常
blockingQueueName
为null
或使用不存在的字符串,capacity
为null
: 最终会进入私有方法customOrDefaultQueue(Integer capacity, Predicate<CustomBlockingQueue> predicate)
中,此时Integer为null并赋值给int会抛出NPE。
问题重现步骤
调用方法
修复办法
将
temCapacity
修改为Integer
, 或者capacity
判空的条件前置The text was updated successfully, but these errors were encountered: