On Wed, 25 May 2022 17:11:59 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:
>>> `SnippetUtils` is broken if we get a null result. >> >> If it's unconditionally so, which it seems to be, wouldn't it be better to >> throw something from `SnippetUtils.getSnippetById` instead? > > Hmmm, The current spec of `SnippetUtils` is to return `null` if an item > cannot be found. So, it is only broken if the user really expects a non-null > result. > > I guess it depends if there is enough use case where you might want a null > result instead of an exception. I guess the `SnippetUtils` spec does not currently define behavior if not found. I would be more inclined to define a "returns null" behavior than to use `Optional` or throw and exception. But more generally, I'd prefer to leave updates to `SnippetIUtils` to its own separate Enhancement. ------------- PR: https://git.openjdk.java.net/jdk/pull/8796