jesmith17 commented on code in PR #3467: URL: https://github.com/apache/logging-log4j2/pull/3467#discussion_r1958828058
########## log4j-mongodb4/src/main/java/org/apache/logging/log4j/mongodb4/MongoDb4Provider.java: ########## @@ -60,14 +61,47 @@ public static class Builder<B extends Builder<B>> extends AbstractFilterable.Bui @PluginBuilderAttribute("capped") private boolean capped = false; + @PluginBuilderAttribute("collectionName") + private String collectionName; + + @PluginBuilderAttribute("databaseName") + private String databaseName; + + + @Override public MongoDb4Provider build() { StatusLogger.getLogger().warn("The {} Appender is deprecated, use the MongoDb Appender.", PLUGIN_NAME); + + ConnectionString connectionString; + try { + connectionString = new ConnectionString(connectionStringSource); + } catch (final IllegalArgumentException e) { + LOGGER.error("Invalid MongoDB connection string `{}`.", connectionStringSource, e); + return null; + } + + String effectiveDatabaseName = databaseName != null ? databaseName : connectionString.getDatabase(); + String effectiveCollectionName = collectionName != null ? collectionName : connectionString.getCollection(); + // Validate the provided databaseName property + try { + MongoNamespace.checkDatabaseNameValidity(effectiveDatabaseName); + } catch (final IllegalArgumentException e) { + LOGGER.error("Invalid MongoDB database name `{}`.", effectiveDatabaseName, e); + return null; + } + // Validate the provided collectionName property + try { + MongoNamespace.checkCollectionNameValidity(effectiveCollectionName); + } catch (final IllegalArgumentException e) { + LOGGER.error("Invalid MongoDB collection name `{}`.", effectiveCollectionName, e); + return null; + } Review Comment: When I made these changes to the main branch, was specifically asked to make them to the build method. So making these change in this format keep the approach in line with the same code changes in the main branch. It seems odd to want to solve the same challenge in 2 different ways across the branches. -- 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: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org