Skip to content

Commit

Permalink
Fix issue scijava#406 without a location call handler supportsOpen(st…
Browse files Browse the repository at this point in the history
…ring)

This commit fixes an issue caused by calling the Location version of the
method supportsOpen() in all cases when many IOPlugin do not yet
implement that Location version of that method and therefore always
return false. Instead now IOService getOpener(string) directly calls the
string version of supportsOpen. This ensures older IOPlugin that can
support the file provided are discovered and used.
  • Loading branch information
karlduderstadt committed Feb 26, 2021
1 parent 46ca0d0 commit a0f04b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/scijava/io/IOService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public interface IOService extends HandlerService<Location, IOPlugin<?>>,
* location.
*/
default IOPlugin<?> getOpener(final String source) {
return getOpener(new FileLocation(source));
for (final IOPlugin<?> handler : getInstances()) {
if (handler.supportsOpen(source)) return handler;
}
return null;
}

/**
Expand Down

0 comments on commit a0f04b2

Please sign in to comment.