forked from scream3r/java-simple-serial-connector
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Description
Calling SerialPortList.getPortNames() while or close to (<1 sec) unplugging a serial device, I encountered the following exception:
java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "this.text" is null
at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1769)
at java.base/java.util.regex.Matcher.reset(Matcher.java:415)
at java.base/java.util.regex.Matcher.<init>(Matcher.java:252)
at java.base/java.util.regex.Pattern.matcher(Pattern.java:1134)
at jssc.SerialPortList.getWindowsPortNames(SerialPortList.java:317)
at jssc.SerialPortList.getPortNames(SerialPortList.java:300)
at jssc.SerialPortList.getPortNames(SerialPortList.java:184)
<my software calling SerialPortList.getPortNames()>
This seems to be caused by portName being null in:
https://github.com/java-native/jssc/blob/master/src/main/java/jssc/SerialPortList.java#L317
I think a simple fix would be to insert a portName != null check on this line, ignoring null (very recently removed) ports.
This exception occurred using jssc-2.9.4.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working