Weird thing in static string comparation

I am parsing XML file with simple structure:
<?xml version='1.0' encoding='utf-8'?>
<list>
        <item>
                <ingredient id="1" count="1" />
                <production id="2" count="1" />
        </item>
</list>I have code block to parse <item> node:
     protected TableEntry parseEntry(Node n)
          TableEntry entry = new TableEntry();
          for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
               if("ingredient".equalsIgnoreCase(d.getNodeName()))
                    // parse it
                    //entry.addIngredient
                    l2p.util.Log.add("loaded ingredient " + id + " count " + count);
               else if("production".equalsIgnoreCase(d.getNodeName()))
                    // parse it
                    //entry.addProduct
                    l2p.util.Log.add("loaded production " + id + " count " + count);
          if(entry.getIngredients().isEmpty() || entry.getProduction().isEmpty())
               Log.add("wrong node");
               for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
                    Log.add(d.getNodeName());
               return null;
          return entry;
     }First block always works fine, but second not:
loading new entry
loaded ingridient 1 count 1
wrong node
#text
ingredient
#text
production
#textHow can it be? Looks like
"production".equalsIgnoreCase(d.getNodeName())
return false, while d.getNodeName() actually equals "production"
The most strange:
Only "production" can broke, never "ingredient".
About 1/3 of all parsed works fine, but after method become "broken" and skips "production" in all parsed nodes.
This bug appears only on production server, and never at developers workstation.
Server:
Linux server 2.6.28-17-server #58-Ubuntu SMP Tue Dec 1 22:13:36 UTC 2009 x86_64 GNU/Linux
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
Dev:
Win7 Ult
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)

Oblitus wrote:
Which assumptions? I don't know. Like I said: I don't understand what you're trying to say, and I can't be bothered to read your code.
However, I 100% guarantee that you are making some assumptions. Assumptions about how Java works. Assumptions about what your code means to Java. Assumptions about which conditions will be true or not. Assumptions about which variables get assigned which values and when. Assumptions about how your mental idea of your algorithm and you code implemenation of that idea map to each other. And I also guarantee you that at least one of those assumptions is wrong.
So you can choose to believe me, accept that Java is behaving exactly as it's supposed to, or you can assume that the problem is with Java, file a bug report, and find a workaround.
I comparing
"production".equalsIgnoreCase(d.getNodeName()) when d.getNodeName() equals "production" and it returns false!You're assuming that's what's happening. I am highly confident that that assumption is wrong, and that's not really what's happening.
The only way you'll solve your problem is if you ask yourself, "What am *I* doing wrong?" and accept that it could be anything, even the things you're 100% sure you're doing right. (Actually, especially those things.)

