Skip to content

Commit 3b87559

Browse files
committed
Configurations: Minor cleanups
1 parent 4141621 commit 3b87559

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/main/java/com/mongodb/kafka/connect/sink/MongoSinkConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848

4949
public class MongoSinkConfig extends AbstractConfig {
5050

51+
private static final String EMPTY_STRING = "";
5152
public static final String TOPICS_CONFIG = MongoSinkConnector.TOPICS_CONFIG;
5253
private static final String TOPICS_DOC =
5354
"A list of kafka topics for the sink connector, separated by commas";
54-
public static final String TOPICS_DEFAULT = "";
55+
public static final String TOPICS_DEFAULT = EMPTY_STRING;
5556
private static final String TOPICS_DISPLAY = "The Kafka topics";
5657

5758
public static final String TOPICS_REGEX_CONFIG = "topics.regex";
@@ -63,7 +64,7 @@ public class MongoSinkConfig extends AbstractConfig {
6364
+ " or "
6465
+ TOPICS_REGEX_CONFIG
6566
+ " should be specified.";
66-
public static final String TOPICS_REGEX_DEFAULT = "";
67+
public static final String TOPICS_REGEX_DEFAULT = EMPTY_STRING;
6768
private static final String TOPICS_REGEX_DISPLAY = "Topics regex";
6869

6970
public static final String CONNECTION_URI_CONFIG = "connection.uri";
@@ -74,7 +75,7 @@ public class MongoSinkConfig extends AbstractConfig {
7475
+ "eg: ``mongodb://user@pass@locahost/``.";
7576

7677
public static final String TOPIC_OVERRIDE_CONFIG = "topic.override.%s.%s";
77-
private static final String TOPIC_OVERRIDE_DEFAULT = "";
78+
private static final String TOPIC_OVERRIDE_DEFAULT = EMPTY_STRING;
7879
private static final String TOPIC_OVERRIDE_DISPLAY = "Per topic configuration overrides.";
7980
public static final String TOPIC_OVERRIDE_DOC =
8081
"The overrides configuration allows for per topic customization of configuration. "

src/main/java/com/mongodb/kafka/connect/source/MongoSourceConfig.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
public class MongoSourceConfig extends AbstractConfig {
6161

62+
private static final String EMPTY_STRING = "";
6263
private static final Pattern CLASS_NAME =
6364
Pattern.compile("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*");
6465
private static final Pattern FULLY_QUALIFIED_CLASS_NAME =
@@ -142,14 +143,14 @@ public class MongoSourceConfig extends AbstractConfig {
142143
"Prefix to prepend to database & collection names to generate the name of the Kafka "
143144
+ "topic to publish data to. Used by the 'DefaultTopicMapper'.";
144145
private static final String TOPIC_PREFIX_DISPLAY = "Topic Prefix";
145-
private static final String TOPIC_PREFIX_DEFAULT = "";
146+
private static final String TOPIC_PREFIX_DEFAULT = EMPTY_STRING;
146147

147148
public static final String TOPIC_SUFFIX_CONFIG = "topic.suffix";
148149
private static final String TOPIC_SUFFIX_DOC =
149150
"Suffix to append to database & collection names to generate the name of the Kafka "
150151
+ "topic to publish data to. Used by the 'DefaultTopicMapper'.";
151152
private static final String TOPIC_SUFFIX_DISPLAY = "Topic Suffix";
152-
private static final String TOPIC_SUFFIX_DEFAULT = "";
153+
private static final String TOPIC_SUFFIX_DEFAULT = EMPTY_STRING;
153154

154155
public static final String TOPIC_NAMESPACE_MAP_CONFIG = "topic.namespace.map";
155156
private static final String TOPIC_NAMESPACE_MAP_DISPLAY = "The namespace to topic map";
@@ -163,7 +164,7 @@ public class MongoSourceConfig extends AbstractConfig {
163164
+ "will map all change stream documents to the `everyThingTopic` apart from the `db.coll` "
164165
+ "messages."
165166
+ "Note: Any prefix and suffix configuration will still apply.";
166-
private static final String TOPIC_NAMESPACE_MAP_DEFAULT = "";
167+
private static final String TOPIC_NAMESPACE_MAP_DEFAULT = EMPTY_STRING;
167168

168169
public static final String PIPELINE_CONFIG = "pipeline";
169170
private static final String PIPELINE_DISPLAY = "The pipeline to apply to the change stream";
@@ -192,14 +193,14 @@ public class MongoSourceConfig extends AbstractConfig {
192193
+ "When set to 'updateLookup', the change stream for partial updates will include both a delta "
193194
+ "describing the changes to the document as well as a copy of the entire document that was changed from *some time* after "
194195
+ "the change occurred.";
195-
private static final String FULL_DOCUMENT_DEFAULT = "";
196+
private static final String FULL_DOCUMENT_DEFAULT = EMPTY_STRING;
196197

197198
public static final String COLLATION_CONFIG = "collation";
198199
private static final String COLLATION_DISPLAY = "The collation options";
199200
private static final String COLLATION_DOC =
200201
"The json representation of the Collation options to use for the change stream.\n"
201202
+ "Use the `Collation.asDocument().toJson()` to create the specific json representation.";
202-
private static final String COLLATION_DEFAULT = "";
203+
private static final String COLLATION_DEFAULT = EMPTY_STRING;
203204

204205
public static final String POLL_MAX_BATCH_SIZE_CONFIG = "poll.max.batch.size";
205206
private static final String POLL_MAX_BATCH_SIZE_DISPLAY = "The maximum batch size";
@@ -218,14 +219,14 @@ public class MongoSourceConfig extends AbstractConfig {
218219
private static final String DATABASE_DISPLAY = "The database to watch.";
219220
private static final String DATABASE_DOC =
220221
"The database to watch. If not set then all databases will be watched.";
221-
private static final String DATABASE_DEFAULT = "";
222+
private static final String DATABASE_DEFAULT = EMPTY_STRING;
222223

223224
public static final String COLLECTION_CONFIG = "collection";
224225
private static final String COLLECTION_DISPLAY = "The collection to watch.";
225226
private static final String COLLECTION_DOC =
226227
"The collection in the database to watch. If not set then all collections will be "
227228
+ "watched.";
228-
private static final String COLLECTION_DEFAULT = "";
229+
private static final String COLLECTION_DEFAULT = EMPTY_STRING;
229230

230231
public static final String COPY_EXISTING_CONFIG = "copy.existing";
231232
private static final String COPY_EXISTING_DISPLAY = "Copy existing data";
@@ -260,7 +261,7 @@ public class MongoSourceConfig extends AbstractConfig {
260261
+ "This can improve the use of indexes by the copying manager and make copying more efficient.\n"
261262
+ "Use if there is any filtering of collection data in the `pipeline` configuration to speed up the copying process.\n"
262263
+ "Example: `[{\"$match\": {\"closed\": \"false\"}}]`";
263-
private static final String COPY_EXISTING_PIPELINE_DEFAULT = "";
264+
private static final String COPY_EXISTING_PIPELINE_DEFAULT = EMPTY_STRING;
264265

265266
public static final String COPY_EXISTING_NAMESPACE_REGEX_CONFIG = "copy.existing.namespace.regex";
266267
private static final String COPY_EXISTING_NAMESPACE_REGEX_DISPLAY =
@@ -270,7 +271,7 @@ public class MongoSourceConfig extends AbstractConfig {
270271
+ " A namespace is the database name and collection separated by a period e.g. `database.collection`.\n"
271272
+ " Example: The following regular expression will only include collections starting with `a` "
272273
+ "in the `demo` database: `demo\\.a.*`";
273-
private static final String COPY_EXISTING_NAMESPACE_REGEX_DEFAULT = "";
274+
private static final String COPY_EXISTING_NAMESPACE_REGEX_DEFAULT = EMPTY_STRING;
274275

275276
public static final String ERRORS_TOLERANCE_CONFIG = "errors.tolerance";
276277
public static final String ERRORS_TOLERANCE_DISPLAY = "Error Tolerance";
@@ -299,7 +300,7 @@ public class MongoSourceConfig extends AbstractConfig {
299300
"errors.deadletterqueue.topic.name";
300301
public static final String ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_DISPLAY =
301302
"Output errors to the dead letter queue";
302-
public static final String ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_DEFAULT = "";
303+
public static final String ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_DEFAULT = EMPTY_STRING;
303304
public static final String ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_DOC =
304305
"Whether to output conversion errors to the dead letter queue. "
305306
+ "Stops poison messages when using schemas, any message will be outputted as extended json on the specified topic. "
@@ -330,7 +331,7 @@ public class MongoSourceConfig extends AbstractConfig {
330331

331332
public static final String OFFSET_PARTITION_NAME_CONFIG = "offset.partition.name";
332333
public static final String OFFSET_PARTITION_NAME_DISPLAY = "Offset partition name";
333-
public static final String OFFSET_PARTITION_NAME_DEFAULT = "";
334+
public static final String OFFSET_PARTITION_NAME_DEFAULT = EMPTY_STRING;
334335
public static final String OFFSET_PARTITION_NAME_DOC =
335336
"Use a custom offset partition name. If blank the default partition name based on the "
336337
+ "connection details will be used.";

0 commit comments

Comments
 (0)