Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ public Set<UsbSerialDeviceInformation> scanAllUsbDevicesInformation() {
}

Set<UsbSerialDeviceInformation> result = new HashSet<>();
String[] deviceKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, USB_REGISTRY_ROOT);
String[] deviceKeys;
try {
deviceKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, USB_REGISTRY_ROOT);
} catch (RuntimeException e) {
Comment thread
lolodomo marked this conversation as resolved.
Outdated
logger.debug("registryGetKeys failed for {}", USB_REGISTRY_ROOT, e);
return result;
}

for (String deviceKey : deviceKeys) {
logger.trace("{}", deviceKey);
Expand Down Expand Up @@ -171,14 +177,26 @@ public Set<UsbSerialDeviceInformation> scanAllUsbDevicesInformation() {
String serialNumber = ids.length > 2 ? ids[2] : null;

String devicePath = USB_REGISTRY_ROOT + BACKSLASH + deviceKey;
String[] interfaceNames = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, devicePath);
String[] interfaceNames;
try {
interfaceNames = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, devicePath);
} catch (RuntimeException e) {
Comment thread
lolodomo marked this conversation as resolved.
Outdated
logger.debug("registryGetKeys failed for {}", devicePath, e);
continue;
}

int interfaceId = 0;
for (String interfaceName : interfaceNames) {
logger.trace(" interfaceId:{}, interfaceName:{}", interfaceId, interfaceName);

String interfacePath = devicePath + BACKSLASH + interfaceName;
TreeMap<String, Object> values = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE, interfacePath);
TreeMap<String, Object> values;
try {
values = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE, interfacePath);
} catch (RuntimeException e) {
Comment thread
lolodomo marked this conversation as resolved.
Outdated
logger.debug("registryGetValues failed for {}", interfacePath, e);
continue;
}

if (logger.isTraceEnabled()) {
for (Entry<String, Object> value : values.entrySet()) {
Expand Down Expand Up @@ -211,15 +229,27 @@ public Set<UsbSerialDeviceInformation> scanAllUsbDevicesInformation() {
}

String serialPort = "";
String[] interfaceSubKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, interfacePath);
String[] interfaceSubKeys;
try {
interfaceSubKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, interfacePath);
} catch (RuntimeException e) {
Comment thread
lolodomo marked this conversation as resolved.
Outdated
logger.debug("registryGetKeys failed for {}", interfacePath, e);
continue;
}

for (String interfaceSubKey : interfaceSubKeys) {
if (!KEY_DEVICE_PARAMETERS.equals(interfaceSubKey)) {
continue;
}
String deviceParametersPath = interfacePath + BACKSLASH + interfaceSubKey;
TreeMap<String, Object> deviceParameterValues = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE,
deviceParametersPath);
TreeMap<String, Object> deviceParameterValues;
try {
deviceParameterValues = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE,
deviceParametersPath);
} catch (RuntimeException e) {
Comment thread
lolodomo marked this conversation as resolved.
Outdated
logger.debug("registryGetValues failed for {}", deviceParametersPath, e);
continue;
}
Object serialPortValue = deviceParameterValues.get(KEY_SERIAL_PORT);
if (serialPortValue instanceof String serialPortString) {
serialPort = serialPortString;
Expand Down