vladislav-sidorovich commented on code in PR #16848:
URL: https://github.com/apache/iceberg/pull/16848#discussion_r3434290804
##########
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());
Review Comment:
Yes, the test will fail. I commented the `synchronyzed` section and run the
test. The test failed with the following error:
```
googleAuthManager.loadCredentials(
<any boolean>,
<any>,
<any boolean>,
<any>,
<any>
);
Wanted 1 time:
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.loadCredentials(GoogleAuthManager.java:128)
But was 10 times:
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
-> at
org.apache.iceberg.gcp.auth.GoogleAuthManager.initialize(GoogleAuthManager.java:105)
```
--
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]