[ 
https://issues.apache.org/jira/browse/HDDS-16351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18130502#comment-18130502
 ] 

Siyao Meng commented on HDDS-16351:
-----------------------------------

[Jira cleanup 2026-10-22] Resolving as Fixed. Unknown feature names now throw 
the intended IllegalArgumentException.

Evidence:
* https://github.com/apache/ozone/pull/11170
* 
https://github.com/apache/ozone/commit/e6e62de12d5f8e5351653f45521a5985ddd87f52
* 
https://github.com/apache/ozone/blob/bf3829e6c8ac69ae17585585703f91426dcdf6b3/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java#L64

Feel free to reopen if further work is needed.

> FeatureProvider.Feature.of throws NoSuchElementException instead of 
> IllegalArgumentException
> --------------------------------------------------------------------------------------------
>
>                 Key: HDDS-16351
>                 URL: https://issues.apache.org/jira/browse/HDDS-16351
>             Project: Apache Ozone
>          Issue Type: Bug
>          Components: Ozone Recon
>            Reporter: Henry Chen
>            Assignee: Henry Chen
>            Priority: Minor
>              Labels: pull-request-available
>
> {{FeatureProvider.Feature.of(String)}} uses {{Optional.get()}} and then 
> null-checks the result:
> {{Feature featureEnum = Arrays.stream(Feature.values())
>     .filter(feature -> feature.getFeatureName().equals(featureName))
>     .findFirst().get();
> if (null == featureEnum) \{
>   throw new IllegalArgumentException("Unrecognized value for Features enum: " 
> + featureName);
> }}}
> {{Optional.get()}} never returns null, so the null check is dead code. For an 
> unrecognized feature name the method throws a bare {{NoSuchElementException}} 
> instead of the intended {{IllegalArgumentException}} naming the offending 
> value.
> The method currently has no callers, so this is latent.
> Fix: use {{{}orElseThrow(() -> new IllegalArgumentException(...)){}}}, or 
> remove the unused method.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to