Skip to content
Open
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 @@ -85,9 +85,9 @@ public JsonAsyncHttpPinotClientTransportFactory withConnectionProperties(Propert
_headers = ConnectionUtils.getHeadersFromProperties(properties);
}

String scheme = properties.getProperty("scheme", CommonConstants.HTTP_PROTOCOL);
if (_scheme == null || !_scheme.contentEquals(scheme)) {
_scheme = scheme;
_scheme = properties.getProperty("scheme", _scheme);
if (_scheme == null) {
_scheme = CommonConstants.HTTP_PROTOCOL;
}

if (_sslContext == null && _scheme.contentEquals(CommonConstants.HTTPS_PROTOCOL)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.pinot.spi.utils.CommonConstants;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -140,6 +141,38 @@ public void serverResponseExceedsBrokerReadTimeoutThreshold() {
}
}

@Test
public void withConnectionPropertiesRetainsConfiguredSchemeWhenSchemePropertyIsAbsent() {
JsonAsyncHttpPinotClientTransportFactory factory = new JsonAsyncHttpPinotClientTransportFactory();
factory.setScheme(CommonConstants.HTTPS_PROTOCOL);

factory.withConnectionProperties(new Properties());

assertEquals(factory.getScheme(), CommonConstants.HTTPS_PROTOCOL);
}

@Test
public void withConnectionPropertiesOverridesConfiguredSchemeWhenSchemePropertyIsPresent() {
JsonAsyncHttpPinotClientTransportFactory factory = new JsonAsyncHttpPinotClientTransportFactory();
factory.setScheme(CommonConstants.HTTP_PROTOCOL);
Properties connectionProps = new Properties();
connectionProps.setProperty("scheme", CommonConstants.HTTPS_PROTOCOL);

factory.withConnectionProperties(connectionProps);

assertEquals(factory.getScheme(), CommonConstants.HTTPS_PROTOCOL);
}

@Test
public void withConnectionPropertiesFallsBackToHttpWhenConfiguredSchemeIsNull() {
JsonAsyncHttpPinotClientTransportFactory factory = new JsonAsyncHttpPinotClientTransportFactory();
factory.setScheme(null);

factory.withConnectionProperties(new Properties());

assertEquals(factory.getScheme(), CommonConstants.HTTP_PROTOCOL);
}

// Cursor-related tests
@Test
public void testExecuteQueryWithCursor() {
Expand Down
Loading