GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Xpp3Dom.getValue(): honor @NonNull contract by elharo · Pull Request #389 · apache/maven-shared-utils

Conversation

@elharo

@elharo elharo commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Xpp3Dom.getValue() is annotated @NonNull (line 141) but can return null when the instance was created via new Xpp3Dom(name) (the value field is never initialized in the one-arg constructor).

Fix:

  • getValue() now returns "" when the internal value field is null, upholding the @NonNull contract
  • Added package-private isValueSet() method so Xpp3DomWriter can distinguish between "value was explicitly set to empty string" and "value was never set" — preserving the existing serialization behavior (elements with unset values serialize as self-closing tags)

The builder at Xpp3DomBuilder.java:201 already worked around this with element.setValue(""); // null in xpp3dom, but we don't do that around here.

Fixes #388

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo added 3 commits July 1, 2026 08:44
@elharo
Add failing test: Xpp3Dom default value should not be null
3c95941
@elharo
Xpp3Dom.getValue(): honor @nonnull contract, Xpp3DomWriter: use isVal…
85a7b55
…ueSet()
@elharo
spotless:apply formatting
e6f70f0
@elharo
elharo requested a review from sparsick July 1, 2026 13:07
@elharo elharo added the bug Something isn't working label Jul 1, 2026
sparsick
sparsick approved these changes Jul 1, 2026
View reviewed changes
@elharo
elharo merged commit 5e13d9b into master Jul 1, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@elharo
elharo deleted the fix/xpp3dom-value-null branch July 1, 2026 14:55
@github-actions github-actions Bot assigned elharo Jul 1, 2026
@github-actions github-actions Bot added this to the 3.5.0 milestone Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sparsick sparsick sparsick approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@elharo elharo

Labels

bug Something isn't working

Projects

None yet

Milestone

3.5.0

Development

Successfully merging this pull request may close these issues.

Xpp3Dom.getValue() returns null despite @NonNull annotation

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@elharo @sparsick
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.