diff options
author | Roel Spilker <r.spilker@gmail.com> | 2015-01-13 16:26:41 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-01-20 22:35:38 +0100 |
commit | e97e0cc23eca1b34d657f382d123ce2298ceb5a8 (patch) | |
tree | a6d7174670b57431daa13703472f13b4be1643d3 /src | |
parent | 091f6ee83a98ea2a303164380aeeac093ceb8e47 (diff) | |
download | lombok-e97e0cc23eca1b34d657f382d123ce2298ceb5a8.tar.gz lombok-e97e0cc23eca1b34d657f382d123ce2298ceb5a8.tar.bz2 lombok-e97e0cc23eca1b34d657f382d123ce2298ceb5a8.zip |
Bug fix in postcompiler app which seemed to not correctly identify changes.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/bytecode/PostCompilerApp.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/lombok/bytecode/PostCompilerApp.java b/src/core/lombok/bytecode/PostCompilerApp.java index d2c3157c..5f49bd81 100644 --- a/src/core/lombok/bytecode/PostCompilerApp.java +++ b/src/core/lombok/bytecode/PostCompilerApp.java @@ -98,7 +98,7 @@ public class PostCompilerApp extends LombokApp { byte[] original = readFile(file); byte[] clone = original.clone(); byte[] transformed = PostCompiler.applyTransformations(clone, file.toString(), DiagnosticsReceiver.CONSOLE); - if (clone != transformed && !Arrays.equals(clone, transformed)) { + if (clone != transformed && !Arrays.equals(original, transformed)) { filesTouched++; if (args.verbose) System.out.println("Rewriting " + file.getAbsolutePath()); writeFile(file, transformed); @@ -138,18 +138,24 @@ public class PostCompilerApp extends LombokApp { byte[] buffer = new byte[1024]; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); FileInputStream fileInputStream = new FileInputStream(file); - while (true) { - int read = fileInputStream.read(buffer); - if (read == -1) break; - bytes.write(buffer, 0, read); + try { + while (true) { + int read = fileInputStream.read(buffer); + if (read == -1) break; + bytes.write(buffer, 0, read); + } + } finally { + fileInputStream.close(); } - fileInputStream.close(); return bytes.toByteArray(); } static void writeFile(File file, byte[] transformed) throws IOException { FileOutputStream out = new FileOutputStream(file); - out.write(transformed); - out.close(); + try { + out.write(transformed); + } finally { + out.close(); + } } } |