Skip to content

Commit 5842660

Browse files
pditommasoclaude
andcommitted
Simplify cause-chain walk per review feedback
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a6e4fcd commit 5842660

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/main/groovy/io/seqera/wave/service/request/ContainerRequestServiceImpl.groovy

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class ContainerRequestServiceImpl implements ContainerRequestService {
134134
meterRegistry?.counter('wave.tokens.refresh', 'result', result)?.increment()
135135
}
136136

137-
// Cause chains are never deep; cap the walk so a cyclic chain (e.g. A->B->A) cannot spin forever.
138137
private static final int MAX_CAUSE_DEPTH = 50
139138

140139
/**
@@ -148,16 +147,16 @@ class ContainerRequestServiceImpl implements ContainerRequestService {
148147
for( int i = 0; e != null && i < MAX_CAUSE_DEPTH; e = e.cause, i++ ) {
149148
if( e instanceof TimeoutException || e instanceof HttpResponseException )
150149
return true
151-
if( e == e.cause )
152-
break
153150
}
154151
return false
155152
}
156153

157154
protected static String rootCauseMessage(Throwable t) {
155+
if( t == null )
156+
return null
158157
Throwable e = t
159158
int i = 0
160-
while( e.cause != null && e.cause != e && ++i < MAX_CAUSE_DEPTH )
159+
while( e.cause != null && e.cause != e && i++ < MAX_CAUSE_DEPTH )
161160
e = e.cause
162161
return e.message ?: e.class.simpleName
163162
}

0 commit comments

Comments
 (0)