Similar Messages

  • Public static final Comparator String CASE_INSENSITIVE_ORDER

    in this declaration..
    public static final Comparator<String> CASE_INSENSITIVE_ORDER
    what does <String> mean?
    thanks!

    what does the Comparator do. Look at the API and you would see the following description about the compare method.
    public int compare(Object o1,
    Object o2)Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
    The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)
    The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.
    Finally, the implementer must ensure that compare(x, y)==0 implies that sgn(compare(x, z))==sgn(compare(y, z)) for all z.
    It is generally the case, but not strictly required that (compare(x, y)==0) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact. The recommended language is "Note: this comparator imposes orderings that are inconsistent with equals."
    Now your question is about what <String> is in your declaration. It is the type of the objects which are going to be compared.

  • MacBook won't turn on 98% of the time, help! Very weird things happening!

    Hi there, any advice you have for me would me much appreciated. What happened with my Macbook is all very strange.
    So, the morning before last, I was on my Macbook (which I bought in 2006 so it's on the older side, but otherwise worked great) and it was running low on battery. I was late for work so didn't plug it in before leaving. I left it open. However I have no roomates, pets, etc.
    When I get home that evening, I plugged in the powercord and it wouldn't turn on. After trying a million different things, like taking the battery out, reseting the PRAM, etc, there were a few times where I got it to turn on, went through the log on screen, and was able to use my computer like normal for about 5 minutes or so, and then it would just shut off.
    There were also many times when I would pres the power button and the screen would flash like it was about to turn on, and then it would make the noise that the computer makes when you're typically on 0% battery and it shuts down. Later in the night, when the computer was closed but plugged into the power outlet, it was by itself (meaning I wasn't pressing anything) making the noise that it was restarting. It made that noise about every 30 seconds for a few minutes. Weird.
    It was also doing inconsistent things re: the sleep light. At times it was on, including when the computer was closed, and sometimes it would go from on to off. Also, the battery/charing was doing weird things. The few times I was able to get past the log in screen it showed that it was at 0%, even though the light on the adapter was green and it had been plugged in for a long time. Another time the battery icon had an X through it. I have 2 different batteries and neither one of them seemed to make a difference.
    Also, yesterday I brought my computer into the Apple store and they put in a battery that was charged and it didn't seem to make a difference either. One more weird thing: when I did get the computer on in the spotlight bar it said it was indexing??
    Anyways, I'm just confused/upset, etc. because I literally did nothing to the computer. I didn't drop it/spill on it, etc. I'm also frustrated because the guy at the genius bar litteraly only spent like 5 minutes looking at before he said i was SOL. He said it was the "main board" that was the problem. One of the things like I'm just confused by is if the main board really does need to be replaced, then how was I able to get the computer on and working those few times???
    Sorrry this is so long, any help would be awesome!! I just don't have the money to buy a new computer, and I'm not sure it will be worth it for me to pay $300 to have it fixed when my computer's already pretty old and other things haven't been working for awhile (like my disc drive, camera). THANK YOU!!!

    EmadJamal,
    the battery won’t melt because of long connection to the AC charger, although that has the potential of reducing the battery’s life.
    Do you have access to a second 60 W AC charger to test with your MacBook Pro, or access to a second 13-inch MacBook Pro against which your AC charger could be tested?

  • Weird things happen in Edit view...

    Some (but NOT all)of my photos do weird things when you Double-Click them to get into Edit view. Most of my photos zoom in to their appropriate sizes and are viewed 'normally', however, other photos initially come up in their normal zoomed size then in a second of two, zoom in again several times larger than they should be, and the colors will pop your eyes out, like a reverse negative or something and the photos gets all 'chunky' or 'blocky'. Fortunately, only a small number of my photos zoom in wildly like this.
    Anyone seen this, have a clue what causes it and most importantly, can it be fixed to STOP doing this?
    Thanks

    Well, I used to see this problem way back in the v7 days of the purple app. It's not an FCP exclusive problem, though I have seen it happen one time with Final Cut.
    Glad to help you solve this one, Jamie. You can help others who come to this thread later, by marking the Helpful & Solved posts in the thread. That way, when others are searching for solutions to this problem, they can scan down quickly and easily to those posts, and see the yellow and green stars.
    I've posted this request on a number of threads, both those I've helped or solved, and those I had no helpful contributions for. I'm just trying to help make the new forum as usable as ut can be.

  • Weird thing going on with Expose and Dock

    Weird things have been going on with my Macbook Pro. It's been like this for several months and it's very annoying. What happened was that at some point during using computer, the dock and the expose will go on doing strange stuff together, for the dock, it's the magnification not working properly, when i move my mouse over any application icon, the magnification didn't come up, but if I click on it it will, however, after having clicked on the icon it will not doing the jump motion like it usually does, what it does is that it's going to stay being magnified, even if i point the mouse elsewhere. That's the dock. The problem with the expose is with the all window view, where when i turn it on everything seems to be normal, but if i move my mouse around, anywhere, each window that has been shown in the "all window" view will keep flashing until i dont move my mouse again. And that's the expose problem. Two other problems that occur along with the annoying issue mentioned earlier is that say when you click on the apple icon on the top, usually when you move down along there will be a blue stripe as a background to the words like "About this mac", "System preferences" etc, but when the problem occurs it will not do that. And if you have any window opened that has a scroll for horizontally, it'll keep forcing me to the right hand side of the bar, even if i drag it to the left it'll still go straight to the right hand side automatically. These are the problems that log-out-then-log-in won't resolve, needs to be restarted, i cannot work under this kind of situation, and it's getting really frustrating although i really like my mac still. I'm not sure when it started to do this, one time i thought maybe an application like p2p may disrupt the system so one time i only had calendar, itunes working still it happened again. I have a macbook pro A1226, has been updated to 10.5 and went through all the software update already... still... Does anyone have have the similar or maybe exact same problem as I do here? Please let me know. If you know how to fix it even better, I'd appreciate that. Thanks.

    Hello Karsten,
    These are the requested lines
    192.168.1.x/24 is my local lan.
    I want to make a RDP session from my PC (192.168.1.x) to a server on the customer lan for example 172.31.2..x
    access-list VPN_Filter line 2 extended permit object RDP object-group DM_INLINE_NETWORK_8 object Lan-Pat 0x7a06853d
      access-list VPN_Filter line 2 extended permit tcp 192.168.5.0 255.255.255.0 range 1 65535 192.168.1.0 255.255.255.0 eq 3389 (hitcnt=0) 0x6dbbab46
      access-list VPN_Filter line 2 extended permit tcp 172.31.2.0 255.255.255.0 range 1 65535 192.168.1.0 255.255.255.0 eq 3389 (hitcnt=0) 0x4fede2a3
      access-list VPN_Filter line 2 extended permit tcp 10.255.2.0 255.255.255.0 range 1 65535 192.168.1.0 255.255.255.0 eq 3389 (hitcnt=0) 0xf63149ed
      access-list VPN_Filter line 2 extended permit tcp 192.168.0.0 255.255.255.0 range 1 65535 192.168.1.0 255.255.255.0 eq 3389 (hitcnt=0) 0xf6c544e9

  • I have an iphone 4 that I recently upgraded to IOS 7, and now I cant drag music to it.  It says "preparing to update" eternally.  Weird thing is... I have an iphone 3s that is IOS 6, and it takes new music all day.  arg.

    I have an iphone 4 that I recently upgraded to IOS 7, and now I cant drag music to it.  It says "preparing to update" eternally.  Weird thing is... I have an iphone 3s that is IOS 6, and it takes new music all day.  arg.
    I have tried direct connecting the iphone 4, via wifi, everything.  I hate itunes with a passion, but it seems to be a necessary evil.  I dont know why I would have no trouble with my iphone 3.  I am using the same technique for both phones.  Find the music I want in the library and drag it to the iphone.  Works on IOS 6, not IOS 7.
    WHat else should I try?

    Hi jeffmbellucci,
    If you are having issues dragging music to your iPhone 4 after a recent upgrade to iOS 7, you may want to verify that the phone is still set to "Manually manage music and videos." You may find the following article helpful:
    Apple Support: Managing content manually on iPhone, iPad, and iPod
    http://support.apple.com/kb/ht1535
    Regards,
    - Brenden

  • [svn] 1751: Bug: BLZ-174 - MessageClient.testMessage() is incorrectly doing a string compare for the subtopic header of an inbound message against the subtopic value (which may contain wildcards) that the Consumer is using.

    Revision: 1751
    Author: [email protected]
    Date: 2008-05-15 14:21:43 -0700 (Thu, 15 May 2008)
    Log Message:
    Bug: BLZ-174 - MessageClient.testMessage() is incorrectly doing a string compare for the subtopic header of an inbound message against the subtopic value (which may contain wildcards) that the Consumer is using.
    QA: No - customer verified the fix.
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-174
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/MessageClient.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/services/MessageService.java

    If you create a metadatatype with a single metdata block, and you reference that in your vm/cm cell attribute using a *one* based index, Excel seems to see the link and it honors it when saving the spreadsheet.
    So, I ended up with something like:
    <c ... cm="1"/> (I'm dealing with cell metadata, but the concept is equivalente to value metadata)
    <metadataTypes count="1">
      <metadataType name="MyMetaType" .../>
    </metadataTypes>
    <futureMetadata count="1" name="MyMetaType">
      <bk>
        <extLst><ext
    uri="http://example" xmlns:x="http://example"><x:val>87</x:val></ext></extLst>
      </bk>
    </futureMetadata>
    <cellMetadata count="1">
      <bk><rc
    t="1" v="0"/></bk> <!-- this is what gets referenced as cm=1 on the cell -->
    </cellMetadata>
    Hope this helps. 

  • Crystal report static string parameter is running with null value too...

    Hi All,
    I am new to crystal report . I am using crystal report XI and in the report I designed contain one static string parameter. If I not enter any value in that parameter field still myu report get run.As per requirement I dnt want to run report unless user enter any value in that field. How to do it? Please help. any comment is valuable.
    Thanks

    Thanks Json ..
    your solution really helps me.Thanks again.
    One more issue is here,
    I have one subreport . In that  'amount ' field is present which have data type as 'character'  in database. I convert it in numeric by using following fromula,
    if NumericText ({Command.AMOUNT})
    then                                                     
    ToNumber ({Command.AMOUNT})
    when I run report in designer, it works but when I run it on crystal report server it throws error ad "Error in File :Error in formula . 'if NumericText ({Command.AMOUNT}) ' This field name is not known. Details: errorKind "
    Can u please help me out of it.
    Edited by: girish_613 on May 10, 2010 10:25 AM

  • I opened my iPhoto library today which was stored on an external hard drive and several of my videos now will not play. The weird thing is that each file shows a duration of 1 second and when I open them it just shows one frame. What the

    I opened my iPhoto library today which was stored on an external hard drive and several of my videos now will not play at all. The weird thing is that each file shows a duration of 1 second and when I open them it just shows one frame. What the !&%$#@ Where did my original video files go?

    Sounds like a good plan, you can never be to safe and having a second External HD is safer than one.
    The only thing that I would do different, is setup the 3T as my TimeMachine Backup and then erase and move my Photos, Videos and perhaps even iTunes Media to the 1T. That way you will have room to backup both the Internal Hard Drive and the 1T External Hard Drive to the 3T using TimeMachine.
    Take your time, study and use the > Time Machine - Frequently Asked Questions if you get stuck or aren't sure how to make the move.
    Also see > iPhoto: How to move the Library folder to a new location
    iMovie ’08: Storing or moving your video library to an external hard disk
    and >  iTunes for Mac: Moving your iTunes Media folder

  • I bought my Iphone 5 a week ago, now suddenly my sound is gone when i play games, i checked everything and the weird thing is that when i put my headphone in i CAN hear the sound when in games, also he just plays music whitout my headphone. What could it

    Hello so as you can see in my question i have troubles with my sound
    I cant hear annything of my sound in game and i did check everything
    The weird thing is that when i put my headphone in i do hear the sound
    Also my music plays without my headphone
    Wat can it be ? Pls help !

    Ok, a little clarification then, you can hear music fine with the speaker and headphone?  You can hear a game's music fine with the headphone but not with the speaker?  Do you get the notification sounds ok with the speaker?
    If the speaker sound is acceptable with everything except the game then there is a problem with that game and its settings.
    If that is the case, you might want to try deleting the game and then downloading and reinstalling the game to see if that helps the problem.

  • I restored my iPod in the middle of a download, now it can't do anything but restore, and when i restore it, the screen gets stuck on weird things, like the apple screen or purple or yellow. how do i get it un-stuck?

    i restored my iPod in the middle of a download, now it can't do anything but restore, and when i restore it, the screen gets stuck on weird things, like the apple screen or purple or yellow. how do i get it un-stuck?

    Try:
    - iOS: Not responding or does not turn on
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.

  • Lines on LCD and a Weird Thing

    Today, after I've applied the invisibleSHEILD to my iPod Touch I started to notice lines or streaks on the screen. There's about 8 of them and at different angles I see different colors. Such as the one that runs right across the music App. At one angle it's light orange and light brown and at another it's dark orange and dark brown. They're happening every where. When I turn my iPod completely off they're still there but instead they're in shades of gray. So I supposed that it's the liquid from the invisibleSHEILD but the lines stop at the end of the clear part of the glass, not the black part.
    As for the weird thing after I finished putting on the invisibleSHEILD I could push the bottom-left corner of my iPod Touch screen into the device almost a millimeter. All the other corners were fine and stable. The screen was actually going inside!
    Message was edited by: iHave a iPod

    Hi micsmith66!
    Thank you for posting to our forum!  It is very difficult to say whether or not this had anything to do with living near the beach.  This will need to be checked out by our Factory Service Center.  To start the repair process, you'll need to complete a Repair Request on our website.
    If this is a time sensitive-matter, additional support options are available at Contact Us.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • What are these weird things in Apple Mail?

    Hi,
    Does anyone know what these weird things are in Apple Mail? (Please ignore the yellow markers)
    It often happens when I open the application in the first e-mail.
    Thanks!
    Teun

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click the line of text below to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. Post the contents of that window, if any — the text, please, not a screenshot. You can then close the TextEdit window. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|edu\.mit|org\.(amavis|apache|cups|isc|ntp|postfix|x)/{print $3}' | open -f -a TextEdit 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    launchctl list | sed 1d | awk '!/0x|com\.apple|edu\.mit|org\.(x|openbsd)/{print $3}' | open -f -a TextEdit 
    Step 4
    ls -1A /e*/mach* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts 2> /dev/null | open -f -a TextEdit  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of every login item' 2> /dev/null | open -f -a TextEdit 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Weird thing happening with my iCal

    A weird thing is happening with my iCal, I don't know if it's a bug... Today I was printing the months of September and October with all my appointments, and when I was checking October I have noticed that 14th was printed as Saturday and as Sunday too, and 15th became Monday, 16th became Tuesday, and so on.
    But in my computer screen the calendar was correct: 14 Saturday, 15 Sunday, 16 Monday, etc.
    I cannot figure out what could be happening and how to solve this.
    Any idea?
    Any help will be appreciated.
    PowerMac G4 1.5 AGP Graphics   Mac OS X (10.4.7)   1 GB RAM

    Today a friend of mine said that he had a similar problem with iCal when printing the month of October, and that he fixed this by changing the Time and Zone setting in System Preferences. When he changed the setting from Sao Paulo, Brazil to Buenos Aires, Argentina (the both have the same time zone) the problem was solved.
    Today I did this and my problem dissapeared too. But I would like to know why is this happening.

  • Using wildcards for String compare

    Hello,
    I want my prog to find out all Strings which start with the letters 'File'. How can I make a String compare by using wildcards ?
    Thanx,
    Findus

    You may use the String method startsWith to find strings beginning with File. eg. filename.startsWith("File")
    for more complicated comparisons you might want to use regular expressions.

Maybe you are looking for

  • DMS - Document checkin

    Hi, I want to check in a document from the sap applicationserver  (unix). I use the BAPI's: - BAPI_DOCUMENT_CREATE2 - BAPI_DOCUMENT_CHECKIN2 But the BAPI's chooses everytime the windows frontend. Any ideas? Kind regards Bernd

  • GarageBand Not Opening After Recent Update, iOS 8

    I updated GB today, already updating to iOS 8, and now I cannot access GB.  I will not reset GB as I will lose all my music in there, I assume.  Please tell me what will be done or what I need to do.  I am using this on my iPad mini with Retina displ

  • Setting up an iPad in Argentina?

    A friend in Argentina would like an iPad Mini.  What is the best way to set up the Apple ID for international use?  They do not intend to link a credit card to the account.  Can an Apple ID be set up without a credit card and can iTunes/Apple gift ca

  • After effects 7 won't install

    when I click on Adobe After Effects 7.0, it asks if I want to run the software, and I click on "RUN," then a window opens and immediately closes and another one comes up, "Adobe AD 7.0 Installer Information" w/ exclamation mark in yellow triangle say

  • Show ip arp not populating

    Hello I have a strange issue where a "show ip arp" only populates local addresses but does not populate with addresses learnt on interfaces in that VLAN. For example, vlan 10 has dozens of IP addresses attached on individual access ports. If I ping t