You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lécharny (Jira)" <ji...@apache.org> on 2024/03/31 10:26:00 UTC
[jira] [Resolved] (DIRSERVER-2397) FB.ES_COMPARING_STRINGS_WITH_EQ in ../server/xdbm/search/impl/DefaultOptimizer.java
[ https://issues.apache.org/jira/browse/DIRSERVER-2397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Lécharny resolved DIRSERVER-2397.
------------------------------------------
Fix Version/s: 2.0.0.AM28
Resolution: Fixed
Thanks and good catch!
Fixed with commit 004437a5a35c36cc128a3a2e4e5b392a8df83102
> FB.ES_COMPARING_STRINGS_WITH_EQ in ../server/xdbm/search/impl/DefaultOptimizer.java
> -----------------------------------------------------------------------------------
>
> Key: DIRSERVER-2397
> URL: https://issues.apache.org/jira/browse/DIRSERVER-2397
> Project: Directory ApacheDS
> Issue Type: Bug
> Affects Versions: 2.0.0.AM26
> Reporter: e.bykhanova
> Priority: Major
> Fix For: 2.0.0.AM28
>
> Attachments: image-2024-03-06-21-46-08-238.png, image-2024-03-06-21-47-20-926.png
>
>
> The static analyzer has detected FB.ES_COMPARING_STRINGS_WITH_EQ: comparison of String objects using == or != in [{_}getScopeScan(PartitionTxn, ScopeNode)](https://github.com/apache/directory-server/blob/8c9b56bdcc0703b04b8e2dbdc4f045ed5d83a064/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java#L497C2-L523C2).{_}
> !image-2024-03-06-21-47-20-926.png!
> The ES_COMPARING_STRINGS_WITH_EQ detector worked because in Java the == operator compares objects for reference equality, but not string literals contained in these objects.
> According to [one](https://github.com/apache/directory-server/commit/cfa2152efaa693368634e5d278890f7f5d2c9914#diff-90992891001769bbc1422416e6c9fe2e0ff73afbc5660f877244f2545b95f58fL353) of the previous commits, here we have the following logic: we excpected to get the comparison of string literals contained in these objects.
>
> !image-2024-03-06-21-46-08-238.png!
> Using the _equals(Object)_ method here seems to be a better practice.
>
> Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
> Author E. Bykhanova (e.bykhanova@fobos-nt.ru).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org