aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-01-17 21:14:24 +0100
committerRoel Spilker <r.spilker@gmail.com>2014-01-17 21:14:24 +0100
commit477a5341c1ca8f3037a921dd1c05addc74e5a5a3 (patch)
tree414c9fb841de11bf7d9fe80014d2508df0b89903 /src/core/lombok/eclipse
parentfee535eae94557287c1762edd32374ddfc311367 (diff)
downloadlombok-477a5341c1ca8f3037a921dd1c05addc74e5a5a3.tar.gz
lombok-477a5341c1ca8f3037a921dd1c05addc74e5a5a3.tar.bz2
lombok-477a5341c1ca8f3037a921dd1c05addc74e5a5a3.zip
Close the outputstream if it is a file after printing the AST
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/HandlePrintAST.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandlePrintAST.java b/src/core/lombok/eclipse/handlers/HandlePrintAST.java
index da6fa2a2..65cda98a 100644
--- a/src/core/lombok/eclipse/handlers/HandlePrintAST.java
+++ b/src/core/lombok/eclipse/handlers/HandlePrintAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2012 The Project Lombok Authors.
+ * Copyright (C) 2009-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -52,7 +52,16 @@ public class HandlePrintAST extends EclipseAnnotationHandler<PrintAST> {
} catch (FileNotFoundException e) {
Lombok.sneakyThrow(e);
}
-
- annotationNode.up().traverse(new EclipseASTVisitor.Printer(annotation.getInstance().printContent(), stream, annotation.getInstance().printPositions()));
+ try {
+ annotationNode.up().traverse(new EclipseASTVisitor.Printer(annotation.getInstance().printContent(), stream, annotation.getInstance().printPositions()));
+ } finally {
+ if (stream != System.out) {
+ try {
+ stream.close();
+ } catch (Exception e) {
+ Lombok.sneakyThrow(e);
+ }
+ }
+ }
}
-}
+} \ No newline at end of file