-
Notifications
You must be signed in to change notification settings - Fork 578
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
False Positive: BC_UNCONFIRMED_CAST_OF_RETURN_VALUE when using generic bounded type #1219
Comments
Thanks for opening your first issue here! 😃 |
I'm also seeing a similar issue as this with a method such as: public <T extends Throwable> T logThrowableAsError(T throwable) {
// Logic to log the throwable.
return throwable;
}
// Other code later
public void attemptSomething() throws IOException {
try {
trySomething();
} catch (IOException ex) {
throw logThrowableAsError(ex);
}
} Using Spotbugs version 4.2.0 |
We've upgraded to Spotbugs 4.2.2 and this continues to persist, is there any chance that this has been resolved by an even newer version? |
No, I am running latest 4.4.2 and the bug still is there: |
I'm also seeing this issue. |
Fix spotbugs complaints in generated code. False positive of BC_UNCONFIRMED_CAST_OF_RETURN_VALUE remains in some cases when using generics due to spotbugs/spotbugs#1219.
Also seeing this with fairly basic use of Jackson. For example: package crap
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.json.JsonMapper;
public final class MyClass {
private static final ObjectReader JSON_READER = JsonMapper.builder()
.build()
.readerFor(OtherClass.class);
}
|
I'm seeing this issue with the latest release version of Kubernetes-client-6.8.0 when both ObjectMetaFluent class and SecretFluent class extend from the same base class BaseFluent.
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.SecretBuilder;
public class ClassName {
final Secret secret =
new SecretBuilder()
.withNewMetadata()
.withName(String)
.withAnnotations(Map.of(String, String))
.withLabels(Map.of(String, String))
.endMetadata()
.WithData(Map.of(String, String))
.build()
} |
I've reproduced this here: gchq/sleeper#1162 |
Any progress on this? |
SomeInterface<?> myObject = ...
var result = switch(myObject) {
case Impl1 i1 -> doStuff(i1); //i1 is cast to Impl1
} I created a new issue: #2782 |
This should be fixed by #2811 once released |
Following code is safe in terms of casting, but spotbugs reports
BC_UNCONFIRMED_CAST_OF_RETURN_VALUE
Parent
is interface instead of class, this bug is not reportedFactory
doesn't bound type T toParent
, this bug is not reportedSpotbugs Version: 4.0.6
Report Level: Low
The text was updated successfully, but these errors were encountered: