|
From: <caw...@us...> - 2007-09-10 13:26:02
|
Revision: 3116
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3116&view=rev
Author: cawilliams
Date: 2007-09-10 06:26:00 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
close connection to gem index once we've read it's contents in!
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:17:21 UTC (rev 3115)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-10 13:26:00 UTC (rev 3116)
@@ -254,27 +254,41 @@
return Arrays.asList(lineArray);
}
- private byte[] getZippedGemIndex() throws MalformedURLException, IOException {
- URL url = new URL(GEM_INDEX_URL);
- URLConnection con = url.openConnection();
- InputStream content = (InputStream) con.getContent();
+ private byte[] getZippedGemIndex() {
+ InputStream content = null;
byte[] input = new byte[1024];
int index = 0;
- while (true) {
- int bytesToRead = content.available();
- byte[] tmp = new byte[bytesToRead];
- int length = content.read(tmp);
- if (length == -1)
- break;
- while ((index + length) > input.length) { // if we'll overflow the
- // array, we need to
- // expand it
- byte[] newInput = new byte[input.length * 2];
- System.arraycopy(input, 0, newInput, 0, input.length);
- input = newInput;
+ try {
+ URL url = new URL(GEM_INDEX_URL);
+ URLConnection con = url.openConnection();
+ content = (InputStream) con.getContent();
+ while (true) {
+ int bytesToRead = content.available();
+ byte[] tmp = new byte[bytesToRead];
+ int length = content.read(tmp);
+ if (length == -1)
+ break;
+ while ((index + length) > input.length) { // if we'll overflow the
+ // array, we need to
+ // expand it
+ byte[] newInput = new byte[input.length * 2];
+ System.arraycopy(input, 0, newInput, 0, input.length);
+ input = newInput;
+ }
+ System.arraycopy(tmp, 0, input, index, length);
+ index += length;
}
- System.arraycopy(tmp, 0, input, index, length);
- index += length;
+ } catch (Exception e) {
+ AptanaRDTPlugin.log(e);
+ return new byte[0];
+ } finally {
+ try {
+ if (content != null) {
+ content.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
}
// Strip byte array down to just length of the content we actually read in.
byte[] newInput = new byte[index];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|