developer-rohith commented on issue #4605:
URL: https://github.com/apache/gravitino/issues/4605#issuecomment-2301217193
if (!properties.containsKey(REPLICATION_FACTOR)) keep this condition in
the above else statement. Please find below updated code for reference
if (properties == null) {
resultMap = new HashMap<>();
} else {
resultMap = new HashMap<>(properties);
if (!properties.containsKey(REPLICATION_FACTOR)) {
// Try to check the number of backend servers.
String query = "select count(*) from information_schema.backends where
Alive = 'true'";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query)) {
while (resultSet.next()) {
int backendCount = resultSet.getInt(1);
if (backendCount < DEFAULT_REPLICATION_FACTOR_IN_SERVER_SIDE) {
resultMap.put(
REPLICATION_FACTOR,
DORIS_TABLE_PROPERTIES_META
.propertyEntries()
.get(REPLICATION_FACTOR)
.getDefaultValue()
.toString());
}
}
} catch (Exception e) {
throw new RuntimeException("Failed to get the number of backend
servers", e);
}
}
}
NPE issue can be resolved by doing this.
--
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]