This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 5364219335 fix: trigger refresh for discovery upstream data
subscribers when data is empty and add unit test (#6957)
5364219335 is described below
commit 53642193351fd505bdea551284f2c5e157f417dc
Author: Limbo <[email protected]>
AuthorDate: Sun Aug 23 15:54:23 2026 +0800
fix: trigger refresh for discovery upstream data subscribers when data is
empty and add unit test (#6957)
Co-authored-by: aias00 <[email protected]>
---
.../http/refresh/DiscoveryUpstreamDataRefresh.java | 3 +-
.../refresh/DiscoveryUpstreamDataRefreshTest.java | 39 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefresh.java
b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefresh.java
index 3ee22a1fc0..6887412461 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefresh.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefresh.java
@@ -54,7 +54,8 @@ public class DiscoveryUpstreamDataRefresh extends
AbstractDataRefresh<DiscoveryS
@Override
protected void refresh(final List<DiscoverySyncData> data) {
if (CollectionUtils.isEmpty(data)) {
- LOG.info("clear all plugin data cache");
+ LOG.info("clear all discovery upstream data cache");
+
discoveryUpstreamDataSubscribers.forEach(DiscoveryUpstreamDataSubscriber::refresh);
return;
}
data.forEach(d -> discoveryUpstreamDataSubscribers.forEach(dus ->
dus.onSubscribe(d)));
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-http/src/test/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefreshTest.java
b/shenyu-sync-data-center/shenyu-sync-data-http/src/test/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefreshTest.java
new file mode 100644
index 0000000000..a58bd4605e
--- /dev/null
+++
b/shenyu-sync-data-center/shenyu-sync-data-http/src/test/java/org/apache/shenyu/sync/data/http/refresh/DiscoveryUpstreamDataRefreshTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.shenyu.sync.data.http.refresh;
+
+import org.apache.shenyu.sync.data.api.DiscoveryUpstreamDataSubscriber;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public final class DiscoveryUpstreamDataRefreshTest {
+
+ @Test
+ public void testRefreshWithEmptyData() {
+ DiscoveryUpstreamDataSubscriber subscriber =
mock(DiscoveryUpstreamDataSubscriber.class);
+ DiscoveryUpstreamDataRefresh dataRefresh = new
DiscoveryUpstreamDataRefresh(Collections.singletonList(subscriber));
+
+ dataRefresh.refresh(Collections.emptyList());
+
+ verify(subscriber).refresh();
+ }
+}