Java.lang.nullpointerexception element cannot be mapped to a null key

Bug 579512 - Internal error exporting plug-ins or features

Summary:Internal error exporting plug-ins or features

Status: RESOLVED FIXED
Alias: None
Product:PDE
Classification:Eclipse Project
Component:Build (show other bugs)
Version:4.23  
Java.lang.nullpointerexception element cannot be mapped to a null key
Hardware:PC Windows 10
Importance: P3 normal (vote)
Target Milestone:---  
Java.lang.nullpointerexception element cannot be mapped to a null key
Assignee:Vikas Chandra
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
Reported: 2022-03-30 12:13 EDT by Gunnar Arndt
Modified: 2022-05-17 07:46 EDT (History)
CC List: 3 users (show)
See Also:


Attachments
Sample project without dependencies that fails to export (1.43 MB, application/x-zip-compressed)
2022-03-31 04:06 EDT, Gunnar Arndt
no flags Details
Eclipse sample plugin (4.63 KB, application/x-zip-compressed)
2022-04-05 10:31 EDT, Gunnar Arndt
no flags Details
Plain Java project with manifest (3.35 KB, application/x-zip-compressed)
2022-04-06 08:23 EDT, Gunnar Arndt
no flags Details
patch (910 bytes, patch)
2022-04-06 11:06 EDT, Vikas Chandra
no flags Details | Diff
Export Product error (30.35 KB, image/png)
2022-05-17 07:30 EDT, Jean-Pascal Laux
no flags Details
View All Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this bug.



Java NullPointerException: element cannot be mapped to a null key问题解决

Java.lang.nullpointerexception element cannot be mapped to a null key

旭东怪

Java.lang.nullpointerexception element cannot be mapped to a null key
已于 2022-03-16 15:03:24 修改
Java.lang.nullpointerexception element cannot be mapped to a null key
1536
Java.lang.nullpointerexception element cannot be mapped to a null key
收藏 1

于 2022-03-16 15:02:59 首次发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

问题描述:

java.lang.NullPointerException: element cannot be mapped to a null key

问题分析:

1、使用Collectors.groupingBy()进行分组时,分组值存在null值。

List<String> strList = new ArrayList<>(Arrays.asList("11", "12", "13", null, null));
Map<String, List<String>> map = strList.stream().collect(Collectors.groupingBy(x -> x));

解决办法:分组值为null时,默认值为空字符。

List<String> strList = new ArrayList<>(Arrays.asList("11", "12", "13", null, null));
Map<String, List<String>> map = strList.stream().collect(Collectors.groupingBy(x -> StrUtil.isEmpty(x) ? "" : x));