tpalfy commented on a change in pull request #5145:
URL: https://github.com/apache/nifi/pull/5145#discussion_r680970230
##########
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:
Again, I find it useful to return a single variable.
During debug, one can just put a breakpoint at the return statement and see
right away what that value is.
Also it's great that one can actually give a descriptive _name_ for the
variable which can help understand the code better.
All in all I consider this a matter of preference and plan to leave it as it
is unless I see more suggestions form others to do otherwise.
--
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]