diff --git a/hibernate-core/src/main/antlr/sql-script.g b/hibernate-core/src/main/antlr/sql-script.g index bc0e3c1ab2..5e17d62ae2 100644 --- a/hibernate-core/src/main/antlr/sql-script.g +++ b/hibernate-core/src/main/antlr/sql-script.g @@ -57,7 +57,7 @@ options { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ script - : (newLineToSkip)* (statement)+ EOF + : (newLineToSkip)* (statement)* EOF ; statement @@ -141,7 +141,7 @@ LINE_COMMENT ; /** - * Note : this comes from the great Terrance Parr (author of Antlr) - + * Note : this comes from the great Terence Parr (author of Antlr) - * * https://theantlrguy.atlassian.net/wiki/spaces/ANTLR3/pages/2687360/How+do+I+match+multi-line+comments */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java index 07329692d9..93691cb855 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportExtractorTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.StringReader; import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; @@ -58,4 +59,13 @@ public void testExtraction() throws IOException { } } } + + @Test + public void testExtractionFromEmptyScript() throws IOException { + StringReader reader = new StringReader( "" ); + final String[] commands = extractor.extractCommands( reader ); + assertThat( commands, notNullValue() ); + assertThat( commands.length, is( 0 ) ); + } + }