Skip to content

Commit

Permalink
fix: reinstate the old KsqlRestClient.create overload
Browse files Browse the repository at this point in the history
Commit a33b1e6
has changed the `create` method signature without
deprecating the old one first, causing the drift benchmarks
to fail with:
```
java.lang.NoSuchMethodError: io.confluent.ksql.rest.client.KsqlRestClient.create(
	java/lang/String;
	java/util/Map;
	java/util/Map;
	java/util/Optional;
)
io/confluent/ksql/rest/client/KsqlRestClient;
```
We're just adding back the missing signagure
  • Loading branch information
swist committed Feb 15, 2022
1 parent 50756e4 commit 6037136
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ public final class KsqlRestClient implements Closeable {
private List<URI> serverAddresses;
private boolean isCCloudServer;



/**
* @param serverAddress the address of the KSQL server to connect to.
* @param localProps initial set of local properties.
* @param clientProps properties used to build the client.
* @param creds optional credentials
*/
public static KsqlRestClient create(
final String serverAddress,
final Map<String, ?> localProps,
final Map<String, String> clientProps,
final Optional<BasicCredentials> creds
) {
return create(
serverAddress,
localProps,
clientProps,
creds,
Optional.empty(),
(cprops, credz, lprops) -> new KsqlClient(cprops, credz, lprops,
new HttpClientOptions(),
Optional.of(new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2)))
);
}

/**
* @param serverAddress the address of the KSQL server to connect to.
* @param localProps initial set of local properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static io.confluent.ksql.rest.client.KsqlRestClient.CCLOUD_CONNECT_USERNAME_HEADER;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -222,6 +223,18 @@ public void shouldNotIncludeAdditionalHeadersForOnPremNonConnectorRequest() thro
verify(target).postKsqlRequest("some ksql;", Collections.emptyMap(), Optional.of(0L));
}

@Test
public void shouldAllowCallingCreateWithoutNeedingACCloudApiKey() {
// This is a backwards compatibility check

final KsqlRestClient client = KsqlRestClient.create(SOME_SERVER_ADDRESS, LOCAL_PROPS, CLIENT_PROPS, Optional.empty());
assertThat(client, is(instanceOf(KsqlRestClient.class)));

// Also with new signature
final KsqlRestClient ccloudClient = KsqlRestClient.create(SOME_SERVER_ADDRESS, LOCAL_PROPS, CLIENT_PROPS, Optional.empty(), Optional.empty());
assertThat(ccloudClient, is(instanceOf(KsqlRestClient.class)));
}

private KsqlRestClient clientWithServerAddresses(final String serverAddresses) {
return clientWithServerAddresses(serverAddresses, Optional.empty());
}
Expand Down

0 comments on commit 6037136

Please sign in to comment.