diff --git a/check_api/pom.xml b/check_api/pom.xml index 3f28f8ce0501..e026cb775eea 100644 --- a/check_api/pom.xml +++ b/check_api/pom.xml @@ -59,7 +59,7 @@ io.github.java-diff-utils java-diff-utils - 4.0 + 4.12 diff --git a/check_api/src/main/java/com/google/errorprone/apply/PatchFileDestination.java b/check_api/src/main/java/com/google/errorprone/apply/PatchFileDestination.java index 98b1a86bf9cd..896cea59894a 100644 --- a/check_api/src/main/java/com/google/errorprone/apply/PatchFileDestination.java +++ b/check_api/src/main/java/com/google/errorprone/apply/PatchFileDestination.java @@ -20,7 +20,6 @@ import com.github.difflib.DiffUtils; import com.github.difflib.UnifiedDiffUtils; -import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.Patch; import com.google.common.base.Joiner; import com.google.common.base.Splitter; @@ -60,12 +59,7 @@ public void writeFile(SourceFile update) throws IOException { if (!oldSource.equals(newSource)) { List originalLines = LINE_SPLITTER.splitToList(oldSource); - Patch diff = null; - try { - diff = DiffUtils.diff(originalLines, LINE_SPLITTER.splitToList(newSource)); - } catch (DiffException e) { - throw new AssertionError("DiffUtils.diff should not fail", e); - } + Patch diff = DiffUtils.diff(originalLines, LINE_SPLITTER.splitToList(newSource)); String relativePath = baseDir.relativize(sourceFilePath).toString(); List unifiedDiff = UnifiedDiffUtils.generateUnifiedDiff(relativePath, relativePath, originalLines, diff, 2);