-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
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
WorkbookEditorsHandler: Fix NPE in case name is null #1286
WorkbookEditorsHandler: Fix NPE in case name is null #1286
Conversation
Test Results 899 files - 1 899 suites - 1 42m 13s ⏱️ - 9m 39s For more details on these failures, see this check. Results for commit b5aad0e. ± Comparison against base commit 4c5fccc. ♻️ This comment has been updated with latest results. |
@@ -162,10 +164,10 @@ private List<EditorReference> getParts(WorkbenchPage page) { | |||
*/ | |||
private Map<EditorReference, String> generateColumnLabelTexts(List<EditorReference> editorReferences) { | |||
Map<EditorReference, String> editorReferenceLabelTexts = new HashMap<>(editorReferences.size()); | |||
Map<String, List<EditorReference>> collisionsMap = editorReferences.stream() | |||
.collect(Collectors.groupingBy(r -> r.getName())); | |||
Map<Optional<String>, List<EditorReference>> collisionsMap = editorReferences.stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe one should filter out null
names altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then they would disappear from Ctrl-E?
I guess keeping them is the safest approach for now and just fix the regression introduced by 03277d3 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using Objects.requireNonNullOrElse(r.getName(), "N/A");
if the only problem is that name is null (whatever that the should mean to the user).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a better solution:
The actual intended text to be used in Ctrl-E (if unique), is ref.getTitle()
,
Line 821 in 5b62380
return ref.getTitle(); |
which is already null-safe (returns ""
in that case):
Lines 227 to 240 in 5b62380
@Override | |
public String getTitle() { | |
String label = Util.safeString(getModel().getLocalizedLabel()); | |
if (label.isEmpty()) { | |
if (input == null) { | |
if (descriptor != null) { | |
return descriptor.getLabel(); | |
} | |
} else { | |
return Util.safeString(input.getName()); | |
} | |
} | |
return label; | |
} |
But in 03277d3 I have inadvertently used getName()
to populate the collisionMap
.
It should simply also use getTitle()
.
67cfb45
to
a88b209
Compare
Any objections to merge like this? (I don't know why the build is failing, but it's definitely unrelated). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't merge, API tools are broken. @laeubi : please take a look.
See https://ci.eclipse.org/platform/job/eclipse.platform.ui/job/PR-1286/4/console
09:45:32.437 [ERROR] Failed to execute goal org.eclipse.tycho:tycho-apitools-plugin:4.0.4:verify (verify) on project org.eclipse.ui.workbench: There are API errors:
09:45:32.437 [ERROR] Eclipse UI/org/eclipse/ui/AbstractSourceProvider.java:31 The type org.eclipse.ui.AbstractSourceProvider has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/ActiveShellExpression.java:32 The type org.eclipse.ui.ActiveShellExpression has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/BasicWorkingSetElementAdapter.java:58 The type org.eclipse.ui.BasicWorkingSetElementAdapter has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/ExtensionFactory.java:46 The type org.eclipse.ui.ExtensionFactory has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionBars.java:66 The type org.eclipse.ui.IActionBars has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionBars2.java:24 The type org.eclipse.ui.IActionBars2 has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionDelegate.java:53 The type org.eclipse.ui.IActionDelegate has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionDelegate2.java:42 The type org.eclipse.ui.IActionDelegate2 has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionDelegateWithEvent.java:34 The type org.eclipse.ui.IActionDelegateWithEvent has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IActionFilter.java:52 The type org.eclipse.ui.IActionFilter has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IAggregateWorkingSet.java:30 The type org.eclipse.ui.IAggregateWorkingSet has been removed from org.eclipse.ui.workbench_3.131.0
09:45:32.438 [ERROR] Eclipse UI/org/eclipse/ui/IContainmentAdapter.java:22 The type
...
see eclipse-equinox/p2#382 (comment) |
@@ -163,7 +163,7 @@ private List<EditorReference> getParts(WorkbenchPage page) { | |||
private Map<EditorReference, String> generateColumnLabelTexts(List<EditorReference> editorReferences) { | |||
Map<EditorReference, String> editorReferenceLabelTexts = new HashMap<>(editorReferences.size()); | |||
Map<String, List<EditorReference>> collisionsMap = editorReferences.stream() | |||
.collect(Collectors.groupingBy(r -> r.getName())); | |||
.collect(Collectors.groupingBy(r -> r.getTitle())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about replacing null with empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getTitle()
already does that and does not return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that can return descriptor.getLabel() that can return configurationElement.getAttribute(IWorkbenchRegistryConstants.ATT_NAME); that can return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I have added another Util.safeString() guard around it.
a88b209
to
47ccb55
Compare
|
it's tychos problem eclipse-tycho/tycho#3019 |
Regression was introduced in 03277d3, where getTitle() was accidentally changed to getName(). Revert that back to getTitle(). getTitle() is already null-safe in most cases, but to be 100% safe, guard it using Util.safeString() again. Fixes eclipse-platform#1275.
47ccb55
to
b5aad0e
Compare
@iloveeclipse: Any objections to merge for RC1? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@vogella @merks we need a PL/PMC approval for RC1 I think its worth to be considered. |
PMC +1 I do generally trust that folks will use their discretion to fix things that really ought to be fixed and to avoid changing things that are risk. |
Fixes #1275.
(Regression was introduced in 03277d3)