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

Prevent unsafe cast to TestResult. #84

Merged
merged 1 commit into from Nov 8, 2017

Conversation

Projects
None yet
4 participants
@mwoodland
Contributor

mwoodland commented Oct 19, 2017

There are already null checks in TestResult.getPreviousResult() that calls AbstractRestResultAction.findCorrespondingResult() so presumably it's safe to return null here if the results aren't available.

The jenkins cucumber test result plugin (https://wiki.jenkins.io/display/JENKINS/Cucumber+Test+Result+Plugin) was getting a ClassCastException. This was being caused after having just installed the plugin and trying to call the json api as it was trying to get results from a previous build from before the plugin was installed:

Caused by: java.lang.ClassCastException: hudson.tasks.test.AggregatedTestResultAction$1 cannot be cast to hudson.tasks.test.TestResult
at hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:252)
at hudson.tasks.test.TestResult.getPreviousResult(TestResult.java:146)
... 125 more

Prevent unsafe cast to TestResult.
There are already null checks in TestResult.getPreviousResult() that calls AbstractRestResultAction.findCorrespondingResult() so presumably it's safe to return null here if the results aren't available.

The jenkins cucumber test result plugin (https://wiki.jenkins.io/display/JENKINS/Cucumber+Test+Result+Plugin) was getting a ClassCastException. This was being caused after having just installed the plugin and trying to call the json api as it was trying to get results from a previous build from before the plugin was installed:

Caused by: java.lang.ClassCastException: hudson.tasks.test.AggregatedTestResultAction$1 cannot be cast to hudson.tasks.test.TestResult
        at hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:252)
        at hudson.tasks.test.TestResult.getPreviousResult(TestResult.java:146)
        ... 125 more
@oleg-nenashev

Not sure how it happens, but having a check is good anyway.

@abayer abayer merged commit a70eb66 into jenkinsci:master Nov 8, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment