Skip to content

Commit

Permalink
[JENKINS-66258] Retrieve non transient actions to prevent deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Dohbedoh authored and jakub-bochenski committed Dec 2, 2024
1 parent 9c7e1f8 commit a10e30d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ public void updateResult()
Result result = build.getResult();
this.result = result == null ? null : result.toString();
}
Action testResultAction = build.getAction(AbstractTestResultAction.class);
@SuppressWarnings("deprecation") // We don't need transient actions
Action testResultAction = build.getActions().stream()
.filter(action -> action instanceof AbstractTestResultAction).findFirst()
.orElse(null);
if (testResults == null && testResultAction != null) {
testResults = new TestData(testResultAction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void before() throws Exception {
when(mockBuild.getBuildVariables()).thenReturn(Collections.emptyMap());
when(mockBuild.getSensitiveBuildVariables()).thenReturn(Collections.emptySet());
when(mockBuild.getEnvironments()).thenReturn(null);
when(mockBuild.getAction(AbstractTestResultAction.class)).thenReturn(mockTestResultAction);
when(mockBuild.getActions()).thenReturn(Collections.singletonList(mockTestResultAction));
when(mockBuild.getLog(3)).thenReturn(Arrays.asList("line 1", "line 2", "line 3", "Log truncated..."));
when(mockBuild.getEnvironment(null)).thenReturn(new EnvVars());
when(mockBuild.getExecutor()).thenReturn(mockExecutor);
Expand Down Expand Up @@ -167,7 +167,7 @@ public void constructorSuccess() throws Exception {
verify(mockBuild).getFullDisplayName();
verify(mockBuild).getDescription();
verify(mockBuild).getUrl();
verify(mockBuild).getAction(AbstractTestResultAction.class);
verify(mockBuild).getActions();
verify(mockBuild).getExecutor();
verify(mockBuild, times(2)).getNumber();
verify(mockBuild).getTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void before() throws Exception {
when(mockBuild.getBuildVariables()).thenReturn(Collections.emptyMap());
when(mockBuild.getSensitiveBuildVariables()).thenReturn(Collections.emptySet());
when(mockBuild.getEnvironments()).thenReturn(null);
when(mockBuild.getAction(AbstractTestResultAction.class)).thenReturn(mockTestResultAction);
when(mockBuild.getActions()).thenReturn(Collections.singletonList(mockTestResultAction));
when(mockBuild.getEnvironment(mockListener)).thenReturn(new EnvVars());
when(mockBuild.getRootBuild()).thenReturn(mockRootBuild);

Expand Down Expand Up @@ -138,7 +138,7 @@ private void verifyMocks() throws Exception
verify(mockBuild).getDescription();
verify(mockBuild).getStartTimeInMillis();
verify(mockBuild).getUrl();
verify(mockBuild).getAction(AbstractTestResultAction.class);
verify(mockBuild).getActions();
verify(mockBuild).getExecutor();
verify(mockBuild).getNumber();
verify(mockBuild).getTimestamp();
Expand Down Expand Up @@ -264,7 +264,7 @@ public void constructorSuccessTestFailures() throws Exception {

@Test
public void constructorSuccessNoTests() throws Exception {
when(mockBuild.getAction(AbstractTestResultAction.class)).thenReturn(null);
when(mockBuild.getActions()).thenReturn(Collections.emptyList());

// Unit under test
BuildData buildData = new BuildData(mockBuild, mockDate, mockListener);
Expand Down

0 comments on commit a10e30d

Please sign in to comment.