Skip to content

Commit

Permalink
Merge #4459
Browse files Browse the repository at this point in the history
4459: fix(clients/java): parse USE_PLAINTEXT_CONNECTION as boolean r=saig0 a=pihme

## Description

Changes behavior of `USE_PLAINTEXT_CONNECTION` flag; If it is explicitly set to `false`, it won't be applied.

## Related issues

closes #4245

#

Co-authored-by: pihme <pihme@users.noreply.github.com>
  • Loading branch information
zeebe-bors[bot] and pihme committed May 11, 2020
2 parents b61b727 + f037e03 commit 53af478
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ public ZeebeClientBuilder withProperties(final Properties properties) {
Duration.ofMillis(Long.parseLong(properties.getProperty(DEFAULT_REQUEST_TIMEOUT))));
}
if (properties.containsKey(USE_PLAINTEXT_CONNECTION)) {
usePlaintext();
/**
* The following condition is phrased in this particular way in order to be backwards
* compatible with older versions of the software. In older versions the content of the
* property was not interpreted. It was assumed to be true, whenever it was set. Because of
* that, code examples in this code base set the flag to an empty string. By phrasing the
* condition this way, the old code will still work with this new implementation. Only if
* somebody deliberately sets the flag to false, the behavior will change
*/
if (!"false".equalsIgnoreCase(properties.getProperty(USE_PLAINTEXT_CONNECTION))) {
usePlaintext();
}
}
if (properties.containsKey(CA_CERTIFICATE_PATH)) {
caCertificatePath(properties.getProperty(CA_CERTIFICATE_PATH));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void shouldOverridePropertyWithEnvVariable() {
// given
Environment.system().put(PLAINTEXT_CONNECTION_VAR, "false");
final Properties properties = new Properties();
properties.putIfAbsent(USE_PLAINTEXT_CONNECTION, "");
properties.putIfAbsent(USE_PLAINTEXT_CONNECTION, "true");
final ZeebeClientBuilderImpl builder = new ZeebeClientBuilderImpl();
builder.withProperties(properties);

Expand Down
2 changes: 1 addition & 1 deletion test/src/main/java/io/zeebe/test/ZeebeTestRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ZeebeTestRule(
properties.setProperty(
ClientProperties.BROKER_CONTACTPOINT,
SocketUtil.toHostAndPortString(brokerRule.getGatewayAddress()));
properties.putIfAbsent(ClientProperties.USE_PLAINTEXT_CONNECTION, "");
properties.putIfAbsent(ClientProperties.USE_PLAINTEXT_CONNECTION, "true");

return properties;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private Properties newClientProperties() {
ClientProperties.BROKER_CONTACTPOINT,
SocketUtil.toHostAndPortString(
getBrokerConfig().getGateway().getNetwork().toSocketAddress()));
properties.put(ClientProperties.USE_PLAINTEXT_CONNECTION, "");
properties.put(ClientProperties.USE_PLAINTEXT_CONNECTION, "true");

return properties;
}
Expand Down

0 comments on commit 53af478

Please sign in to comment.