Very strange bug with compareTo: returning incorrect results

Hello everyone! I have used the method compareTo many times to maintain my database project's entries. However recently I have discovered a bug, in which:
a and b both being Storage type objects:
private static class Storage {
object data
int nextData //an array stores the Storage objects
int previousData //this uses an integer to locate previous in array
Problem:
((Comparable)(a.data)).compareTo((Comparable)(b.data)) returns a 3, when a.data is clearly 5, and b.data is clearly 20.
This is very strange, as the compareTo should return a -1 instead of a positive number. Is this a known bug with the compareTo method? I have been using it reliably for many programs but this is the first time it ever occurs to me.

Problem:
((Comparable)(a.data)).compareTo((Comparable)(b.data))
returns a 3, when a.data is clearly 5, and b.data is
clearly 20.
This is very strange, as the compareTo should return a
-1 instead of a positive number. Is this a known bug
with the compareTo method? I have been using it
reliably for many programs but this is the first time
it ever occurs to me.Not really... comparing Strings "5" to "20"
is really the same as comparing "5" to "2"
being the first character of the string, difference
being, surprise, surprise = 3.
If you want the Strings to be comparable that way you should left-fill them with spaces or zeros.
Or, better still, override compareTo and make your Storage implement Comparable instead of all that casting of the data objects.

Similar Messages

  • Very strange bug with my Apple Wired Keyboard

    I have a very strange issue with my Apple Keyboard.
    Sometimes my Apple Keyboard stopped working at my MacBook Pro Retina 15 inch late 2013. I doesn't give any input at all in all the usb ports. The strange thing is when I connect the Apple Keyboard extension cable it worked again and I can disconnect the extension cable and plug it back in with only the cable from the keyboard itself and it works as well. This happened every 2 to 3 months to me. It only happens when my MacBook is in sleep mode and I wake it up.
    Can somebody please help me. What when I lose the Apple Extension cable?

    Yes, a USB extension cable with a male and female end will work.
    example: Amazon.com: Belkin USB Extension Cable (10-Feet): Electronics

  • Very strange bug with AIR and native process (Windows 7, EXE)

    Hello to everyone!
    The situation is:
    I've made an AIR Application, inside of that is running a native process - EXE file.
    I'm using Flash CC as IDE and tried to use compile that as EXE with AIR 2.6 and 3.6 - results are same.
    So I've insert inside a checking if Native Process is supported or not and the Native process is supported all the time.
    When I've just installed the application and run it - the very first attempt is good - everything is working as a must: internal EXE is called by my Application with necessary parameters as many time as I'm need.
    However if I'll close the App and then will run it again - internal EXE is not starting at all, doesn't depends on number of attempts to re-start of the App.
    So only way is to uninstall, install it back and then you'll be one more session of successful internal EXE-requests, till the next re-start of the App.
    That's it.
    I've tried to "google it" but unsuccessful. Probably the bug is very rare.
    Help me please?
    Update: at compilation with Flash CC IDE it's working all the time with no any issues.
    Update-2: when I'm running installator-EXE, there is going a notification "Same version is installed, etc." and then selected "Run Now" - there is also working with no problems.

    Well, I've found the solution and answer by myself and here is it please:
    In case with same situation as above you need to add just one line in your AS3-code
    nativeProcessStartupInfo.workingDirectory = File.applicationDirectory;
    And you will be happy so much

  • Very strange bug: random keyboard disposition

    Hi,
    I just experimented a very strange bug. I have Arch installed with the XFCE desktop and Firefox3b05 from unstable. I was reading my favourite austrian newspaper online: http://derstandard.at. There's the possibility to post messages under the articles, so I clicked on "Post", and suddenly, within the posting window... my keyboard disposition went crazy. Instead of "a", I had a greek omega, instead of "s", I had a euro symbol, and so on. And more: all the other apps were suddenly affected too. I opened mousepad, same story.
    I restarted X, went to the same site... and had the same experience. But after the third time, things seem to have returned to normality.
    Anybody ever experienced something similar? What could this be related to? X going crazy?

