This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 230576 - Wrong warning: Returning null value from a method whose return type is not-null
Summary: Wrong warning: Returning null value from a method whose return type is not-null
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Linux
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-31 13:16 UTC by ezsi
Modified: 2016-07-07 07:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ezsi 2013-05-31 13:16:47 UTC
Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_15; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b03
System: Linux version 3.2.0-4-amd64 running on amd64; UTF-8; en_US (nb)

    @Nonnull String method(){
        String s = null; // some logic comes here
        if(s != null){
            return s; // NULL WARNING!
        } else {
            throw new IllegalStateException("Some message.");
        }
    }
    
    @Nonnull String method2(){
        String s = null; // some logic comes here
        if ( s == null ) {
            s = "something";
            return s;
        } else {
            return s; // NULL WARNING!
        }   
    }

In the examples above Netbeans gives warning hint "Returning null value from a method whose return type is not-null" where the returned values are obviously non null!
Comment 1 Martin Balin 2016-07-07 07:16:33 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss