rdblue commented on code in PR #7487:
URL: https://github.com/apache/iceberg/pull/7487#discussion_r1183887950


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -300,15 +300,13 @@ public Table loadTable(SessionContext context, 
TableIdentifier identifier) {
       response = loadInternal(context, identifier, snapshotMode);
       loadedIdent = identifier;
       metadataType = null;
-
     } catch (NoSuchTableException original) {
       metadataType = MetadataTableType.from(identifier.name());
       if (metadataType != null) {
         // attempt to load a metadata table using the identifier's namespace 
as the base table
-        TableIdentifier baseIdent = 
TableIdentifier.of(identifier.namespace().levels());
+        loadedIdent = TableIdentifier.of(identifier.namespace().levels());

Review Comment:
   I don't agree with this change.
   
   While this is technically correct, it makes the code more brittle. The 
purpose of not initializing `loadedIdent` is to ensure that we set it correctly 
in this fairly complex code path (two try/catch, with an if). If we don't set 
it in any path, then there is a compiler error, `Variable 'loadedIdent' might 
not have been initialized`.
   
   By setting this before we know the load succeeded, we're breaking that check 
if this code is updated in the future to handle more cases.



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