-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Test Hive: Fix TestHiveMetastore #12140
base: main
Are you sure you want to change the base?
Conversation
SystemClassLoader swap to getClassLoader add try-resources for connection in derby db
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.
LGTM
@@ -273,13 +274,13 @@ private void initConf(HiveConf conf, int port) { | |||
} | |||
|
|||
private static void setupMetastoreDB(String dbURL) throws SQLException, IOException { | |||
Connection connection = DriverManager.getConnection(dbURL); | |||
ScriptRunner scriptRunner = new ScriptRunner(connection, true, true); | |||
try (Connection connection = DriverManager.getConnection(dbURL)) { |
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.
I think we should still fail if this doesn't work, so Try with resources is good but we should rethrow after closing
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.
NVM I didn't read the standard enough. Looks like we should still rethrow
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.
@pvary Just for a second look on this from a hive expert
@2MD, please run |
InputStream inputStream = classLoader.getResourceAsStream("hive-schema-3.1.0.derby.sql"); | ||
try (Reader reader = new InputStreamReader(inputStream)) { | ||
scriptRunner.runScript(reader); | ||
InputStream inputStream = TestHiveMetastore.class.getClassLoader().getResourceAsStream("hive-schema-3.1.0.derby.sql"); |
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.
please wrap this also in a try-with-resources block
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.
LGTM once the input stream has been also wrapped in a try-with-resources block
Fix #12131
SystemClassLoader swap to getClassLoader
add try-resources for connection in derby db