eric-maynard commented on code in PR #1942:
URL: https://github.com/apache/polaris/pull/1942#discussion_r2175814145


##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/DatasourceOperations.java:
##########
@@ -80,16 +81,13 @@ DatabaseType getDatabaseType() {
    * @param scriptFilePath : Path of SQL script.
    * @throws SQLException : Exception while executing the script.
    */
-  public void executeScript(String scriptFilePath) throws SQLException {
-    ClassLoader classLoader = DatasourceOperations.class.getClassLoader();
+  public void executeScript(InputStream scriptInputStream) throws SQLException 
{
     runWithinTransaction(
         connection -> {
           try (Statement statement = connection.createStatement()) {
             BufferedReader reader =
                 new BufferedReader(
-                    new InputStreamReader(
-                        
Objects.requireNonNull(classLoader.getResourceAsStream(scriptFilePath)),
-                        UTF_8));
+                    new 
InputStreamReader(Objects.requireNonNull(scriptInputStream), UTF_8));

Review Comment:
   Oops sorry mixed up the threads.
   
   They don't really _need_ to be closed, but it's definitely a good idea to 
close them like the code now does.



##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/DatasourceOperations.java:
##########
@@ -80,16 +81,13 @@ DatabaseType getDatabaseType() {
    * @param scriptFilePath : Path of SQL script.
    * @throws SQLException : Exception while executing the script.
    */
-  public void executeScript(String scriptFilePath) throws SQLException {
-    ClassLoader classLoader = DatasourceOperations.class.getClassLoader();
+  public void executeScript(InputStream scriptInputStream) throws SQLException 
{
     runWithinTransaction(
         connection -> {
           try (Statement statement = connection.createStatement()) {
             BufferedReader reader =
                 new BufferedReader(
-                    new InputStreamReader(
-                        
Objects.requireNonNull(classLoader.getResourceAsStream(scriptFilePath)),
-                        UTF_8));
+                    new 
InputStreamReader(Objects.requireNonNull(scriptInputStream), UTF_8));

Review Comment:
   That sounds like a good idea... is this [the one from 
jsr305](https://www.javadoc.io/static/com.google.code.findbugs/jsr305/3.0.2/javax/annotation/WillClose.html)?
 It doesn't seem that we have that dependency currently, and we're not using it 
anywhere else in the project.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to