全局异常 element cannot be mapped to a null key >>>>>>>>>>>>>>

全局异常 element cannot be mapped to a null key >>>>>>>>>>>>>>:

2019-12-24 10:29:10.363 [tms: d6e158839dd7ea27][http-nio-8008-exec-8] ERROR com.runlion.sat.tools.handler.ExceptionHandler - >>>>>>>>> 全局异常 element cannot be mapped to a null key >>>>>>>>>>>>>>
java.lang.NullPointerException: element cannot be mapped to a null key
	at java.util.Objects.requireNonNull(Objects.java:228)
	at java.util.stream.Collectors.lambda$groupingBy$45(Collectors.java:907)
	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at com.runlion.sat.tms.service.impl.BillFeeServiceImpl.listTotalFee(BillFeeServiceImpl.java:269)

代码:

Map> feeGroup = feeVOList.stream()
					.collect(Collectors.groupingBy(BillFeeVO::getBizOperator));

//按照BizOperator分组,此时BizOperator有空值,就会报错。
// 改为,增加非空过滤。
Map> feeGroup = feeVOList.stream().filter(item->StringUtil.isNotBlank(item.getBizOperator()))
					.collect(Collectors.groupingBy(BillFeeVO::getBizOperator));

 

你可能感兴趣的:(异常)