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

Fix deprecated uses of newInstance() #1887

Merged
merged 2 commits into from Jun 2, 2023
Merged

Conversation

lbergelson
Copy link
Member

Replace instances of newInstance() which is deprecated with getDeclaredConstructor().newInstance() which is the drop in replacement.

Copy link
Contributor

@droazen droazen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment to address, otherwise looks good

final CommandLineProgram program;
try {
program = (CommandLineProgram) Class.forName(programClassname).getDeclaredConstructor().newInstance();
} catch (InvocationTargetException | NoSuchMethodException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced that with catch (ReflectiveOperationException e) and removed a bunch of boilerplate.

@@ -267,7 +274,7 @@ static void assertCRAM(final File outputFile) {
try (InputStream in = new FileInputStream(outputFile)) {
Assert.assertTrue(SamStreams.isCRAMFile(new BufferedInputStream(in)), "File " + outputFile.getAbsolutePath() + " is not a CRAM.");
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeIOException(e);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed this from a silent success to an exception since it seems like it could easily hide errors.

@lbergelson lbergelson merged commit 4527d6d into master Jun 2, 2023
3 checks passed
@lbergelson lbergelson deleted the lb_fix_deprecated_use branch June 2, 2023 20:53
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

Successfully merging this pull request may close these issues.

None yet

2 participants