Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reinstate the old KsqlRestClient.create overload #8761

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ 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
*/
@Deprecated
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