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
SONAR-9082 SONAR-9062 H2 and ES must use the correct network interface #1912
Conversation
1d68657
to
7053ab1
Compare
@@ -110,7 +111,7 @@ Provider resolveProviderAndEnforceNonnullJdbcUrl(Props props) { | |||
} | |||
|
|||
private static String buildH2JdbcUrl(int embeddedDatabasePort) { | |||
return "jdbc:h2:tcp://localhost:" + embeddedDatabasePort + "/sonar"; | |||
return "jdbc:h2:tcp://" + InetAddress.getLoopbackAddress().getHostAddress() + ":" + embeddedDatabasePort + "/sonar"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small note here, with IPv6 is requiring the host to be separated with bracket (because : is used in IPv6 address)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact no, I won't add a dependency on guava for that. However I will fix the issue.
assertThat(System2.INSTANCE.isOsWindows()).isEqualTo(SystemUtils.IS_OS_WINDOWS); | ||
} | ||
|
||
@Test | ||
public void testIsJavaAtLeast17() throws Exception { | ||
public void testIsJavaAtLeast17() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question here: since SonarQube is now using Java8 and that classes won't be loaded by Java 7 or Java 6, does this test shouldn't be dropped ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, let's deprecate this method and return always true.
Connector connector = newConnector(props, HTTP_PROTOCOL, "http"); | ||
Connector connector = new Connector(HTTP_PROTOCOL); | ||
connector.setURIEncoding("UTF-8"); | ||
connector.setProperty("address", props.value("sonar.web.host", "0.0.0.0")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are supposing that we are using IPv4, not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default value, as commented in sonar.properties. Users can use IPv6 host.
|
||
import static java.lang.String.format; | ||
import static java.util.Collections.list; | ||
import static org.apache.commons.lang.StringUtils.isBlank; | ||
|
||
public final class NetworkUtils { | ||
|
||
private static final RandomPortFinder RANDOM_PORT_FINDER = new RandomPortFinder(); | ||
private static final Set<Integer> ALREADY_ALLOCATED = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set will fill during all the tests in the same JVM so even if a port is available we won't be able to find an available port if the method is called more than ~64512 not a big deal for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact. I will complete the javadoc.
…n resolving sonar.search.port=0
7053ab1
to
a6ca4c7
Compare
*/ | ||
@Deprecated | ||
public boolean isJavaAtLeast17() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it always returns true. Java 6 is not supported at runtime.
a6ca4c7
to
41ff386
Compare
SONAR-9082 H2 must bind to localhost interface only
SONAR-9062 ES must bind to the interface defined by property "sonar.search.host"
when "sonar.search.port" has value "0"