pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guangn...@apache.org
Subject [pulsar-manager] branch master updated: Fix the pulsar-manager can not process the request by pulsar proxy (#281)
Date Tue, 24 Mar 2020 05:58:23 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new b115312  Fix the pulsar-manager can not process the request by pulsar proxy (#281)
b115312 is described below

commit b115312b5b91aacdd5377da2f7c2d19b08645af4
Author: Yong Zhang <zhangyong1025.zy@gmail.com>
AuthorDate: Tue Mar 24 13:58:16 2020 +0800

    Fix the pulsar-manager can not process the request by pulsar proxy (#281)
    
    ---
    
    Fixes: #280
    
    When sending a GET request to the Pulsar proxy, the server
    always threw an IllegalArgumentException. By my test that's because
    we are setting the Content-Type for a request without the request body.
    We remove the Content-Type if the request is GET.
---
 .../java/org/apache/pulsar/manager/PulsarApplicationListener.java     | 1 -
 .../org/apache/pulsar/manager/controller/EnvironmentsController.java  | 2 --
 .../org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java    | 2 --
 .../apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java    | 4 +---
 .../org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java    | 1 -
 .../org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java   | 2 --
 .../pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java      | 1 -
 .../org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java | 3 +--
 .../org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java    | 1 -
 .../org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java     | 3 +--
 .../org/apache/pulsar/manager/service/BrokerStatsServiceImplTest.java | 2 --
 .../org/apache/pulsar/manager/service/BrokersServiceImplTest.java     | 1 -
 .../org/apache/pulsar/manager/service/ClustersServiceImplTest.java    | 2 --
 .../org/apache/pulsar/manager/service/NamespacesServiceImplTest.java  | 2 --
 .../org/apache/pulsar/manager/service/TenantsServiceImplTest.java     | 1 -
 .../java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java | 2 --
 16 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java b/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java
index ec1048f..0391718 100644
--- a/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java
+++ b/src/main/java/org/apache/pulsar/manager/PulsarApplicationListener.java
@@ -66,7 +66,6 @@ public class PulsarApplicationListener implements ApplicationListener<ContextRef
                     && defaultEnvironmentServiceUrl.length() > 0
                     && !environmentEntityOptional.isPresent()) {
                 Map<String, String> header = Maps.newHashMap();
-                header.put("Content-Type", "application/json");
                 if (StringUtils.isNotBlank(pulsarJwtToken)) {
                     header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
                 }
diff --git a/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java
b/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java
index 76a5024..017dcd3 100644
--- a/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java
+++ b/src/main/java/org/apache/pulsar/manager/controller/EnvironmentsController.java
@@ -184,7 +184,6 @@ public class EnvironmentsController {
             return ResponseEntity.ok(result);
         }
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
@@ -219,7 +218,6 @@ public class EnvironmentsController {
             return ResponseEntity.ok(result);
         }
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java
index f661c9f..836b890 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java
@@ -49,12 +49,10 @@ public class BookiesServiceImpl implements BookiesService {
     private static String pulsarJwtToken;
 
     private static final Map<String, String> header = new HashMap<String, String>(){{
-        put("Content-Type","application/json");
         put("Authorization", String.format("Bearer %s", pulsarJwtToken));
     }};
 
     private final Pattern pattern = Pattern.compile(" \\d+");;
-
     public Map<String, Object> getBookiesList(Integer pageNum, Integer pageSize, String
cluster) {
         Map<String, Object> bookiesMap = Maps.newHashMap();
         List<Map<String, Object>> bookiesArray = new ArrayList<>();
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java
index 16e1757..ca57605 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/BrokerStatsServiceImpl.java
@@ -78,9 +78,7 @@ public class BrokerStatsServiceImpl implements BrokerStatsService {
     private final ReplicationsStatsRepository replicationsStatsRepository;
     private final ConsumersStatsRepository consumersStatsRepository;
 
-    private static final Map<String, String> header = new HashMap<String, String>(){{
-        put("Content-Type","application/json");
-    }};
+    private static final Map<String, String> header = new HashMap<String, String>();
 
     @Autowired
     public BrokerStatsServiceImpl(
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java
index 46bfba7..536d428 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/BrokersServiceImpl.java
@@ -42,7 +42,6 @@ public class BrokersServiceImpl implements BrokersService {
         if (directRequestBroker) {
             Gson gson = new Gson();
             Map<String, String> header = Maps.newHashMap();
-            header.put("Content-Type", "application/json");
             if (StringUtils.isNotBlank(pulsarJwtToken)) {
                 header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
             }
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java
index 4bd06b6..0162658 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/ClustersServiceImpl.java
@@ -57,7 +57,6 @@ public class ClustersServiceImpl implements ClustersService {
         if (directRequestBroker) {
             Gson gson = new Gson();
             Map<String, String> header = Maps.newHashMap();
-            header.put("Content-Type", "application/json");
             if (StringUtils.isNotBlank(pulsarJwtToken)) {
                 header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
             }
@@ -91,7 +90,6 @@ public class ClustersServiceImpl implements ClustersService {
     public List<String> getClusterByAnyBroker(String requestHost) {
         Gson gson = new Gson();
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java
index f62dbd8..a0f4b5d 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java
@@ -105,7 +105,6 @@ public class EnvironmentCacheServiceImpl implements EnvironmentCacheService
{
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
-        header.put("Content-Type", "application/json");
         return header;
     }
 
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java
index e96517c..630b34d 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/NamespacesServiceImpl.java
@@ -63,7 +63,6 @@ public class NamespacesServiceImpl implements NamespacesService {
         if (directRequestBroker) {
             Gson gson = new Gson();
             Map<String, String> header = Maps.newHashMap();
-            header.put("Content-Type", "application/json");
             if (StringUtils.isNotBlank(pulsarJwtToken)) {
                 header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
             }
@@ -152,4 +151,4 @@ public class NamespacesServiceImpl implements NamespacesService {
         return namespaceStatsMap;
     }
 
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java
b/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java
index 2f61880..9eeeda6 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/TenantsServiceImpl.java
@@ -65,7 +65,6 @@ public class TenantsServiceImpl implements TenantsService {
         if (directRequestBroker) {
             Gson gson = new Gson();
             Map<String, String> header = Maps.newHashMap();
-            header.put("Content-Type", "application/json");
             if (StringUtils.isNotBlank(pulsarJwtToken)) {
                 header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
             }
diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java
index 9d2fb22..2503747 100644
--- a/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java
+++ b/src/main/java/org/apache/pulsar/manager/service/impl/TopicsServiceImpl.java
@@ -199,7 +199,6 @@ public class TopicsServiceImpl implements TopicsService {
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
-        header.put("Content-Type", "application/json");
         String prefix = "/admin/v2/" + persistent + "/" + tenant + "/" + namespace;
         Gson gson = new Gson();
         String partitionedUrl = requestHost + prefix + "/partitioned";
@@ -266,4 +265,4 @@ public class TopicsServiceImpl implements TopicsService {
         String topicName = tntPath.split("/")[2];
         return topicName;
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/pulsar/manager/service/BrokerStatsServiceImplTest.java
b/src/test/java/org/apache/pulsar/manager/service/BrokerStatsServiceImplTest.java
index 79d925a..2049977 100644
--- a/src/test/java/org/apache/pulsar/manager/service/BrokerStatsServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/BrokerStatsServiceImplTest.java
@@ -222,7 +222,6 @@ public class BrokerStatsServiceImplTest {
     public void convertStatsToDbTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)){
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
@@ -303,7 +302,6 @@ public class BrokerStatsServiceImplTest {
     public void findByMultiTenantOrMultiNamespace() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)){
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/test/java/org/apache/pulsar/manager/service/BrokersServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/BrokersServiceImplTest.java
index ddd17c5..eea39cb 100644
--- a/src/test/java/org/apache/pulsar/manager/service/BrokersServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/BrokersServiceImplTest.java
@@ -58,7 +58,6 @@ public class BrokersServiceImplTest {
     public void brokersServiceTest() throws Exception{
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/test/java/org/apache/pulsar/manager/service/ClustersServiceImplTest.java
b/src/test/java/org/apache/pulsar/manager/service/ClustersServiceImplTest.java
index b491629..00be004 100644
--- a/src/test/java/org/apache/pulsar/manager/service/ClustersServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/ClustersServiceImplTest.java
@@ -58,7 +58,6 @@ public class ClustersServiceImplTest {
     public void clusterServiceImplTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
@@ -87,7 +86,6 @@ public class ClustersServiceImplTest {
     public void getClusterByAnyBroker() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/test/java/org/apache/pulsar/manager/service/NamespacesServiceImplTest.java
b/src/test/java/org/apache/pulsar/manager/service/NamespacesServiceImplTest.java
index 3ba6d28..c5684bc 100644
--- a/src/test/java/org/apache/pulsar/manager/service/NamespacesServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/NamespacesServiceImplTest.java
@@ -60,7 +60,6 @@ public class NamespacesServiceImplTest {
     public void namespaceServiceImplTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
@@ -82,7 +81,6 @@ public class NamespacesServiceImplTest {
     public void getNamespaceStatsTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/test/java/org/apache/pulsar/manager/service/TenantsServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/TenantsServiceImplTest.java
index 30c25fb..ab81a7a 100644
--- a/src/test/java/org/apache/pulsar/manager/service/TenantsServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/TenantsServiceImplTest.java
@@ -63,7 +63,6 @@ public class TenantsServiceImplTest {
     public void tenantsServiceImplTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
diff --git a/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java
index b2f9385..2036b47 100644
--- a/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java
+++ b/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java
@@ -70,7 +70,6 @@ public class TopicsServiceImplTest {
     public void topicsServiceImplTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }
@@ -94,7 +93,6 @@ public class TopicsServiceImplTest {
     public void getTopicsStatsImplTest() {
         PowerMockito.mockStatic(HttpUtil.class);
         Map<String, String> header = Maps.newHashMap();
-        header.put("Content-Type", "application/json");
         if (StringUtils.isNotBlank(pulsarJwtToken)) {
             header.put("Authorization", String.format("Bearer %s", pulsarJwtToken));
         }


Mime
View raw message