laserninja opened a new issue, #16034:
URL: https://github.com/apache/iceberg/issues/16034

   ### Apache Iceberg version
   
   1.10.1 (latest release)
   
   ### Query engine
   
   Other
   
   ### Please describe the bug 🐞
   
   
   In `S3FileIO` (and identically in `GCSFileIO`), `storageCredentials` is 
declared as:
   
   ```java
   private volatile List<StorageCredential> storageCredentials = 
Lists.newArrayList();
   ```
   
   The `volatile` keyword ensures visibility of the reference, but the 
underlying `ArrayList` is mutable. During a credential refresh, the list 
reference is replaced, but `clientByPrefix()` reads the field outside any 
synchronized block. A thread iterating the list for prefix matching could 
observe a partially-constructed or stale list if the JIT reorders reads.
   
   While the current pattern of replacing the entire list reference is mostly 
safe due to the volatile semantics, a more defensive approach would prevent 
subtle bugs:
   
   - Use `List.copyOf()` or `Collections.unmodifiableList()` when assigning to 
ensure the published list is immutable
   - Or use a `CopyOnWriteArrayList`
   
   ### Affected files
   
   - S3FileIO.java (line 113)
   - GCSFileIO.java (similar pattern)
   
   ### Willingness to contribute
   
   - [x] I can contribute a fix for this bug independently
   - [ ] I would be willing to contribute a fix for this bug with guidance from 
the Iceberg community
   - [ ] I cannot contribute a fix for this bug at this time


-- 
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]

Reply via email to