@@ -110,19 +110,16 @@ public static String getPattern(String topic) {
110
110
return "^" + Pattern .quote (get (topic ).getPartitionedTopicName ().toString ()) + "$" ;
111
111
}
112
112
113
- private TopicName (String completeTopicName ) {
114
- this (completeTopicName , true );
115
- }
116
-
117
113
/**
118
- * The constructor from a topic name string. You can leverage {@link TopicName#get(String)} to get benefits from
119
- * the built-in cache mechanism.
114
+ * The constructor from a topic name string. The difference from {@link TopicName#get(String)} is that the `get`
115
+ * method can leverage the built-in cache mechanism, which can be slightly faster, but at the cost of higher JVM
116
+ * memory usage that could lead to unnecessary GC, as well as potentially OOM in extreme cases.
117
+ * You can benchmark `TopicName.get(topic)` and `new TopicName(topic)` to see the actual performance gap.
120
118
*
121
119
* @param completeTopicName the topic name
122
- * @param initializeNamespaceName whether to initializing the internal {@link NamespaceName} field
123
120
*/
124
121
@ SuppressFBWarnings ("DCN_NULLPOINTER_EXCEPTION" )
125
- public TopicName (String completeTopicName , boolean initializeNamespaceName ) {
122
+ public TopicName (String completeTopicName ) {
126
123
try {
127
124
// The topic name can be in two different forms, one is fully qualified topic name,
128
125
// the other one is short topic name
@@ -179,10 +176,6 @@ public TopicName(String completeTopicName, boolean initializeNamespaceName) {
179
176
this .domain = TopicDomain .getEnum (completeTopicName .substring (0 , index ));
180
177
}
181
178
182
- if (initializeNamespaceName ) {
183
- getNamespaceObject ();
184
- }
185
-
186
179
if (StringUtils .isBlank (localName )) {
187
180
throw new IllegalArgumentException (String .format ("Invalid topic name: %s. Topic local name must not"
188
181
+ " be blank." , completeTopicName ));
0 commit comments