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

ExecutorLibrarySourceProvider using static source-based references to FHIRHelper #6

Open
MikeRileyGTRI opened this issue Sep 19, 2018 · 1 comment

Comments

@MikeRileyGTRI
Copy link
Contributor

MikeRileyGTRI commented Sep 19, 2018

ExecutorLibrarySourceProvider uses this code to search for libraries to load at runtime.
@Override public InputStream getLibrarySource(VersionedIdentifier versionedIdentifier) { Path path = Paths.get("src/main/resources").toAbsolutePath(); File source = new File(path.resolve(versionedIdentifier.getId() + "-" + versionedIdentifier.getVersion() + ".cql").toString());

try { return new FileInputStream(source); } catch (FileNotFoundException e) { throw new IllegalArgumentException("Cannot find library source " + versionedIdentifier.getId()); } }

The Paths base directory is FileSystem-dependent however, and doesn't translate over well. Deploying the war to tomcat, for example, breaks the library loading.

The Paths documentation itself provides a proposed solution

The Path is obtained by invoking the getPath method of the default FileSystem. Note that while this method is very convenient, using it will imply an assumed reference to the default FileSystem and limit the utility of the calling code. Hence it should not be used in library code intended for flexible reuse. A more flexible alternative is to use an existing Path instance as an anchor, such as:

Path dir = ... Path path = dir.resolve("file");

Paths Documentation Here

@brynrhodes
Copy link
Contributor

@MikeRileyGTRI , thank you for the suggestion, we'll look at getting this added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants