Skip to content

Commit c493310

Browse files
committed
Fix AvaticaSpnegoTest for canonicalHostName("localhost") != "localhost"
Avatica HTTP client always uses CANONICAL_HOSTNAME which confuses test code.
1 parent 22a8f7f commit c493310

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ allprojects {
329329
exceptionFormat = TestExceptionFormat.FULL
330330
showStandardStreams = true
331331
}
332+
// Pass the property to tests
333+
fun passProperty(name: String, default: String? = null) {
334+
val value = System.getProperty(name) ?: default
335+
value?.let { systemProperty(name, it) }
336+
}
337+
passProperty("java.awt.headless")
338+
passProperty("user.language", "TR")
339+
passProperty("user.country", "tr")
340+
val props = System.getProperties()
341+
for (e in props.propertyNames() as `java.util`.Enumeration<String>) {
342+
if (e.startsWith("calcite.") || e.startsWith("avatica.")) {
343+
passProperty(e)
344+
}
345+
}
332346
}
333347
withType<SpotBugsTask>().configureEach {
334348
group = LifecycleBasePlugin.VERIFICATION_GROUP

core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientSpnegoImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public class AvaticaCommonsHttpClientSpnegoImpl extends AvaticaCommonsHttpClient
5555
public static final String CACHED_CONNECTIONS_MAX_PER_ROUTE_KEY =
5656
"avatica.http.spnego.max_per_route";
5757

58-
private static final boolean USE_CANONICAL_HOSTNAME = true;
58+
private static final boolean USE_CANONICAL_HOSTNAME =
59+
Boolean.parseBoolean(
60+
System.getProperty("avatica.http.spnego.use_canonical_hostname", "true"));
5961
private static final boolean STRIP_PORT_ON_SERVER_LOOKUP = true;
6062

6163
/**

server/src/test/java/org/apache/calcite/avatica/AvaticaSpnegoTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ private static void setupKdc() throws Exception {
7070
if (isKdcStarted) {
7171
return;
7272
}
73+
if (System.getProperty("avatica.http.spnego.use_canonical_hostname") == null) {
74+
System.setProperty("avatica.http.spnego.use_canonical_hostname", "false");
75+
}
7376
kdc = new SimpleKdcServer();
7477
File target = SpnegoTestUtil.TARGET_DIR;
7578
assertTrue(target.exists());

0 commit comments

Comments
 (0)