exceptionfactory commented on a change in pull request #5145:
URL: https://github.com/apache/nifi/pull/5145#discussion_r680952160
##########
File path:
nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/serialization/jaxb/JAXBSerializer.java
##########
@@ -88,9 +98,15 @@ public T deserialize(final InputStream input) throws
SerializationException {
try {
// Consume the header bytes.
readDataModelVersion(input);
+
+ XMLStreamReader streamReader =
XMLInputFactory.newInstance().createXMLStreamReader(input);
+
final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- return (T) unmarshaller.unmarshal(input);
- } catch (JAXBException e) {
+ JAXBElement<T> jaxbElement = unmarshaller.unmarshal(streamReader,
clazz);
+ T deserializedObject = jaxbElement.getValue();
+
+ return deserializedObject;
Review comment:
I can see usefulness in a separate variable in some cases, particularly
if it is the result of a complicated method. In this case, the value is a
member variable of `JAXBElement`. IntelliJ flags this as redundant in the
default configuration, which is not an absolute rule, but in this particular
instance, having a separate variable does not seem to add much value for
debugging.
--
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]