smaheshwar-pltr commented on code in PR #14751:
URL: https://github.com/apache/iceberg/pull/14751#discussion_r2698625302
##########
gcp/src/main/java/org/apache/iceberg/gcp/GcpKeyManagementClient.java:
##########
@@ -100,11 +88,43 @@ public ByteBuffer unwrapKey(ByteBuffer wrappedKey, String
wrappingKeyId) {
@Override
public void close() {
- try {
- closeableGroup.close();
- } catch (IOException ioe) {
- // closure exceptions already suppressed and logged in closeableGroup
+ if (isResourceClosed.compareAndSet(false, true)) {
+ if (closeableGroup != null) {
+ closeableGroup.setSuppressCloseFailure(true);
+ try {
+ closeableGroup.close();
+ } catch (IOException ioe) {
+ // closure exceptions already suppressed and logged in closeableGroup
+ }
+ }
+ }
+ }
+
+ private KeyManagementServiceClient kmsClient() {
+ if (kmsClient == null) {
+ synchronized (this) {
+ if (kmsClient == null) {
+ GCPProperties gcpProperties = new GCPProperties(allProperties);
+ try {
+ KeyManagementServiceSettings.Builder kmsBuilder =
+ KeyManagementServiceSettings.newBuilder();
+ if (gcpProperties.oauth2Token().isPresent()) {
+ OAuth2Credentials oAuth2Credentials =
+
GCPAuthUtils.oauth2CredentialsFromGcpProperties(gcpProperties, closeableGroup);
+
kmsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(oAuth2Credentials));
+ }
+
+ // if not OAuth then defaults to
GoogleCredentials.getApplicationDefault()
+ this.kmsClient =
KeyManagementServiceClient.create(kmsBuilder.build());
+ closeableGroup.addCloseable(kmsClient);
+
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to create GCP cloud KMS service
client", e);
Review Comment:
```suggestion
throw new RuntimeIOException("Failed to create GCP cloud KMS
service client", e);
```
(nit, unrelated to this PR's changes)
--
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]