Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registryValueExists() throws exception if key does not exist #1036

Closed
jansohn opened this issue Nov 16, 2018 · 1 comment
Closed

registryValueExists() throws exception if key does not exist #1036

jansohn opened this issue Nov 16, 2018 · 1 comment

Comments

@jansohn
Copy link

jansohn commented Nov 16, 2018

Checking the existence of a registry value throws an exception if the key does not exist:

Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "FAIL", "Path");

Stack trace:

com.sun.jna.platform.win32.Win32Exception: The handle is invalid.
	at com.sun.jna.platform.win32.Advapi32Util.registryValueExists(Advapi32Util.java:661)
	at com.sun.jna.platform.win32.Advapi32Util.registryValueExists(Advapi32Util.java:612)

I expected it to simply return false, especially as the exception occurs in the finally block when cleaning up. Can be worked around by first checking the existence of the registry key.

  • JNA 5.1.0
  • Oracle JDK 1.8.0_181 (64bit)
  • Windows 10 / Windows Server 2016 (64bit)

PS: I don't have a Google account and I don't want to create one. As there are no alternative ways to participate in the mailing list I directly created the issue here.

@matthiasblaesing
Copy link
Member

Fixed via 15d6208. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants