exceptionfactory commented on a change in pull request #5145:
URL: https://github.com/apache/nifi/pull/5145#discussion_r680955581
##########
File path:
nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/serialization/jaxb/JAXBSerializer.java
##########
@@ -73,8 +79,12 @@ public void serialize(final int dataModelVersion, final T t,
final OutputStream
try {
final Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- marshaller.marshal(t, out);
- } catch (JAXBException e) {
+
+ String className = clazz.getSimpleName();
+ String tagName = Character.toLowerCase(className.charAt(0)) +
className.substring(1);
+
+ marshaller.marshal(new JAXBElement<>(new QName(tagName), clazz,
t), out);
Review comment:
I would prefer not to have a try-catch with fall back in this case,
because the reason would not be clear. Although having a direct reference to
`VersionedProcessGroup` might not generally be preferable, it is a clear
indicator of the reason for the workaround.
Use of reflection is simply introspecting the class using
`Class.getAnnotation(XmlRootElement.class)` to determine whether the workaround
is necessary. The getAnnotation() approach would be the most generic, and would
avoid referencing VersionedProcessGroup, although it would be helpful to
include a comment describing the reason for the workaround.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]