Skip to content

Commit 79ad944

Browse files
Copilotrpdome
andauthored
Apply code-review feedback: input validation, interrupt handling, dispatch try/catch, richer error messages
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/3b42a162-07a3-4bfb-9b33-bf29afe1d139 Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
1 parent 7de08fb commit 79ad944

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/concurrent/ConcurrentAcquireTokenSilentHelper.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ public static StressResult run(
158158
final long perWaveTimeoutSec,
159159
final SilentTokenRequester requester) throws InterruptedException {
160160

161+
if (threadCount <= 0) {
162+
throw new IllegalArgumentException("threadCount must be > 0");
163+
}
164+
if (iterations <= 0) {
165+
throw new IllegalArgumentException("iterations must be > 0");
166+
}
167+
if (perWaveTimeoutSec <= 0) {
168+
throw new IllegalArgumentException("perWaveTimeoutSec must be > 0");
169+
}
170+
161171
final AtomicBoolean stopped = new AtomicBoolean(false);
162172
final AtomicReference<CountDownLatch> currentWaveLatch = new AtomicReference<>();
163173
final List<String> errors = Collections.synchronizedList(new ArrayList<>());
@@ -181,11 +191,14 @@ public static StressResult run(
181191
// Synchronise all threads so every wave fires together.
182192
try {
183193
waveBarrier.await();
194+
} catch (final InterruptedException ie) {
195+
Thread.currentThread().interrupt();
196+
break;
184197
} catch (final Exception barrierEx) {
185198
if (!stopped.get()) {
186199
errors.add("Thread " + threadIndex
187200
+ " barrier failed at wave " + iter
188-
+ ": " + barrierEx.getMessage());
201+
+ ": " + barrierEx);
189202
}
190203
break;
191204
}
@@ -200,7 +213,13 @@ public static StressResult run(
200213
final CountDownLatch waveDone = currentWaveLatch.get();
201214
final int currentIter = iter;
202215

203-
requester.request(threadIndex, currentIter, waveDone, errors);
216+
try {
217+
requester.request(threadIndex, currentIter, waveDone, errors);
218+
} catch (final Throwable dispatchError) {
219+
errors.add("Thread " + threadIndex + " iter " + currentIter
220+
+ " dispatch failed: " + dispatchError);
221+
waveDone.countDown();
222+
}
204223

205224
// Wait for every callback in this wave before starting the next.
206225
try {

msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/concurrent/TestCaseConcurrentAcquireTokenSilent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ public void onSuccess(
177177
public void onError(
178178
final MsalException exception) {
179179
errors.add("Thread " + threadIndex
180-
+ " iter " + iteration + ": "
181-
+ exception.getMessage());
180+
+ " iter " + iteration + " ["
181+
+ exception.getErrorCode() + "]: "
182+
+ exception);
182183
done.countDown();
183184
}
184185
})

0 commit comments

Comments
 (0)