You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2020/03/26 02:09:58 UTC
[pulsar] branch master updated: Fix function related test issue.
(#6604)
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 9c7ab70 Fix function related test issue. (#6604)
9c7ab70 is described below
commit 9c7ab70e4a2c2cd7c2eaa4eb68d617d497693077
Author: lipenghui <pe...@apache.org>
AuthorDate: Thu Mar 26 10:09:45 2020 +0800
Fix function related test issue. (#6604)
### Motivation
There are some tests that failed in the master branch related to functions. For example https://github.com/apache/pulsar/blob/master/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionE2ESecurityTest.java#L630, the test checks the properties of the message are forwarded, but we don't call `functionConfig.setForwardSourceMessageProperty(true)`, the reason is #6318 introduce `forwardSourceMessageProperty ` to enable or disable message properties forward in func [...]
And getApiException method (https://github.com/apache/pulsar/blob/master/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java#L235) is very confusing, this will cause the async function admin method that #6580 introduced can't complete when met exceptions.
BTW, I have no idea why #6318 and #6580 can pass the CI check. This test is there long ago.
---
.../pulsar/client/admin/internal/BaseResource.java | 22 ++++++++++++++--------
.../pulsar/common/functions/FunctionConfig.java | 2 +-
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
index f8efedf..a039b08 100644
--- a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
+++ b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java
@@ -194,7 +194,9 @@ public abstract class BaseResource {
}
public PulsarAdminException getApiException(Throwable e) {
- if (e instanceof ServiceUnavailableException) {
+ if (e instanceof PulsarAdminException) {
+ return (PulsarAdminException) e;
+ } else if (e instanceof ServiceUnavailableException) {
if (e.getCause() instanceof java.net.ConnectException) {
return new ConnectException(e.getCause());
} else {
@@ -232,16 +234,20 @@ public abstract class BaseResource {
}
}
- public WebApplicationException getApiException(Response response) {
+ public PulsarAdminException getApiException(Response response) {
if (response.getStatusInfo().equals(Response.Status.OK)) {
return null;
}
- if (response.getStatus() >= 500) {
- throw new ServerErrorException(response);
- } else if (response.getStatus() >= 400) {
- throw new ClientErrorException(response);
- } else {
- throw new WebApplicationException(response);
+ try {
+ if (response.getStatus() >= 500) {
+ throw new ServerErrorException(response);
+ } else if (response.getStatus() >= 400) {
+ throw new ClientErrorException(response);
+ } else {
+ throw new WebApplicationException(response);
+ }
+ } catch (Exception e) {
+ return getApiException(e);
}
}
}
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/functions/FunctionConfig.java b/pulsar-common/src/main/java/org/apache/pulsar/common/functions/FunctionConfig.java
index 4e1bfe1..d0b72ab 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/functions/FunctionConfig.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/functions/FunctionConfig.java
@@ -86,7 +86,7 @@ public class FunctionConfig {
private String logTopic;
private ProcessingGuarantees processingGuarantees;
private Boolean retainOrdering;
- private Boolean forwardSourceMessageProperty;
+ private Boolean forwardSourceMessageProperty = true;
private Map<String, Object> userConfig;
// This is a map of secretName(aka how the secret is going to be
// accessed in the function via context) to an object that