    Well, viewing the site is not the problem. You'd have to get an account and actually try posting a message on their message board. That's where the havoc begins.
    JavaScript from hell, maybe...

  • Hey, i have very strange prob with my iphone 5(latest version/updated), after resetting it, so it doesn't connect to my laptop, even it doesn't charge too. it does charge from wall charger i try all the possible methods but still i am facing the prob

    Hey, i have very strange prob with my iphone 5(latest version/updated), after resetting it, so it doesn't connect to my laptop, even it doesn't charge too. it does charge from wall charger i try all the possible methods but still i am facing the prob any fix/solution for it.. Helppppp!!!!!!!!!!!!!!!!!!!!!!!! As soon as possible, it will be gratefulness,
                                Thnksssssss....

    So you are saying that you followed all of the steps in the support document for problems with connection, including removing and reinstalling iTunes? You do not say what you have tried, so it is hard to make recommendations. If this is the case, then you have tried resolving driver issues? What if you go to Device Manager and look for the iPhone. You should be able to click on it and see about drivers. You can update/reinstall the device driver.

  • I have very strange problem with Iphone 3gs. Whenever it gets little hot or exposed to 30 degree temperature it losses signals (No service). Whenever it is cooled down the service is back. Please help!

    I have very strange problem with iphone 3gs. Whenever it gets little hot or exposed to 30 degree or above temperature it losses signals (No service). Whenever it is cooled down the service is back. Whenever I am using Skype or playing game for a while it losses carrier signals and wifi. When it is cooled down afer shutting down the carrier signals and wifi are back. It is for sure problem is with heating, but 30 degree tempeature in Oman is normal and some time it goes upto 50 degrees. I have noticed this has started after I started using substandard charger as I lost my original charger of the phone. Please help!! Thanx.

    The specifications define an operating range up to 35 degrees.

  • Rp_provide_from_last returns incorrect result

    Hi
    When issuing rp_provide_from_last  for IT2001, we get incorrect result.
    rp-provide-from-last p2001 space '19000101' '99991231'
    This macro does not return the latest record.  Instead it returns the record with the highest subtype #.  (It actually returns the last record shown in a SE16N listing of PA2001).
    Has anyone seen this problem?
    We are on SAP 4.7., SP 85.
    Best regards
    Kirsten

    Pleas Try this
    Usage:
    Only in PNP database reports under GET PERNR, because the personnel number for which data is being read comes from field PERNR-PERNR, while the field being used is PNP-SW-AUTH-SKIPPED-RECORD.
    (RP_READ_ALL_TIME_ITY beg end)
       DATA: BEGDA LIKE P2001-BEGDA, ENDDA LIKE P2001-ENDDA.
       INFOTYPES:  0000, 0001, 0002, ...
                         2001 MODE N, 2002 MODE N, ...
         GET PERNR.
       BEGDA = '19900101'. ENDDA = '19900131'.
       RP_READ_ALL_TIME_ITY BEGDA ENDDA.
       IF PNP-SW-AUTH-SKIPPED-RECORD NE '0'.
          WRITE: / 'Authorization for time data missing'.
          WRITE: / 'for personnel number', PERNR-PERNR. REJECT.
       ENDIF.
    Remarks
    This RMAC module can be used when, for example, the time infotypes were originally defined in MODE N. This was done because the time data (from LOW-DATE to HIGH-DATE) might not all have fitted into the buffer. Now, however, they are read with shorter intervals (for example, in RPCALCx0 with payroll periods).
    -Due to the large amount of data in HR, the infotypes 2000 u2013 2999 should not be read when GET PERNR occurs. Therefore, these infotypes are declared with the enhancement MODE N.
    -As a result, the infotype tables under GET PERNR are not filled. The time infotype tables are filled subsequently using the macro RP_READ_ALL_TIME_ITY, but only for the time interval specified by PN-BEGDA and PN-ENDDA.
    http://help.sap.com/saphelp_45b/helpdata/en/60/d8bb88576311d189270000e8322f96/content.htm
    Best Regards

  • Premiere Pro CS5.5 -very strange issue with the color tones and Preview-

