Ostrzyciel commented on issue #2795:
URL: https://github.com/apache/jena/issues/2795#issuecomment-2439737229
@arne-bdt on second thought and considering the point about breaking a
contract, I think this would be a better solution:
```java
public RDFDatatype getSafeTypeByName(final String uri) {
if (uri == null) {
// Plain literal
return null;
}
return uriToDT.computeIfAbsent(uri, uri -> {
// Unknown datatype
if (JenaParameters.enableSilentAcceptanceOfUnknownDatatypes) {
dtype = new BaseDatatype(uri);
// No need to update classToDT
// BaseDatatype.getJavaClass is always null
return registerDatatype(dtype);
} else {
throw new DatatypeFormatException(
"Attempted to created typed literal using an unknown
datatype - " + uri);
}
});
}
```
And then leave `registerDatatype` unchanged. Note that I didn't test it...
but it should work.
What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]