#8 RegistryKey.hasValues() inconsistent with Iterator

closed
nobody
None
2
2006-10-10
2006-09-27
Peter Becker
No

RegistryKey.hasValues() returns true in some
situations where the Iterator returned by
RegistryKey.values() returns false on the first
Iterator.hasNext() call.
In my opinion this is inconsistent and does not match
the behaviour documented for hasValues().
I think it happens if the only value shown in the MS
Registry Editor is (Default)/REG_SZ/(value not set),
but I'm not sure about this.

Discussion

  • Matt Hilliard
    Matt Hilliard
    2006-09-28

    Logged In: YES
    user_id=969951

    Curious.

    hasValues() makes the win32 API call RegQueryInfoKey where
    we query for count and return "count is > 0".
    The Iterator makes also calls RegQueryInfoKey (but
    simultaniously queries for the maximum value name length, so
    we can allocate space later for native strings). The
    Iterator call for hasNext returns "count < index of current
    value ", (where the initial index is also 0). There's very
    little other logic here, except check to ensure we can move
    data between the native and java side (which would result in
    errors far, far more spectacular than what you're seeing).

    The problem you're seeing here is count appears to be both 0
    and not 0 when we call RegQueryInfoKey--depending on some
    "magic" internal to win32. I can try splitting the Iterator
    call into 2 calls next time I'm on a Windows machine
    (Mid-October), but I honesly can't guarantee this will
    change much of anything, as we're not the ones generating
    the count.

    What flavour of Windows are you using?

    Matt

     
  • Matt Hilliard
    Matt Hilliard
    2006-10-04

    Logged In: YES
    user_id=969951

    Alright. I can't recreate this behavior at all on my 2K
    machine. A good example of a key that exhibits the an unset
    default value of type REG_SZ is HKEY_LOCAL_MACHINE/ and I
    consistently get false on hasValues() for this key.
    Not just this key, but also every single key in my registry
    having only a default unset REG_SZ as its value.
    I'm going to leave this open for a few months, if you let me
    know what flavour of windows this was occuring on for you,
    or any other info regarding the key or the access pattern
    that seems to trigger this behavior, I'll take another stab
    at it, otherwise, given the nature of the code involved with
    what you've described, and the fact I can't recreate the
    symptoms, I really have nothing to go on, and can't offer up
    anything for a solution.

     
  • Matt Hilliard
    Matt Hilliard
    2006-10-04

    • priority: 5 --> 2
     
  • Peter Becker
    Peter Becker
    2006-10-10

    Logged In: YES
    user_id=1094652

    I obeyed the behaviour on Windows XP (Multilanguage
    edition) SP 2.
    I will check it on some other Windows systems and come back
    with a report.

    Peter

     
  • Matt Hilliard
    Matt Hilliard
    2006-10-10

    Logged In: YES
    user_id=969951

    Hi Peter.
    That would be great.

    I can take a look at what's going on for a US-english SP2
    test machine, but again, given the nature of everything, I'm
    really not expecting to see much of anything we can fix.

    Can I also get you to verify this occurs on jRK 1.4.1, and
    which JVM(s) (both make and model) you see this behavior on?
    (I could guess Sun 1.4.2, but I'd probably be wrong)

    Lastly, My own little 30-line bug-hunting java file
    obviously returns nothing, so if you are able to recreate
    it, I'd appreciate whatever (30-ish)-line bug-hunting java
    file you use to find it with, to help me narrow the hunt on
    my end. You can attach it here or mail it to me.

    Matt

     
  • Peter Becker
    Peter Becker
    2006-10-10

    Logged In: YES
    user_id=1094652

    Oh, what did I do! I used the download at
    http://www.bayequities.com/tech/Products/jreg_key.shtml and
    got a pretty old version 1.0. It works with the current
    release well.
    Sorry for wasting your time.

    Peter

     
  • Matt Hilliard
    Matt Hilliard
    2006-10-10

    Logged In: YES
    user_id=969951

    Heh.
    I was really scratching my head on this one--I'm glad the
    new one works well for you.

    I'm closing this, let me know if you come across any
    difficulties with the new one.

     
  • Matt Hilliard
    Matt Hilliard
    2006-10-10

    • status: open --> closed