From d7c4a71c1d7d61f6b98907324a9d1b0c8faccc51 Mon Sep 17 00:00:00 2001 From: wxbty Date: Mon, 11 Sep 2023 11:44:30 +0800 Subject: [PATCH] remove unuse code --- .../dubbo/metrics/event/EmptyEvent.java | 36 ------------------- .../event/SimpleMetricsEventMulticaster.java | 7 ---- .../SimpleMetricsEventMulticasterTest.java | 10 ------ 3 files changed, 53 deletions(-) delete mode 100644 dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/EmptyEvent.java diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/EmptyEvent.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/EmptyEvent.java deleted file mode 100644 index 70c9764dd37..00000000000 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/EmptyEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.dubbo.metrics.event; - -import org.apache.dubbo.rpc.model.ApplicationModel; - -/** - * EmptyEvent, do nothing. - */ -public class EmptyEvent extends MetricsEvent { - - private static final EmptyEvent empty = new EmptyEvent(null); - - private EmptyEvent(ApplicationModel source) { - super(source, null); - } - - public static EmptyEvent instance() { - return empty; - } -} diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticaster.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticaster.java index a88745ca460..ed172de6eec 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticaster.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticaster.java @@ -40,10 +40,6 @@ public void addListener(MetricsListener listener) { @Override @SuppressWarnings({"rawtypes", "unchecked"}) public void publishEvent(MetricsEvent event) { - if (event instanceof EmptyEvent) { - return; - } - if (validateIfApplicationConfigExist(event)) return; for (MetricsListener listener : listeners) { if (listener.isSupport(event)) { @@ -75,9 +71,6 @@ public void publishErrorEvent(TimeCounterEvent event) { @SuppressWarnings({"rawtypes"}) private void publishTimeEvent(MetricsEvent event, Consumer consumer) { if (validateIfApplicationConfigExist(event)) return; - if (event instanceof EmptyEvent) { - return; - } if (event instanceof TimeCounterEvent) { ((TimeCounterEvent) event).getTimePair().end(); } diff --git a/dubbo-metrics/dubbo-metrics-api/src/test/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticasterTest.java b/dubbo-metrics/dubbo-metrics-api/src/test/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticasterTest.java index 1e3b2f4c56c..ef2e1739943 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/test/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticasterTest.java +++ b/dubbo-metrics/dubbo-metrics-api/src/test/java/org/apache/dubbo/metrics/event/SimpleMetricsEventMulticasterTest.java @@ -58,16 +58,6 @@ public void onEvent(MetricsEvent event) { } - @Test - void testPublishEvent() { - - // emptyEvent do nothing - MetricsEvent emptyEvent = EmptyEvent.instance(); - eventMulticaster.publishEvent(emptyEvent); - Assertions.assertSame(obj, objects[0]); - - } - @Test void testPublishFinishEvent() {