    I deal with a very strange and not usual problem in Premiere Pro CS5.5 (also the version CS5). What I try to do is just a simple color correction. The problem occurs when I try to use Three Way Color Corrector but it happens with Fast Color Corrector also.
    When applying the Three-Way Color Correction and without changing anything else (just applying), can be seen in the preview of the soft how sudden changes in color tones. For example, the gray tone becomes a little more green, but also can be seen very easy a change in the other color tones too. In fact even RGB Parade show the same thing. This is very, very strange and unacceptable and saw that it happens when trying to use Colorista II too.
    I tried the same thing in Sony Vegas Pro 11 and I downloaded the trial version of Edius 6 to convince me if the same thing happens. Not! In Sony Vegas and Edius everything is working correctly, I have not experienced these problems in the preview's of this 2 others softs.
    This issue is very annoying because every possible color correction is based on what we see in the preview and if in this preview the tones are seen altered realize that can not make a decent color correction. So what happens here?!? I uploaded a small video demonstration to see very clearly about what I'm talking. You can see in the next link: http://vimeo.com/35317616

    Yes Jim, you're right. No changes in the scopes when one just apply RGB Curves, Fast Color Corrector, RGB Color Corrector  or the Three way Color Corrector (last three thanks to the new update 6.03). I already wrote that Adobe team has been able to fix this bug for some of the tools/effects.
    But Brightness&Contrast? Change Color? Color Balance? Levels? MBLooks? Twixtor? Colorista II? Does it seem normally that all scopes or just one of them jump when you just apply one of these effects/tools? Not to say that in some situations even the tones change (especially in shadows&midtones).
    You say this is something "very minimal". I say it is not so. I don't find normally to make a very detalied CC with Three way Color Corrector and then when applying Colorista/MBLooks, for example, the scopes jump and inclusively some tones may be influenced. And I left clear examples in this topic where you can see that this is possible. I don't know if this is "very minimal" or not, but is really so impossible to edit in Premiere without this "very minimal" issue?!? How can it be possible in other softs (Edius, Media Composer, Vegas Pro) and in Premiere not?!?
    One more thing: many of us use intermediate codecs in the editing process. Do you find normally that a AVCHD video have the lumninance at approximately 110IRE, to export it directly to Cineform and then import it in Premiere, and the waveform shows the luminance at 100IRE?!? How is this possible?!? So the AVCHD video have a 110IRE luminance, you convert this video to Cineform without changing anything, and then this Cineform video have the luminance at 100IRE?!? And anyone can verify this example.
    So, how can one trust in this soft?!?

  • Strange bug with the java.io.File class

