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

org.hid4java.HidDevice.read(HidDevice.java:402) java.lang.NegativeArraySizeException: -1 on read failure #156

Open
fricpa opened this issue Jul 18, 2024 · 0 comments

Comments

@fricpa
Copy link

fricpa commented Jul 18, 2024

it's a bit confusing/discouraging that an error in the implementation leaks when a read fails:

2024-07-18T12:06:06,135 INFO  [org.example.Main.main()] org.example.tihidapi.impl.hid4java.TiHidApiSessionHid4JavaImplementation - writing: [63, 2, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ...
2024-07-18T12:06:06,136 TRACE [org.example.Main.main()] org.example.tihidapi.impl.hid4java.TiHidApiSessionHid4JavaImplementation - writing, as ISO/IEC 8859-1: ?.r.............................................................
> [40]: 3f 02 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2024-07-18T12:06:06,137 INFO  [org.example.Main.main()] org.example.tihidapi.impl.hid4java.TiHidApiSessionHid4JavaImplementation - reading attempt, at most for timeout=3000 ms...
2024-07-18T12:06:06,509 ERROR [org.example.Main.main()] org.example.Main - inner error, devicePath=UsbDevicePath(vendorId=0x2047, productId=0x0301, serialNumber='B4459C6F2B002100'), status=31119h,631610,451,0,0,1,0
 java.lang.RuntimeException: java.lang.NegativeArraySizeException: -1
        at org.example.tihidapi.impl.hid4java.TiHidApiSessionFactoryHid4JavaImplementation.runWithSession(TiHidApiSessionFactoryHid4JavaImplementation.java:41) ~[classes/:?]
        at org.example.apdapi.Api.read(Api.java:97) ~[classes/:?]
        at org.example.Main.main(Main.java:51) ~[classes/:?]
        at org.codehaus.mojo.exec.ExecJavaMojo.doMain(ExecJavaMojo.java:385) ~[?:?]
        at org.codehaus.mojo.exec.ExecJavaMojo.doExec(ExecJavaMojo.java:374) ~[?:?]
        at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0(ExecJavaMojo.java:296) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.NegativeArraySizeException: -1
        at org.hid4java.HidDevice.read(HidDevice.java:402) ~[hid4java-0.8.0.jar:0.8.0]
        at org.example.tihidapi.impl.hid4java.TiHidApiSessionHid4JavaImplementation.read(TiHidApiSessionHid4JavaImplementation.java:94) ~[classes/:?]
        at org.example.apdapi.Api.lambda$read$1(Api.java:108) ~[classes/:?]
        at org.example.tihidapi.impl.hid4java.TiHidApiSessionFactoryHid4JavaImplementation.runWithSession(TiHidApiSessionFactoryHid4JavaImplementation.java:39) ~[classes/:?]
        ... 6 more

this happened when I intentionally disconnected the device while it was being read. I would expect an IOException or something

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

1 participant