This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new e44f36a1b2a [fix][ws] Fix issue where 
metadataStoreAllowReadOnlyOperations setting is ignored by WebSocket server 
(#25281)
e44f36a1b2a is described below

commit e44f36a1b2af49dd399c7a2ac43664be8f971f22
Author: Masahiro Sakamoto <[email protected]>
AuthorDate: Thu Mar 5 11:11:55 2026 +0900

    [fix][ws] Fix issue where metadataStoreAllowReadOnlyOperations setting is 
ignored by WebSocket server (#25281)
---
 .../service/WebSocketProxyConfiguration.java       |  3 ++
 .../pulsar/websocket/WebSocketServiceTest.java     | 50 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git 
a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
 
b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
index 31a1adc2915..f678fc40d7b 100644
--- 
a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
+++ 
b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java
@@ -75,6 +75,9 @@ public class WebSocketProxyConfiguration implements 
PulsarConfiguration {
     @FieldContext(doc = "Metadata store cache expiry time in seconds.")
     private int metadataStoreCacheExpirySeconds = 300;
 
+    @FieldContext(doc = "Is metadata store read-only operations.")
+    private boolean metadataStoreAllowReadOnlyOperations;
+
     @FieldContext(
             deprecated = true,
             doc = "ZooKeeper session timeout in milliseconds. "
diff --git 
a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketServiceTest.java
 
b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketServiceTest.java
new file mode 100644
index 00000000000..510028c3050
--- /dev/null
+++ 
b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketServiceTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.pulsar.websocket;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import java.io.InputStream;
+import java.util.Properties;
+import lombok.Cleanup;
+import org.apache.pulsar.common.configuration.PulsarConfigurationLoader;
+import org.apache.pulsar.websocket.service.WebSocketProxyConfiguration;
+import org.testng.annotations.Test;
+
+public class WebSocketServiceTest {
+
+    @Test
+    public void testMetadataStoreAllowReadOnlyOperations() throws Exception {
+        @Cleanup
+        InputStream inputStream = 
this.getClass().getClassLoader().getResourceAsStream("websocket.conf");
+        Properties properties = new Properties();
+        properties.load(inputStream);
+        properties.setProperty("authenticationEnabled", "false");
+        properties.setProperty("authorizationEnabled", "false");
+        properties.setProperty("metadataStoreAllowReadOnlyOperations", "true");
+        WebSocketProxyConfiguration config = 
PulsarConfigurationLoader.create(properties,
+                WebSocketProxyConfiguration.class);
+        @Cleanup
+        WebSocketService service = spy(new WebSocketService(config));
+        service.start();
+        verify(service).createConfigMetadataStore(eq("memory:127.0.0.1:2181"), 
eq(30000), eq(true));
+    }
+
+}

Reply via email to