-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix nullability issue in queuechannel #3012
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
Fix nullability issue in queuechannel #3012
Conversation
I am not sure I understand - seems to be a bug in the compiler. Are you saying the I thought you only had to add |
Me too, but then I read description of this annotation: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/Nullable.html
Thus, if I understand correct, even if super class has this annotation, sub class also must have it, otherwise it would have no effect. |
Hmmm - this works fine for me... package com.example.demo;
import org.springframework.lang.Nullable;
public class Foo {
@Nullable
public Object getOne() {
return "one";
}
}
package com.example.demo;
public class Bar extends Foo {
@Override
public Object getOne() {
return null;
}
} package kot
import com.example.demo.Bar
class Baz: Bar() {
override fun getOne(): Any? {
return "two"
}
}
package kot
fun main() {
val bar: Baz = Baz()
val one: Any? = bar.one
println(one)
} What's the difference between this and your case? |
Have you tested with |
Interesting, with that I get the error when subclassing I'll go ahead and merge this, but I fear there are many other places in the framework that will need to be addressed 😦 |
* Added inherited @nullable to QueueChannel.doReceive * Minor refactoring
Cherry-picked as e5fadc3 to 5.1.x |
See
So, this |
No; I didn't mean It does seem to silence Sonar, though. |
Surprisingly, we only have 12 classes with abstract methods marked with It won't catch them all but fixing those shouldn't be too bad; I'll start tomorrow. Of course, some of them have many, many subclasses. |
As per
@Nullable
annotation description,QueueChannel
inherits fromAbstractPollableChannel
, which has annotation@Nullable
ondoReceive
, butQueueChannel
lacked it. It presents a problem in some cases, see discussion here:https://discuss.kotlinlang.org/t/override-java-method-return-type-nullability/13633