justinmclean opened a new issue, #8057:
URL: https://github.com/apache/gravitino/issues/8057

   ### What would you like to be improved?
   
   This line contains incorrect logic:
   ```
   if (!properties.containsKey(key) && properties.get(key) != null) {
   ```
   
   Here are some unit tests to show that:
   ```
     @Test
     void testJdbcProperties() {
       Map<String, String> properties = Maps.newHashMap();
       properties.put(JdbcAuthorizationProperties.JDBC_URL, 
"jdbc:test://localhost");
       properties.put(JdbcAuthorizationProperties.JDBC_USERNAME, "user");
       properties.put(JdbcAuthorizationProperties.JDBC_PASSWORD, "pwd");
       properties.put(JdbcAuthorizationProperties.JDBC_DRIVER, "driver");
   
       JdbcAuthorizationProperties jdbcProps = new 
JdbcAuthorizationProperties(properties);
       Assertions.assertDoesNotThrow(jdbcProps::validate);
     }
   
     @Test
     void testJdbcPropertiesMissingUrl() {
       Map<String, String> properties = Maps.newHashMap();
       properties.put(JdbcAuthorizationProperties.JDBC_USERNAME, "user");
       properties.put(JdbcAuthorizationProperties.JDBC_PASSWORD, "pwd");
       properties.put(JdbcAuthorizationProperties.JDBC_DRIVER, "driver");
   
       JdbcAuthorizationProperties jdbcProps = new 
JdbcAuthorizationProperties(properties);
       Assertions.assertThrows(IllegalArgumentException.class, 
jdbcProps::validate);
     }
   
     @Test
     void testJdbcPropertiesNullUsername() {
       Map<String, String> properties = Maps.newHashMap();
       properties.put(JdbcAuthorizationProperties.JDBC_URL, 
"jdbc:test://localhost");
       properties.put(JdbcAuthorizationProperties.JDBC_USERNAME, null);
       properties.put(JdbcAuthorizationProperties.JDBC_PASSWORD, "pwd");
       properties.put(JdbcAuthorizationProperties.JDBC_DRIVER, "driver");
   
       JdbcAuthorizationProperties jdbcProps = new 
JdbcAuthorizationProperties(properties);
       Assertions.assertThrows(IllegalArgumentException.class, 
jdbcProps::validate);
     }
   ```
   
   
   ### How should we improve?
   
   Fix the logic.


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

Reply via email to