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

Follow general contract of comparison method #345

Merged

Conversation

Projects
None yet
2 participants
@Jimilian
Copy link
Contributor

commented Jan 22, 2018

Old implemenation did not respect transitive requirement of comparison
method. I.e.:
If A == B and B == C, then A must be equal to C.

So, in old implementation if B is null, first two checks return true, but it does not gurantee that A == C.

That leads to:

Jan 22, 2018 11:04:58 AM com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.GerritNotifier buildCompleted
SEVERE: Could not complete BuildCompleted notification!
java.lang.IllegalArgumentException: Comparison method violates its general contract!
        at java.util.TimSort.mergeHi(TimSort.java:899)
        at java.util.TimSort.mergeAt(TimSort.java:516)
        at java.util.TimSort.mergeForceCollapse(TimSort.java:457)
        at java.util.TimSort.sort(TimSort.java:254)
        at java.util.Arrays.sort(Arrays.java:1438)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander.createBuildsStats(ParameterExpander.java:798)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander.getBuildCompletedCommand(ParameterExpander.java:768)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander.fillOnCompletedParams(ParameterExpander.java:704)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander.getBuildCompletedCommands(ParameterExpander.java:670)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.GerritNotifier.buildCompleted(GerritNotifier.java:121)
        at com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.job.ssh.BuildCompletedCommandJob.run(BuildCompletedCommandJob.java:71)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Follow general contract of comparison method
Old implemenation did not respect transitive requirement of comparison
method. I.e.:
  If A == B and B == C, then A must be equal to C.

So, in old implementation if B is null, first two checks return true, but it does not gurantee that A == C.

@rsandell rsandell merged commit b95acf0 into jenkinsci:master Jan 25, 2018

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details

@Jimilian Jimilian deleted the Jimilian:fix_comporator_in_parameterexpander branch Jan 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.