Skip to content
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

Open
wants to merge 5 commits into
base: 2023.06.x
Choose a base branch
from

Conversation

Antoniafriedrich
Copy link
Contributor

Copy link
Member

@yagee-de yagee-de left a 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

Comment on lines 84 to 85
results.put(dir.relativize(file).toString(), new ValidationErrorResult());

Copy link
Member

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.

Comment on lines 172 to 201
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());
}
}
Copy link
Member

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

Comment on lines 144 to 148
List<Element> exceptions = createExceptionElements(document, resultEntry.exception());
Element exceptionElements = document.createElement("exceptions");
for (Element exception : exceptions) {
exceptionElements.appendChild(exception);
}
Copy link
Member

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.

Comment on lines 178 to 180
if (currentException == null || exceptionsQueue.contains(currentException)) {
return exceptionElementList;
}
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants