mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 521515: Do not log every failed access attempt
The Windows registry can be checked for keys that may not exist. In order to avoid logging an exception that the entry is missing when it's not critical that the entry do exist, the method should just return null and let the caller handle if it's critical or not that the entry exists. To easily debug situations where the entry is supposed to always exist, the trace symbol "org.eclipse.cdt.core.native/debug/win32/registry" can be set to "true" and the exceptions will be logged in any case. Change-Id: I6603cbe363ebecd357fa44c41fb1a26c6345dd70 Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
a708a1dcc9
commit
09582630d7
3 changed files with 18 additions and 4 deletions
4
core/org.eclipse.cdt.core.native/.options
Normal file
4
core/org.eclipse.cdt.core.native/.options
Normal file
|
@ -0,0 +1,4 @@
|
|||
org.eclipse.cdt.core.native/debug=false
|
||||
|
||||
# Used by org.eclipse.cdt.core.win32 fragment
|
||||
org.eclipse.cdt.core.native/debug/win32/registry=false
|
|
@ -20,7 +20,8 @@ bin.includes = plugin.properties,\
|
|||
about.mappings,\
|
||||
cdt_logo_icon32.png,\
|
||||
about.properties,\
|
||||
plugin.xml
|
||||
plugin.xml,\
|
||||
.options
|
||||
src.includes = about.html,\
|
||||
schema/,\
|
||||
native_src/
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.win32;
|
|||
|
||||
import org.eclipse.cdt.internal.core.natives.CNativePlugin;
|
||||
import org.eclipse.cdt.utils.WindowsRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Advapi32;
|
||||
|
@ -33,6 +34,8 @@ import com.sun.jna.ptr.IntByReference;
|
|||
*/
|
||||
public class WindowsRegistryImpl extends WindowsRegistry {
|
||||
|
||||
private final static boolean DEBUG = Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/win32/registry"); //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public String getLocalMachineValue(String subkey, String name) {
|
||||
return getValue(WinReg.HKEY_LOCAL_MACHINE, subkey, name);
|
||||
|
@ -67,7 +70,9 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
try {
|
||||
return Advapi32Util.registryGetStringValue(key, subkey, name);
|
||||
} catch (Win32Exception e) {
|
||||
if (DEBUG) {
|
||||
CNativePlugin.log(String.format("Unable to get value for %s in %s", name, subkey), e); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +87,9 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
Advapi32Util.registryCloseKey(phkKey.getValue());
|
||||
}
|
||||
} catch (Win32Exception e) {
|
||||
if (DEBUG) {
|
||||
CNativePlugin.log(String.format("Unable to get keyname for %s at index %d", subkey, index), e); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +112,9 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
Advapi32Util.registryCloseKey(phkKey.getValue());
|
||||
}
|
||||
} catch (Win32Exception e) {
|
||||
if (DEBUG) {
|
||||
CNativePlugin.log(String.format("Unable to get valuename for %s at index %d", subkey, index), e); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue