massakam commented on a change in pull request #10790:
URL: https://github.com/apache/pulsar/pull/10790#discussion_r644540164
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4035,4 +4035,126 @@ protected void internalTruncateTopic(AsyncResponse
asyncResponse, boolean author
});
}
}
+
+ protected void internalSetReplicatedSubscriptionStatus(AsyncResponse
asyncResponse, String subName,
+ boolean authoritative, Boolean enabled) {
+ log.info("[{}] Attempting to change replicated subscription status to
{} - {} {}", clientAppId(), enabled,
+ topicName, subName);
+
+ if (enabled == null) {
Review comment:
If boolean is used instead of Boolean, it seems that an error response
will be returned unless the request body can be cast to boolean type.
```sh
$ curl -i -X POST -d '' -H 'Content-Type: application/json'
http://localhost:8080/admin/v2/persistent/public/default/massakam/subscription/sub1/replicatedSubscriptionStatus
HTTP/1.1 400 Bad Request
Date: Thu, 03 Jun 2021 06:56:00 GMT
broker-address: localhost
Content-Type: application/json
Content-Length: 35
Server: Jetty(9.4.39.v20210325)
The request entity cannot be empty.
$ curl -i -X POST -d '"foo"' -H 'Content-Type: application/json'
http://localhost:8080/admin/v2/persistent/public/default/massakam/subscription/sub1/replicatedSubscriptionStatus
HTTP/1.1 400 Bad Request
Date: Thu, 03 Jun 2021 07:01:15 GMT
broker-address: localhost
Content-Type: text/plain
Content-Length: 248
Server: Jetty(9.4.39.v20210325)
Cannot deserialize value of type `boolean` from String "foo": only
"true"/"True"/"TRUE" or "false"/"False"/"FALSE" recognized
at [Source:
(org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream);
line: 1, column: 1]
$ curl -i -X POST -d 0 -H 'Content-Type: application/json'
http://localhost:8080/admin/v2/persistent/public/default/massakam/subscription/sub1/replicatedSubscriptionStatus
HTTP/1.1 204 No Content
Date: Thu, 03 Jun 2021 06:56:21 GMT
broker-address: localhost
Server: Jetty(9.4.39.v20210325)
$ curl -i -X POST -d 1 -H 'Content-Type: application/json'
http://localhost:8080/admin/v2/persistent/public/default/massakam/subscription/sub1/replicatedSubscriptionStatus
HTTP/1.1 204 No Content
Date: Thu, 03 Jun 2021 06:56:34 GMT
broker-address: localhost
Server: Jetty(9.4.39.v20210325)
```
Since this behavior is not a problem, I changed the type of `enabled` to
boolean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]