You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Fuxiang Chen <fc...@cse.ust.hk> on 2014/08/06 06:45:46 UTC

[Lucene - Suggestion to Prevent Bug] Trim the whitespaces of longtitude and latitude.

Dear Lucene Developers,

In the source file "GeohashFunction.java", the code fragment that is used
for comparing latitude and longtitude has been reported for wrong
comparison by some users who are writing similar codes.

Original Code
--------------------
    if (!lat.equals(that.lat)) return false;
    if (!lon.equals(that.lon)) return false;

    return true;

Since other users that are using very similar codes as above have
encountered this issue, it is therefore better to prevent it from occurring.

Simply trim the whitespaces by just modifying two lines. The amended code
will be:

Changed Code
----------------------
    if (!lat.trim().equals(that.lat)) return false;
    if (!lon.trim().equals(that.lon)) return false;

    return true;

Reference: http://stackoverflow.com/questions/11219845/

Please consider adding this minor change.

Thanks!

-- 
Warmest Regards,
    Fuxiang

Re: [Lucene - Suggestion to Prevent Bug] Trim the whitespaces of longtitude and latitude.

Posted by Chris Hostetter <ho...@fucit.org>.
: In the source file "GeohashFunction.java", the code fragment that is used
: for comparing latitude and longtitude has been reported for wrong
: comparison by some users who are writing similar codes.

Just to be clear: it appears you are saying that other people, who have   
written comparison code that *look* similar to the equals() method  
in GeohashFunction.java hav reproted bugs, and based on that you are
suggesting we make changes to GeohashFunction.java ... is that correct?
 
I want to clarify that, as i understand it, you don't actaully know of
anyone that has directly experienced a bug resulting from the equals()
function in GeohashFunction.java     

The reason i ask, is because your suggestion makes absolutely no sense to 
me -- in the code you are refering to, the "lat" and "lon" variables are 
instances of the "ValueSource" class ... they aren't Strings ... they 
don't have a trim method.

If i'm missunderstanding your suggestion, and you feel there is a genuine 
risk of a bug here, please open a jira and attach a patch file showing 
your changes (as it's possible i'm completley missunderstanding what code 
you are suggesting we change)

https://wiki.apache.org/solr/HowToContribute
https://wiki.apache.org/solr/HowToContribute#Generating_a_patch



: 
: Original Code
: --------------------
:     if (!lat.equals(that.lat)) return false;
:     if (!lon.equals(that.lon)) return false;
: 
:     return true;
: 
: Since other users that are using very similar codes as above have
: encountered this issue, it is therefore better to prevent it from occurring.
: 
: Simply trim the whitespaces by just modifying two lines. The amended code
: will be:
: 
: Changed Code
: ----------------------
:     if (!lat.trim().equals(that.lat)) return false;
:     if (!lon.trim().equals(that.lon)) return false;
: 
:     return true;
: 
: Reference: http://stackoverflow.com/questions/11219845/
: 
: Please consider adding this minor change.
: 
: Thanks!
: 
: -- 
: Warmest Regards,
:     Fuxiang
: 

-Hoss
http://www.lucidworks.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org