Closed Sanne closed 1 year ago
Avoiding the cast by returning void will work too
Avoiding the cast by returning void will work too
right that's essentially what I've done here: ignore the return type. Perhaps that would be a good change to the Assert.checkNotNullParam
so to avoid the problem in future.. WDYT @radcortez ?
right that's essentially what I've done here: ignore the return type. Perhaps that would be a good change to the
Assert.checkNotNullParam
so to avoid the problem in future.. WDYT @radcortez ?
Sure. We probably need to deprecate that method and introduce a new one.
Something like this.foo = Objects.requireNonNull(foo)
(or Assert.checkNotNullParam()
for that matter) is a very common idiom in constructors. I have no idea why it was used here (and I'm obviously +1 for avoiding it), but removing the Assert.checkNotNullParam()
method is not gonna remove the usages of this idiom. The Objects.requireNonNull()
method exists in the JDK, and I'm pretty sure a lot of other projects have their own copy as well (I know I do in SmallRye Fault Tolerance, for example).
I have to also add a 🛑 to this line of reasoning... what we're working around here is a JVM bug which people are working on fixing, whereas an API change is much more long-term. As @Ladicek pointed out this is a commonly used pattern so changing the API isn't really warranted.
I'm OK with some simple/localized band-aid type fixes for the type pollution issue to stop the bleeding but I am against significant reengineering or API redesigning to work around it. Once the issue is fixed, I feel we will regret the amount of effort we spent on the problem which could have been spent in other areas, and we will also regret how we hobbled our own programming models for a short-term gain.
Could this get merged?
Thanks!
Similar to #190 , this looks rather trivial but has severe performance implications.
I wonder if we shouldn't delete all uses of
Assert.checkNotNullParam
, it seems rather dangerous.