yuqi1129 commented on PR #6853: URL: https://github.com/apache/gravitino/pull/6853#issuecomment-2785099168
> > > > > > OperationDispatcher > > > > > > > > > > > > > > > OK, let me take a look. > > > > > > > > > > > > It seems that we can't use it directly as the method `getEntity` will throw exceptions when the entity does not exist and that's not what the code in this PR intends to do. > > > > > > > > > It should be ok that the `getEntity` method don't throw the exception. You can unify them. > > > > > > <img alt="image" width="1306" src="https://private-user-images.githubusercontent.com/15794564/431178068-54580e83-85cb-4520-a9f8-205f066e742a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDQwODAwODQsIm5iZiI6MTc0NDA3OTc4NCwicGF0aCI6Ii8xNTc5NDU2NC80MzExNzgwNjgtNTQ1ODBlODMtODVjYi00NTIwLWE5ZjgtMjA1ZjA2NmU3NDJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA0MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNDA4VDAyMzYyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc4NjRiYTg2MDFlOTA4ZTlkNjM3NGUzMjAwYTk3MmIyZmRhZTYzNjQ4MjU4MGEwOTcxNDMxNzFkNGRlNThjNDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.XYzDR24XI6Ta0qYa7DR36Vqz8BRR-vC7zp5fsjAv3ZU"> > > It appears that this method is not designed to throw exceptions. do you mean I can use a flag to throw execution or not in this method? > > ```java > > protected <E extends Entity & HasIdentifier> E getEntity( > > NameIdentifier ident, Entity.EntityType type, Class<E> entityClass, bool throwExcetion) { > > try { > > return store.get(ident, type, entityClass); > > } catch (Exception e) { > > if (!throwExcetion) { > > LOG.warn(""); > > return null; > > } > > LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "get", ident, e); > > throw new RuntimeException("Fail to check if entity is existed", e); > > } > > } > > ``` > > The places calling the `getEntity` doesn't need an exception. They can accept a method `getEntity` returing null value. I mean you have assumed the return value of `getEntity` is not null, please see: https://github.com/apache/gravitino/blob/0cecdbfc8799b0abf820cf8b7735767ff307891a/core/src/main/java/org/apache/gravitino/catalog/TableOperationDispatcher.java#L235-L238 Do you mean I can change the code to the following format? ``` if (stringId != null) { tableId = stringId.id(); } else { TableEntity t = getEntity(ident, TABLE, TableEntity.class); if (t == null) { throw new RuntimeException("....") } tableId = t.id(); } ``` -- 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]
