|
From: Christopher W. <caw...@us...> - 2005-09-15 02:19:59
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2469/src/org/rubypeople/rdt/internal/core Modified Files: RubyScript.java Log Message: close our streams properly! (d'oh I suck) Index: RubyScript.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RubyScript.java 7 Sep 2005 21:24:29 -0000 1.13 --- RubyScript.java 15 Sep 2005 02:19:50 -0000 1.14 *************** *** 29,32 **** --- 29,33 ---- import java.io.IOException; import java.io.InputStreamReader; + import java.io.Reader; import java.util.Map; *************** *** 286,292 **** public String getSource() { // TODO Cache the contents and only reload if the file hasn't changed! try { StringBuffer buffer = new StringBuffer(); ! BufferedReader reader = new BufferedReader(new InputStreamReader(underlyingFile.getContents())); String line = null; while ((line = reader.readLine()) != null) { --- 287,295 ---- public String getSource() { // TODO Cache the contents and only reload if the file hasn't changed! + BufferedReader reader = null; + String source = null; try { StringBuffer buffer = new StringBuffer(); ! reader = new BufferedReader(new InputStreamReader(underlyingFile.getContents())); String line = null; while ((line = reader.readLine()) != null) { *************** *** 294,304 **** buffer.append("\n"); } ! return buffer.toString(); } catch (CoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ! return null; } --- 297,313 ---- buffer.append("\n"); } ! source = buffer.toString(); } catch (CoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); + } finally { + try { + if (reader != null) reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } } ! return source; } |