Skip to content

Commit

Permalink
JENKINS-65262 Avoid holding queue lock when updating GitHub (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Apr 1, 2021
1 parent 3e59698 commit b97c8fa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@
<serialVersionUID>1</serialVersionUID>
<justification>Adding actions list with an initial empty value should not break the compatibility.</justification>
</item>
<item>
<regex>true</regex>
<code>java.annotation.*</code>
<annotation>@edu.umd.cs.findbugs.annotations.*</annotation>
<justification>Annotation should be safe to change.</justification>
</item>
<item>
<regex>true</regex>
<code>java.missing.*</code>
Expand Down
2 changes: 2 additions & 0 deletions spotbugs-exclusion-filter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<FindBugsFilter>
</FindBugsFilter>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.jenkins.plugins.checks.status;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.Computer;
import hudson.model.Job;
import hudson.model.Queue;
import hudson.model.Result;
Expand Down Expand Up @@ -96,7 +98,7 @@ static Optional<String> getChecksName(final Job<?, ?> job) {
}

@CheckForNull
static ChecksOutput getOutput(final Run run) {
static ChecksOutput getOutput(final Run<?, ?> run) {
if (!(run instanceof FlowExecutionOwner.Executable)) {
return null;
}
Expand All @@ -111,7 +113,7 @@ static ChecksOutput getOutput(final Run run) {
return getOutput(run, execution);
}

static ChecksOutput getOutput(final Run run, final FlowExecution execution) {
static ChecksOutput getOutput(final Run<?, ?> run, final FlowExecution execution) {
return new FlowExecutionAnalyzer(run, execution, findProperties(run.getParent()).isSuppressLogs(run.getParent())).extractOutput();
}

Expand All @@ -137,9 +139,16 @@ public void onEnterWaiting(final Queue.WaitingItem wi) {
return;
}

final Job job = (Job) wi.task;
getChecksName(job).ifPresent(checksName -> publish(ChecksPublisherFactory.fromJob(job, TaskListener.NULL),
ChecksStatus.QUEUED, ChecksConclusion.NONE, checksName, null));
final Job<?, ?> job = (Job<?, ?>) wi.task;
getChecksName(job).ifPresent(checksName -> runAsync(() -> {
ChecksPublisher publisher = ChecksPublisherFactory.fromJob(job, TaskListener.NULL);
publish(publisher, ChecksStatus.QUEUED, ChecksConclusion.NONE, checksName, null);
}));
}

@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
private void runAsync(Runnable run) {
Computer.threadPoolForRemoting.submit(run);
}
}

Expand Down Expand Up @@ -236,7 +245,7 @@ public void onNewHead(final FlowNode node) {

Run<?, ?> run;
try {
run = (Run) node.getExecution().getOwner().getExecutable();
run = (Run<?, ?>) node.getExecution().getOwner().getExecutable();
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to find Run from flow node.", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.plugins.checks.api;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -15,6 +16,7 @@
*/
@SuppressWarnings({"VisibilityModifier", "MissingJavadocMethod"})
@RunWith(Parameterized.class)
@SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public class TruncatedStringTest {
private static final String MESSAGE = "Truncated"; // length 9

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.plugins.checks.status;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.Job;
import hudson.model.Result;
import hudson.model.Run;
Expand All @@ -26,6 +27,7 @@
* accordingly.
*/
@SuppressWarnings("PMD.AddEmptyString")
@SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public class BuildStatusChecksPublisherITest extends IntegrationTestWithJenkinsPerTest {

/**
Expand Down

0 comments on commit b97c8fa

Please sign in to comment.