Skip to content

Commit 6d9153c

Browse files
committed
Fix infinite immediate retries that the client does when Bitbucket Data Center does not response.
Fix stackoverflow in BitbucketApiUtil unwrap method when exception has a cause that refer to itself
1 parent 1d76159 commit 6d9153c

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

checkstyle.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<property name="separatedStaticGroups" value="true" />
1919
<property name="option" value="bottom" />
2020
</module>
21+
<module name="LeftCurly">
22+
<property name="option" value="eol" />
23+
</module>
2124
<module name="UnusedImports" />
2225
<module name="AvoidStarImport" />
2326
</module>

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/client/ExponentialBackoffRetryStrategy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ public boolean retryRequest(HttpRequest request, IOException exception, int exec
154154
return handleAsIdempotent(request);
155155
}
156156

157+
@Override
158+
public TimeValue getRetryInterval(HttpRequest request, IOException exception, int execCount, HttpContext context) {
159+
return TimeValue.ofMilliseconds(getRetryInterval(execCount));
160+
}
161+
157162
/**
158163
* {@inheritDoc}
159164
*/

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/util/BitbucketApiUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ public static BitbucketRequestException unwrap(Exception e) {
121121
while (cause != null) {
122122
if (e instanceof BitbucketRequestException bbException) {
123123
return bbException;
124-
} else {
124+
} else if (cause != e.getCause()) { // avoid stackoverflow when cause is also the exception
125125
cause = e.getCause();
126+
} else {
127+
break;
126128
}
127129
}
128130
return null;

src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceBuildTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
3838
import com.cloudbees.plugins.credentials.domains.Domain;
3939
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
40-
import hudson.model.Item;
4140
import hudson.model.Descriptor.FormException;
41+
import hudson.model.Item;
4242
import hudson.plugins.git.GitSCM;
4343
import hudson.plugins.git.UserRemoteConfig;
4444
import hudson.plugins.git.extensions.impl.BuildChooserSetting;

0 commit comments

Comments
 (0)