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

Suggestion for fixing a NullPointerException #8667

Closed
pkiraly opened this issue Apr 29, 2022 · 0 comments · Fixed by #8668
Closed

Suggestion for fixing a NullPointerException #8667

pkiraly opened this issue Apr 29, 2022 · 0 comments · Fixed by #8668
Milestone

Comments

@pkiraly
Copy link
Member

pkiraly commented Apr 29, 2022

What steps does it take to reproduce the issue?
When playing with the setting of external vocabularies, I started to set :CVocConf. However when I set it with the two commands mentioned in the description the site returned 505 errors, due to a NullPointerException.

The server log recorder the following error message:

[2022-04-28T16:59:17.336+0200] [Payara 5.2021.8] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=104 _ThreadName=http-thread-pool::jk-connector(5)] [timeMill>
  StandardWrapperValve[default]: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
        at edu.harvard.iq.dataverse.DatasetFieldServiceBean.getCVocConf(DatasetFieldServiceBean.java:303)
        at jdk.internal.reflect.GeneratedMethodAccessor862.invoke(Unknown Source)

It is a warning level, but the site was virtually down.

We checked the environment of the referenced code, and we found that null value is checked, but the code only reports it and does not prevent the flow to run into a branch which expects that the value is not null:

https://github.com/IQSS/dataverse/blob/develop/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java#L293

            for (JsonObject jo : cvocConfJsonArray.getValuesAs(JsonObject.class)) {
                DatasetFieldType dft = findByNameOpt(jo.getString("field-name"));
                if (dft != null) {
                    cvocMap.put(dft.getId(), jo);
                } else {
                    logger.warning("Ignoring External Vocabulary setting for non-existent field: "
                            + jo.getString("field-name"));
                }
                if (jo.containsKey("term-uri-field")) {
                    String termUriField = jo.getString("term-uri-field");
                    if (!dft.isHasChildren()) {
                        if (termUriField.equals(dft.getName())) {
                            logger.fine("Found primitive field for term uri : " + dft.getName() + ": " + dft.getId());
                            cvocMapByTermUri.put(dft.getId(), jo);
                        }
                    } else {
                        DatasetFieldType childdft = findByNameOpt(jo.getString("term-uri-field"));
                        logger.fine("Found term child field: " + childdft.getName()+ ": " + childdft.getId());
                        cvocMapByTermUri.put(childdft.getId(), jo);
                        if (childdft.getParentDatasetFieldType() != dft) {
                            logger.warning("Term URI field (" + childdft.getDisplayName() + ") not a child of parent: "
                                    + dft.getDisplayName());
                        }
                    }
                    if (dft == null) {
                        logger.warning("Ignoring External Vocabulary setting for non-existent child field: "
                                + jo.getString("term-uri-field"));
                    }

Thanks to Marcel Hellkamp (GWDG) who did the error tracking at the first place!

  • When does this issue occur?

  • Which page(s) does it occurs on?
    All.

  • What happens?
    The Payara Java error reporting page is displayed.

  • To whom does it occur (all users, curators, superusers)?
    All users.

  • What did you expect to happen?
    Catch the null, and let flow runs only on the safe branch.

Which version of Dataverse are you using?
6.9

Any related open or closed issues to this bug report?
I am not aware of.

Screenshots:

No matter the issue, screenshots are always welcome.

To add a screenshot, please use one of the following formats and/or methods described here:

pkiraly added a commit to pkiraly/dataverse that referenced this issue Apr 29, 2022
kcondon added a commit that referenced this issue May 24, 2022
@pdurbin pdurbin added this to the 5.11 milestone Jun 2, 2022
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 a pull request may close this issue.

3 participants