vladislav-sidorovich commented on code in PR #16848:
URL: https://github.com/apache/iceberg/pull/16848#discussion_r3530082072
##########
gcp/src/test/java/org/apache/iceberg/gcp/auth/TestGoogleAuthManager.java:
##########
@@ -221,6 +227,42 @@ public void initializationOccursOnlyOnce() {
mockedStaticCredentials.verify(GoogleCredentials::getApplicationDefault,
times(1));
}
+ @Test
+ public void concurrentInitialization() throws Exception {
+ int numThreads = 10;
+ ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
+ CountDownLatch startLatch = new CountDownLatch(1);
+ CountDownLatch finishLatch = new CountDownLatch(numThreads);
+
+ GoogleAuthManager spyManager = spy(authManager);
+ doReturn(credentials)
+ .when(spyManager)
+ .loadCredentials(anyBoolean(), any(), anyBoolean(), any(), any());
+
+ AtomicInteger successfulInitializations = new AtomicInteger(0);
+ for (int i = 0; i < numThreads; i++) {
+ executorService.submit(
+ () -> {
+ try {
+ startLatch.await();
+ spyManager.catalogSession(restClient, Collections.emptyMap());
+ successfulInitializations.incrementAndGet();
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ finishLatch.countDown();
+ }
+ });
+ }
+
+ startLatch.countDown();
+ finishLatch.await(10, TimeUnit.SECONDS);
Review Comment:
Ack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]