    Hi everibody!
    I'm writting a system to upload images with JSF and RichFaces. But when i try to delete the images files sometimes hapen some strange bug.
    first i'll post my method code here:
    public void deleteUploadedFile(ActionEvent event) throws Throwable {
            UIComponent link = event.getComponent();
            UIParameter param = (UIParameter) link.findComponent("fileId");
            TheFile file = this.uploadedFiles.get((Integer) param.getValue());
            try {
                File f = new File(file.getPath(), file.getName());
                if ((f.exists()) && (f.canRead()) && (f.canWrite())) {
                    if(f.delete()){
                        for(int i=0; i<file.getThumbs().size(); i++){
                            File t1 = new File(file.getPath(), file.getThumbs().get(i).getThumbName());
                            t1.delete();
                        setDeleted(true);
                    else{
                        setDeleteLog("Arquivo não pode ser excluido");
                        setDeleted(false);
                } else {
                    setDeleteLog("Erro ao tentar excluir o arquivo");
                    setDeleted(false);
                this.finalize();
            } catch (Exception ex) {
                setDeleteLog("Deu erro: " + ex);
            } finally {
                if (this.deleted) {
                    if (this.uploadedFiles.remove(file)) {
                        setDeleteLog("Conseguiu remover");
                    } else {
                        setDeleteLog("Deu erro");
        }Well, when the method run the f.delete() line, sometimes, something strange hapen. With is, the file data is deleted as expected, but the file it self is not deleted. And even when i run the line this.finalize the JVM still using the file, with don't allows me to try to delete it untill my tomcat stop (with kill the application that was using the file). And this don't hapen every time that i try to delete one file.
    And worse, once it hapen every next time that i try to delete one file hapen the same bug.
    My question is...what could it be, and what can i do to solve this?!

    About this is not a possible cause. Because before i upload a file I verify if the file already exists and even after i change the file name:
    //this method change the file name and eliminate all the special characters, and also attach the current day of month,
    //month, year, minute and second to the file name
    public String generateFileName(String fileName){
            Locale l = new Locale("pt","BR");
            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(TimeZone.getTimeZone("GMT-3").getID()), l);
            int ext = fileName.lastIndexOf('.');
            String name = fileName.replace(fileName.substring(ext), "");
            String newName = RemoverAcentos.remover(name).toLowerCase()+cal.get(cal.DAY_OF_MONTH)+cal.get(cal.MONTH)
                    +cal.get(cal.YEAR)+cal.get(cal.MINUTE)+cal.get(cal.SECOND)+fileName.substring(ext);
            return newName;
        }the upload method
    String fileName = generateFileName(item.getFileName());
            try {
                File uploadFile = new File(filepath, fileName);
                if (!uploadFile.exists()) {

  • Please Help - Very strange problem with internal String encoding

    I created a file in one-byte russian encoding cp1251 and declared String literal with 2 letters:
    String str = "ab"; //attention! ab - two russian characters
    After I got bytes from it - str.getBytes("cp1251") - it returned 2 byte's array.
    Now I created a file with UTF-8 encoding with equal content and suddenly:
    After I got bytes from it - str.getBytes("cp1251") - it returned 4! byte's array. Why?
    I need to get a one-byte encoded arrays (cp1251 or koi8-r) but getBytes ALWAYS returns two-byte encoded arrays.
    It is very strange: cp1251 is always one-byte encoded, but .getBytes("cp1251") returns two-byte on each letter. Why? Please help.

    I did not read a string from a file. I created 2 .java files with different encodings (cp1251 and UTF-8) and compiled them, telling compiler with -Dfile.encoding=*** to read them correctly. While execution java interprets two looking equal in editor strings as different objects with different .intern() representation.
    Why java consider source .java file encoding while creating internal representation of String object and creates from looking equally in editor strings two DIFFERENT Unicode representations. And it is impossible to convert one representation to other - impossible to get two equal byte[] arrays.

  • 10.4.10 update and very strange problem with Mac Mini

    Dear All,
    I have just updated my Mac Mini Intel and I am having a strange problem.
    My Mac Mini has problems booting up. Sometimes I get through the login screen as normal but my wallpaper shows and there are no desktop icons, no dock, no top of screen finder menu bar. Some other times I get stuck in the progress bar of the booting up.
    I tried to run utilities from install disk and there were no problems detected.
    The VERY STRANGE thing is that several times now as I put my fingertip onto the power button laying it on the button but not pressing it yet (because I would like to shut down the system), the system kicks in and becomes unfrozen!!!
    Someone in the 123macmini.com forum says that this problem is related to the airport receiver which is near the power button.
    What do you think about it???
    MacBook and MacMini   Mac OS X (10.4.10)  

    ok, I have found a kind of fix for the problem, although may run a hardware test to check something!.
    I unplugged all USB and Firewire devices, I turned off Bluetooth and Airport, reinstalled the 10.4.10 combo update, when it restarted the starting mac osx screen took barely a second or 2 to load (my comment above is becuase from when I first got it on Sunday I noticed it was slow to boot up, also noticed that the screen resoulution I have set does not kick in until I log on, although this may be becuase this mac mini is an intel one). The computer booted up very quickly and I tuend on bluetooth and airport with no issues and plugged all the usb and fireware devices back in. I again turned the airport off and restarted and again it booted up very quickly logged on and swithced the airport back on. I decided to reboot with the sirport on and it got stuck at the end of the os x starting up screen, I waited a few mins switched it off and on again and it booted up fine although slower. I dont mind turning the airport off when I power down as the mac usually stays on anyway. I assume Apple will release a fix for this as a lot of people seem to have the problem so think I will stay put with this for the time being. It was taking a several goes to get to the login screen before but usually got there every few boots.

  • Strange bug with CC panel and OS X Spaces

    I seem to have a strange bug where the CC panel opens each time I switch spaces in OS X (click on the GIF animation below).  Anyone else have this problem?

    Hi Lee ,
    This has been already notified to the engineering team.
    http://forums.adobe.com/message/5421355#5421355
    Thanks,
    Manish

  • Very strange bug when using a view with a date

    Hi,
    Just thought I'd point out this bug I'd found and see if anybody has had similar problems.
    I'm connecting to Oracle 9i from servlets using the thin client-side JDBC driver. In the Oracle schema I've got a few views to another schema set up. One of them looks like this:
    select
    blah
    blah
    from
    projects
    where
    project_start_date between '1-Apr-2000' and '31-Mar-2010'
    Nothing wrong with this, you'd think. And indeed, the view works fine and any valid queries on the view also work fine if they're performed from anywhere apart from my servlets. The servlets can perform queries on all my other views but they think that this particular view is completely empty.
    As soon as I change the view to:
    project_start_date > '1-Apr-2000'
    the servlets can see the data in the view.
    Hope all this made sense. Anybody else had any similar problems?
    Chris.

    Any time you want to do a date comparison, you really want to do an explicit to_date conversion rather than relying on Oracle to do it implicitly. I'll wager that if you change the view to
    SELECT <columnList>
      FROM projects
    WHERE project_start_date BETWEEN to_date('1-Apr-2000', 'DD-MON-YYYY') and to_date('31-Mar-2010', 'DD-MON-YYYY')that everything will work.
    Justin

  • Problem with sdo_relate returning unexpected results

    I am having a problem with an oracle spatial query not returning what I feel is an appropriate result.
    I have a bounding box that has 6 points from a table that should be inside it. There are several hundred points total in this table. I perform the following query and oracle returns only 4 points, well 5 but we will get to that later, within the area of the search.
    SQL> Select feature_id
    From city_points A
    where (MDSYS.SDO_RELATE(A.GEOM, mdsys.sdo_geometry(2003, 8307, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array(-101.8417,-52.8083,-23.8417,-52.8083,-23.8417,-13.8083,-101.8417,-13.8083,101.8417,-52.8083)), 'mask=ANYINTERACT querytype=join') = 'TRUE');
    I used a different application to perform the same type of query. The difference is that the application does the spatial query, not oracle. Further the application gets all of the points and performs this query on the client. What the application returns is correct both visually and spatially.
    Two of the points not returned in the oracle spatial query are 300km inside the bounding box. This far exceeds the .5 m tolerance used in our decimal degrees data set (SRID 8307).
    I have experienced this problem on 9.2.0.1. I then patched that instance to 9.2.0.7 and duplicated the problem. I then exported the data and imported into a 10g release 1 database and again duplicated the problem. I have tried to re-index the data to no avail.
    I have also tried different querytypes also yielding less than expected results.
    The data looks like this:
    243
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-58.45, -34.6, NULL),NULL, NULL)
    254
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-56.18333, -34.883334, NULL), NULL, NULL)
    377
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-70.666671, -33.449999, NULL), NULL, NULL)
    385
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-68.149999, -16.5, NULL), NULL, NULL)
    388
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-47.916667, -15.783333, NULL), NULL, NULL)
    427
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-57.640066, -25.270295, NULL), NULL, NULL)
    The number is the id field, the rest is the geometry.
    The oracle spatial query above only returns id #s 359, 377,243,254,427
    There are five returned records. The extra value is outside the bounding area. So it should not have been returned at all. It is all too strange.
    I have seen this with different geometry types (points lines and area) as well.
    If anyone has suggestions, I would appreciate your comments.
    Thanks,
    John

    John,,
    What you are seeing is the behavior you should expect in the geodetic space.
    When you have a very long line connecting from longitude -101 to -23, that line
    does not follow the same latitude value.
    Since these points are in southern hemisphere, the line connecting them
    will curve downward (this is the great circle line).
    If you really want a line connecting with constant latitude, you should
    use the MBR type for the window geometry which densifies the
    lines along constant latitude before passing it into relate.
    SDO_GEOMETRY(2003, 8307, NULL,
    sdo_elem_info_array(1,1003,3),
    sdo_ordinate_array(-101.8417,-52.8083, 23.8417,-13.8083))
    siva

  • MDX used in Universe for Prompt returns Incorrect Result

    Hi All,
    I have created an optional predefined filter in the universe like so... (and for many other characteristics too...)
    <OPTIONAL>
    <FILTER KEY="[0COMP_CODE].[LEVEL01]">
    <CONDITION OPERATORCONDITION="InList">
    <CONSTANT CAPTION="@Prompt('Select Company Code(s)','A','Company code\Company code',multi,constrained)">
    </CONSTANT>
    </CONDITION>
    </FILTER>
    </OPTIONAL>
    The code works i.e The prompt comes up, the text is correct, the list of values are correct. BUT....
    This is a multi value prompt i.e In List... So when I select only 1 Comany code i.e CODE-1, run the Webi report, the result is as expected, the reports displays all the data for Company code - CODE-1.
    When I refersh the report and add CODE-2, so the list now has CODE-1 and CODE-2 in the prompt... only the data for CODE-1 is displayed in the report, and CODE-2's data is not returned.
    I also find that when I select CODE-2 first, then CODE-1, then only CODE-2's data is returned, so I can safely say that only the first selected Company code is returned in the Webi report irrespective of how many Company codes where selected in the list.
    This behaviour also affects any other characteristic on which filter is created in this manner.
    Has anyone experienced this behaviour? Is there something on the BW side that needs to be checked? or is this a bug?
    Thanks
    J

    Hi Uwe,
    Yes... the issue is that we need to use short XML tags. The issue is also documented in one of  the release notes.
    In the example below, you can see the </CONSTANT> tag is used. This is what is causing the issue.
    <OPTIONAL>
    <FILTER KEY="[0COMP_CODE].[LEVEL01]">
    <CONDITION OPERATORCONDITION="InList">
    <CONSTANT CAPTION="@Prompt('Select Company Code(s)','A','Company code\Company code',multi,constrained)">
    </CONSTANT>
    </CONDITION>
    </FILTER>
    </OPTIONAL>
    So... to ge the results correctly, we need to remove the </CONTSTANT> tag and close it at the end of the prompt line with a /, now the same code looks like this...
    <OPTIONAL>
    <FILTER KEY="[0COMP_CODE].[LEVEL01]">
    <CONDITION OPERATORCONDITION="InList">
    <CONSTANT CAPTION="@Prompt('Select Company Code(s)','A','Company code\Company code',multi,constrained)"/>
    </CONDITION>
    </FILTER>
    </OPTIONAL>
    I have tested this using other operators and it works fine.
    Jacques

Maybe you are looking for

  • I have a question about my Apple ID security questions that I don't remember?

    Alright, so I don't know my security question answers. However i can buy things from the app store/whatever, i just want to know them. Because when I go to "Manage my apple ID" and i log in and go to the Password and Security section of it, thats whe

  • How do i transfer my movie files from my mac to my external hard drive

    i want to move some video files from my desktop to my external hardrive, never dont it before need help

  • Oracle VM Manager 3 fails to auto discover VM servers

    Hi, It seems the OVM Manager 3 has stopped communicating with the 2 VMservers in the server pool . The 2 servers are in starting (error) status marked red . There have been many auto discover events / jobs running against the 2 servers which fail wit

  • Making a map-style blowup section?

    Hello! I'm fairly new to Illustrator; I've been playing with it for a few days and I'm getting the hang of it, but I can't seem to figure one particular thing out.  I'm working on a vector map and I'd like to be able to take a section of it and blow

  • Re-organization of images Lightroom 2.7

    Greetings,  Over the years I have created a hodge podge of directories with images in various locations. I want to re-organize all my images into the single location and organization in a logical directory structure.  Now for my question.  Would I be