Skip to content

Fix empty ID assertion, simplify equality check#10330

Open
zbynek wants to merge 3 commits into
gwtproject:mainfrom
zbynek:npe
Open

Fix empty ID assertion, simplify equality check#10330
zbynek wants to merge 3 commits into
gwtproject:mainfrom
zbynek:npe

Conversation

@zbynek

@zbynek zbynek commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

This fixes two issues found by nullness analysis:

  • the assertion of non-empty IDs for ARIA purposes was logically wrong. When Id is created from an element, the id attribute is never null and the empty string check was skipped. When Id is created from a string (never happens in GWT itself) and the string happens to be null, the assertion would result in NPE rather than assertion error.
  • the other issue is with slightly inefficient re-implementation of Objects.equals which had an unused null check (I assume the API didn't exist in JDK back when this wasimplemented, but can be used now).

Comment thread user/src/com/google/gwt/cell/client/EditTextCell.java Outdated
ViewData vd = (ViewData) o;
return equalsOrBothNull(original, vd.original)
&& equalsOrBothNull(text, vd.text) && isEditing == vd.isEditing
return Objects.equals(original, vd.original)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, use pattern match instanceof in the return here, something like

Suggested change
return Objects.equals(original, vd.original)
return o instanceof ViewData vd
&& Objects.equals(original, vd.original)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to start using Java 17 features?

Co-authored-by: Colin Alworth <colin@vertispan.com>
@zbynek zbynek added the ready This PR has been reviewed by a maintainer and is ready for a CI run. label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready This PR has been reviewed by a maintainer and is ready for a CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants