SQL: Upgrade h2 library to 1.4.197 (elastic/x-pack-elasticsearch#4251)

H2 fixed several issues related to handling timezones, which allows us
to remove hacks that we used as workarounds.

relates elastic/x-pack-elasticsearch#3169

Original commit: elastic/x-pack-elasticsearch@692c48fbd2
This commit is contained in:
Igor Motov 2018-03-29 11:10:29 -04:00 committed by GitHub
parent e69c5d4d48
commit 92207dba70
3 changed files with 2 additions and 21 deletions

View File

@ -90,7 +90,7 @@ subprojects {
testRuntime("net.sourceforge.csvjdbc:csvjdbc:1.0.34") {
transitive = false
}
testRuntime("com.h2database:h2:1.4.194") {
testRuntime("com.h2database:h2:1.4.197") {
transitive = false
}

View File

@ -132,7 +132,7 @@ public class JdbcAssert {
}
// then timestamp
else if (type == Types.TIMESTAMP || type == Types.TIMESTAMP_WITH_TIMEZONE) {
assertEquals(msg, getTime(expected, column), getTime(actual, column));
assertEquals(msg, expected.getTimestamp(column), actual.getTimestamp(column));
}
// and floats/doubles
else if (type == Types.DOUBLE) {
@ -161,7 +161,4 @@ public class JdbcAssert {
}
}
private static Object getTime(ResultSet rs, int column) throws SQLException {
return rs.getTime(column, UTC_CALENDAR).getTime();
}
}

View File

@ -8,14 +8,11 @@ package org.elasticsearch.xpack.qa.sql.jdbc;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.xpack.sql.client.shared.SuppressForbidden;
import org.junit.rules.ExternalResource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Locale;
import java.util.Properties;
public class LocalH2 extends ExternalResource implements CheckedSupplier<Connection, SQLException> {
@ -43,7 +40,6 @@ public class LocalH2 extends ExternalResource implements CheckedSupplier<Connect
private final String url;
// H2 in-memory will keep the db alive as long as this connection is opened
private Connection keepAlive;
Locale locale;
/*
* The syntax on the connection string is fairly particular:
@ -61,14 +57,7 @@ public class LocalH2 extends ExternalResource implements CheckedSupplier<Connect
}
@Override
@SuppressForbidden(reason = "H2 gets really confused with non Gregorian calendars")
protected void before() throws Throwable {
if ("japanese".equals(Calendar.getInstance().getCalendarType())) {
logger.info("Japanese calendar is detected. Overriding locale.");
locale = Locale.getDefault();
Locale.setDefault(locale.stripExtensions()); // removes the calendar setting
assert "gregory".equals(Calendar.getInstance().getCalendarType());
}
keepAlive = get();
keepAlive.createStatement().execute("RUNSCRIPT FROM 'classpath:/setup_test_emp.sql'");
}
@ -80,11 +69,6 @@ public class LocalH2 extends ExternalResource implements CheckedSupplier<Connect
} catch (SQLException ex) {
// close
}
if (locale != null) {
logger.info("Restoring locale.");
Locale.setDefault(locale);
locale = null;
}
}
@Override