Skip to content

NIFI-15670 - Replace List of Map with VersionedNodeState to fix JAXB compatibility#76

Merged
pvillard31 merged 1 commit intoapache:mainfrom
pvillard31:NIFI-15670-jaxb
Mar 6, 2026
Merged

NIFI-15670 - Replace List of Map with VersionedNodeState to fix JAXB compatibility#76
pvillard31 merged 1 commit intoapache:mainfrom
pvillard31:NIFI-15670-jaxb

Conversation

@pvillard31
Copy link
Contributor

Summary

NIFI-15670 - Replace List of Map with VersionedNodeState to fix JAXB compatibility

Without the fix:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.nifi.registry.serialization.jaxb.TestJAXBVersionedProcessGroupSerializer
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.083 s <<< FAILURE! -- in org.apache.nifi.registry.serialization.jaxb.TestJAXBVersionedProcessGroupSerializer
[ERROR] org.apache.nifi.registry.serialization.jaxb.TestJAXBVersionedProcessGroupSerializer.testSerializeDeserializeFlowSnapshot -- Time elapsed: 0.075 s <<< ERROR!
java.lang.RuntimeException: Unable to create JAXBContext: 1 counts of IllegalAnnotationExceptions
	at org.apache.nifi.registry.serialization.jaxb.JAXBSerializer.<init>(JAXBSerializer.java:55)
	at org.apache.nifi.registry.serialization.jaxb.JAXBVersionedProcessGroupSerializer.<init>(JAXBVersionedProcessGroupSerializer.java:27)
	at org.apache.nifi.registry.serialization.jaxb.TestJAXBVersionedProcessGroupSerializer.testSerializeDeserializeFlowSnapshot(TestJAXBVersionedProcessGroupSerializer.java:34)
Caused by: org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.util.Map is an interface, and JAXB can't handle interfaces.
	this problem is related to the following location:
		at java.util.Map
		at public java.util.List org.apache.nifi.flow.VersionedComponentState.getLocalNodeStates()
		at org.apache.nifi.flow.VersionedComponentState
		at public org.apache.nifi.flow.VersionedComponentState org.apache.nifi.flow.VersionedConfigurableExtension.getComponentState()
		at org.apache.nifi.flow.VersionedConfigurableExtension
		at org.apache.nifi.flow.VersionedControllerService
		at public java.util.Set org.apache.nifi.flow.VersionedProcessGroup.getControllerServices()
		at org.apache.nifi.flow.VersionedProcessGroup

	at org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:83)
	at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:421)
	at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:255)
	at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115)
	at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144)
	at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44)
	at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:366)
	at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
	at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)
	at org.apache.nifi.registry.serialization.jaxb.JAXBSerializer.<init>(JAXBSerializer.java:53)
	... 2 more

The NiFi Registry framework includes a FlowContentSerializer that supports multiple data model versions for reading stored flow snapshots. Data model version 1 uses a JAXB-based serializer (JAXBVersionedProcessGroupSerializer), while versions 2 and 3 use Jackson. Although version 1 is a legacy format unlikely to be encountered in practice, all serializers are eagerly instantiated at construction time, meaning JAXB must be able to create a context for the entire VersionedProcessGroup class hierarchy.

This change introduces a VersionedNodeState wrapper class containing Map<String, String> and changes localNodeStates from List<Map<String, String>> to List<VersionedNodeState>, which JAXB can handle since it is a concrete class.

Test plan

  • mvn clean install on nifi-api passes
  • Install the updated API locally, then run mvn test -pl nifi-registry/nifi-registry-core/nifi-registry-framework on NiFi main to confirm the 10 JAXB test failures are resolved
  • localNodeStates is not yet used in NiFi, so there is no downstream code to update

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Copy link
Contributor

@kevdoran kevdoran left a comment

Choose a reason for hiding this comment

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

Nice improvement, thanks @pvillard31

@pvillard31 pvillard31 merged commit e18f433 into apache:main Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants