-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCR-3214 Add handlings for non validatable pdf documents #2299
base: 2023.06.x
Are you sure you want to change the base?
MCR-3214 Add handlings for non validatable pdf documents #2299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidationErrorResult seems not to fit the purpose
results.put(dir.relativize(file).toString(), new ValidationErrorResult()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Details (cause, stacktrace) of Exception are lost here. Better way is to put the Exception into the map and serialize at least the cause into the Document. You could use a record to old ValidationResult or Exception and use it as a map value.
while (!exceptionsQueue.isEmpty()) { | ||
Throwable currentException = exceptionsQueue.poll(); | ||
Element exceptionElement = document.createElement("exception"); | ||
|
||
Element classElement = document.createElement("class"); | ||
classElement.setAttribute("name", currentException.getClass().getName()); | ||
exceptionElement.appendChild(classElement); | ||
|
||
if (currentException.getMessage() != null) { | ||
Element messageElement = document.createElement("message"); | ||
messageElement.setAttribute("message", currentException.getMessage()); | ||
exceptionElement.appendChild(messageElement); | ||
} | ||
|
||
Element stackTraceElement = document.createElement("stackTrace"); | ||
for (StackTraceElement ste : currentException.getStackTrace()) { | ||
Element frameElement = document.createElement("frame"); | ||
frameElement.setAttribute("text", ste.toString()); | ||
stackTraceElement.appendChild(frameElement); | ||
} | ||
exceptionElement.appendChild(stackTraceElement); | ||
|
||
exceptionElementList.add(exceptionElement); | ||
|
||
exceptionsQueue.addAll(List.of(currentException.getSuppressed())); | ||
if (currentException.getCause() != null && | ||
!currentException.getCause().equals(currentException)) { | ||
exceptionsQueue.add(currentException.getCause()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a hierarchy of elements not a list. We need to know what are causes and what a suppressed exception of which exception
List<Element> exceptions = createExceptionElements(document, resultEntry.exception()); | ||
Element exceptionElements = document.createElement("exceptions"); | ||
for (Element exception : exceptions) { | ||
exceptionElements.appendChild(exception); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You hand over an Exception and receive a List of Exception Elements? I think only one exception could be thrown finally and caught. So no need for "" or a List return type.
if (currentException == null || exceptionsQueue.contains(currentException)) { | ||
return exceptionElementList; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you have a tree, how can an exception be in there twice?
Link to jira.