diff --git a/src/main/java/org/apache/ibatis/migration/MigrationReader.java b/src/main/java/org/apache/ibatis/migration/MigrationReader.java index 76260dde..c803f849 100644 --- a/src/main/java/org/apache/ibatis/migration/MigrationReader.java +++ b/src/main/java/org/apache/ibatis/migration/MigrationReader.java @@ -95,7 +95,7 @@ public int read(char[] cbuf, int off, int len) throws IOException { while (buffer.length() == 0) { int result = in.read(cbuf, off, len); if (result == -1) { - if (lineBuffer.length() > 0 && !undo && !inUndo) { + if (lineBuffer.length() > 0 && (!undo || inUndo)) { buffer.append(lineBuffer).append(lineSeparator); lineBuffer.setLength(0); } diff --git a/src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java b/src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java index 985f5fba..2025f2ee 100644 --- a/src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java +++ b/src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java @@ -72,6 +72,19 @@ public void shouldReturnUndoPart() throws Exception { // @formatter:on } + @Test + public void shouldReturnUndoPart_NoEndBreak() throws Exception { + // @formatter:off + String script = "-- comment\n" + + "do part\n" + + "--//@UNDO\n" + + "undo part"; + String result = readAsString(new MigrationReader(strToInputStream(script, charset), charset, true, null)); + assertEquals("-- @UNDO\n" + + "undo part\n", result); + // @formatter:on + } + @Test public void shouldUndoCommentBeLenient() throws Exception { // @formatter:off