Skip to content

Commit

Permalink
fix: allow trailing slash in listeners config (MINOR) (#5012)
Browse files Browse the repository at this point in the history
  • Loading branch information
agavra authored Apr 7, 2020
1 parent 588c1e9 commit 13b0455
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ public static HostInfo parseHostInfo(final String applicationServerId) {
if (applicationServerId == null || applicationServerId.trim().isEmpty()) {
return StreamsMetadataState.UNKNOWN_HOST;
}
final String host = getHost(applicationServerId);
final Integer port = getPort(applicationServerId);

final String serverId = applicationServerId.endsWith("/")
? applicationServerId.substring(0, applicationServerId.lastIndexOf("/"))
: applicationServerId;

final String host = getHost(serverId);
final Integer port = getPort(serverId);

if (host == null || port == null) {
throw new KsqlException(String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

package io.confluent.ksql.rest.server;

import static org.hamcrest.MatcherAssert.assertThat;

import io.confluent.rest.RestConfig;
import java.util.Collections;
import org.apache.kafka.common.config.ConfigException;
import org.apache.kafka.streams.state.HostInfo;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -53,4 +57,13 @@ public void shouldReturnServerAddress() {
ServerUtil.getServerAddress(restConfig);
}

@Test
public void shouldReturnServerPortWithTrailingSlash() {
// When:
final HostInfo hostInfo = ServerUtil.parseHostInfo("http://localhost:8088/");

// Then:
assertThat(hostInfo.port(), Matchers.is(8088));
}

}

0 comments on commit 13b0455

Please sign in to comment.