Skip to content

Fix NPE when importing newspaper course with metadata #6390

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

Merged
merged 8 commits into from
May 9, 2025

Conversation

matthias-ronge
Copy link
Collaborator

Restores functionality for uploading newspaper courses containing metadata.

Fixes #6069

@henning-gerhardt
Copy link
Collaborator

As code changes are similar, see my comments in #6393

Copy link
Member

@solth solth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthias-ronge please apply the additional commits from #6393 to this pull request as well as @henning-gerhardt requested!

@solth solth requested a review from henning-gerhardt May 5, 2025 14:05
@matthias-ronge matthias-ronge requested a review from solth May 5, 2025 16:00
Copy link
Collaborator

@henning-gerhardt henning-gerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional working but there a some small coding issues.

@@ -28,10 +29,10 @@
public class CourseTest {

@Test
public void testCloneMethod() throws IOException, ParserConfigurationException, SAXException {
public void testCloneMethod() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all other use cased you added the thrown exception class InvalidMetadataValueException but here you replaced all exceptions through the most general exception class at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I don't think we have any specific rules in this regard. It only needs to be declared to satisfy the compiler. JUnit handles the exceptions in the test execution anyway. This, in turn, argues more in favor of a general declaration of throws Exception. I've adapted the other two tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my understanding going to the general exception class is the wrong way as you even hiding other exceptions which extending the general exception class. No one - even Junit - can not decide any more with using general exception class is the thrown exception a valid exception for this method or not. So far as I know Junit5 did not handle any exception except you write an assertion to test for throwing an exception.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I was wrong there. I added it.

*
* @param value
* value to be set
*/
public void setValue(String value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method not got a @Override annotation like in the other places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getValue() of type ProcessTextMetadata does not override or implement a supertype method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is the setValue method. Class ProcessTextMetadata is extending class ProcessSimpleMetadata and ProcessSimpleMetadata is a abstract class with abstract method setValue. In the other implementations of the setValue method in class ProcessBooleanMetadata, class ProcessDateMetadata and ProcessSelectMetadata is always the method setValue defined with the @Override annotation but not in class ProcessTextMetadata.

Copy link
Collaborator

@henning-gerhardt henning-gerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me in general. Code changes are in general good. I have a different opinion which and how to declare exceptions in tests but this is an other more general story.

@solth solth merged commit 4631e7d into kitodo:main May 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Course with metadata throws NPE
4 participants