-
Notifications
You must be signed in to change notification settings - Fork 499
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
CVOC: Fix NPE #10603
CVOC: Fix NPE #10603
Conversation
if(StringUtils.isBlank(paramName) || StringUtils.isBlank(value)) { | ||
return retrievalUri; | ||
} | ||
|
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.
It seems like line 501 above is the only thing that could cause the NPE? And in that case the paramName can't be null but the value could be? I wonder if checking on line 571 to see if retrievalUri.contains(paramName) would be a better check - if the param name is in the Uri and it isn't replaced, that's a problem you wouldn't want to silently ignore? Or do you in the free text case? Seems like the code shouldn't just call the remote service with a broken URL, so maybe the NPE should be caught and used to avoid the call to the service instead?
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.
CVOC is sooo complexe...
- you are right the only case where there is NPE can happen is : L501
retrievalUri = replaceRetrievalUriParam(retrievalUri, f.getDatasetFieldType().getName(), f.getValue());
when value is null which can happen with termUri filled but when a parameter set in retrievalUri has no value. - retrievalUri.contains(paramName) would be a better check - if the param name is in the Uri and it isn't replaced, that's a problem you wouldn't want to silently ignore if param is null, empty or wrong I just do nothing, either it cannot be done, data are wrong or json setting is wrong. But that being said, a "if paramName does not exist in retrievalUri then logger.warning" can be done.
- the code shouldn't just call the remote service with a broken URL, so maybe the NPE should be caught and used to avoid the call to the service instead? hum, you are right, for a wrong parameter we could simply
return;
instead of performing the call.
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.
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.
Looks good - thanks for the update.
@luddaniel - I ran across another NPE when trying to use the latest dev branch with a skomos and ror script. I was getting a case where the value of a datasetfieldvalue was null. Either of the two changes in a520799 would fix it, but I was surprised to see that a DatasetFieldValue would return a null value (versus there not being a DatasetFieldValue at all). I guess two questions - any insight into why there's a null value? Assuming no ideas about a deeper cause, could you confirm that this fix (one of the two checks in the commit) makes sense and perhaps add it to your PR so it can all get tested together? Also - FWIW: I think the fix for the one failing test is now in develop so if you update your branch, you should get all tests passing. |
@qqmyers I don't know how this null value came along with Dataverse releases or different works on CVOC. I did came across the same issue one day as I fixed this issue here : https://github.com/IQSS/dataverse/pull/10505/files#diff-171c256be8744ca0742a9570ed33a3e335eae0544d08be04545ef31fdd5328d1R485 de facto I approve your modification ^^ |
What this PR does / why we need it:
Fix NPE in complex case of CVOC : free text + partial data using flexible params in retrievalUri
Special notes for your reviewer:
Code is tested and will fix already merged code to develop.
I'm fixing my own code here