sjamesr / jfreesane

Java API to talk to the SANE scanning daemon
Apache License 2.0
60 stars 24 forks source link

listDevices() makes subsequent device.open() fail with STATUS_UNSUPPORTED #100

Closed jspyro closed 3 years ago

jspyro commented 4 years ago

I stumbled upon this weird behaviour: Calling listDevices() seems to leave the session in a broken state. When trying to open a device afterwards, it throws a SaneException with STATUS_UNSUPPORTED. The next attempt on opening the device works again.

Example

listDevices()
session.getDevice("mydevice")
device.open() // throws SaneException(STATUS_UNSUPPORTED)
device.open() // works again

Obvious workarounds would be closing and reopening the session after listDevices() or calling device.open() twice while catching the first exception.

I figured this could also be somehow related to the issue described in SaneSessionTest.java:multipleListDevicesCalls()

jspyro commented 4 years ago

Just created a PR (#101) that seems to fix the issue. I'm not quite sure this has no side effects but it does the trick for all cases I tested.

jspyro commented 3 years ago

PR #101 has been merged -> fixed