RFR: 8289274: Cleanup unnecessary null comparison before instanceof check in security modules
Andrey Turbanov
aturbanov at openjdk.org
Wed Jul 6 15:15:41 UTC 2022
On Sun, 3 Jul 2022 20:17:07 GMT, Attila Szegedi <attila at openjdk.org> wrote:
>> Update code checks both non-null and instance of a class in security classes.
>> The checks and explicit casts could also be replaced with pattern matching for the instanceof operator.
>>
>> See similar cleanup in java.base - [JDK-8258422](https://bugs.openjdk.java.net/browse/JDK-8258422)
>
> src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java line 491:
>
>> 489: break;
>> 490: case "SSLServer":
>> 491: result = (t instanceof IOException);
>
> Suggestion:
>
> result = t instanceof IOException;
I like current approach with parentheses when `instanceof` is involved. Especially with assignment. In this case you can clearly see start and end of expression which would be assigned to variable.
@seanjmullan what do you think?
-------------
PR: https://git.openjdk.org/jdk/pull/9284
More information about the security-dev
mailing list