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 251737 - "Created Throwable not thrown" hint shows false positive if used in Optional.orElseThrow()
Summary: "Created Throwable not thrown" hint shows false positive if used in Optional....
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-09 14:18 UTC by markiewb
Modified: 2015-06-05 02:39 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Shows the issue (5.48 KB, image/png)
2015-06-02 12:59 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2015-04-09 14:18:48 UTC
Optional paramNameO;
paramNameO.orElseThrow(()->new IllegalArgumentException())); 

ACTUAL:
* shows warning

EXPECTED:
* shows no warning (if used in orElseThrow or used otherwise as argument for a method)
Comment 1 Svata Dedic 2015-06-02 12:25:04 UTC
(In reply to markiewb from comment #0)
> ... or used otherwise as argument for
> a method)

I didn't understand the last part - AFAIK hint is not reported even now if Throwable is used as a method argument ?
Comment 2 markiewb 2015-06-02 12:59:19 UTC
Created attachment 154017 [details]
Shows the issue
Comment 3 markiewb 2015-06-02 13:00:42 UTC
(In reply to Svata Dedic from comment #1)
> (In reply to markiewb from comment #0)
> > ... or used otherwise as argument for
> > a method)
> 
> I didn't understand the last part - AFAIK hint is not reported even now if
> Throwable is used as a method argument ?

Here are better code samples. "new xxxException()" is reported in lambdas

Optional.empty().orElseThrow(()->new IllegalArgumentException());
new ArrayList<String>().stream().map((x)->new IllegalArgumentException());
Comment 4 Svata Dedic 2015-06-02 13:05:59 UTC
Ah, OK. I've added a check for Throwable as the Lambda return value + check that this return value is actually used somewhere. Sorry for the omission. Fixed in jet-main#16f2ddb342da
Comment 5 Quality Engineering 2015-06-05 02:39:35 UTC
Integrated into 'main-silver', will be available in build *201506050001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/16f2ddb342da
User: Svata Dedic <sdedic@netbeans.org>
Log: #251737: allowed Throwable as a return value of a Lambda