Sanitize the app id before creating app id metric
Author: Jakub Scholz
Reviewers: Randall Hauch Ewen Cheslack-Postava
Closes from scholzj/KAFKA-6008
@@ -28,6 +28,7 @@ import org.apache.kafka.common.MetricName;
import org.apache.kafka.common.metrics.Gauge;
import org.apache.kafka.common.metrics.MetricConfig;
import org.apache.kafka.common.metrics.Metrics;
+import org.apache.kafka.common.metrics.Sanitizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +58,7 @@ public class AppInfoParser {
public static synchronized void registerAppInfo(String prefix, String id, Metrics metrics) {
try {
- ObjectName name = new ObjectName(prefix + ":type=app-info,id=" + id);
+ ObjectName name = new ObjectName(prefix + ":type=app-info,id=" + Sanitizer.sanitize(id));
AppInfo mBean = new AppInfo();
ManagementFactory.getPlatformMBeanServer().registerMBean(mBean, name);
