tpalfy commented on a change in pull request #5145:
URL: https://github.com/apache/nifi/pull/5145#discussion_r680982282



##########
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:
       Referencing `VersionedProcessGroup` would not be a good indicator of the 
reason here in my opinion. The real problem is the `XmlRootElement` (or the 
lack thereof). It just so happens that at this point it's the 
`VersionedProcessGroup` that is missing it.
   
   In other words, if we had an `if-else`, the reason why the 
`VersionedProcessGroup` is problematic wouldn't be clear at all. Also it's 
almost guaranteed that we would never recognise when this check becomes no 
longer necessary and as specific as it would be it'd become a piece of code 
that would be there for 'historical reasons'.
   
   `clazz.getAnnotation(XmlRootElement.class)` brings in the `XmlRootElement` 
reference but I guess that's a reasonable compromise.




-- 
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]


Reply via email to