* I2PSnark, Jetty, SAM, crypto: findbugs resource leaks.

This commit is contained in:
dg2-new
2015-02-10 21:57:27 +00:00
parent 1be9bb29e8
commit 9163d41228
5 changed files with 18 additions and 3 deletions

View File

@@ -358,6 +358,7 @@ class BasicServlet extends HttpServlet
writeHeaders(response, content, content_length); writeHeaders(response, content, content_length);
response.setStatus(416); response.setStatus(416);
response.setHeader("Content-Range", InclusiveByteRange.to416HeaderRangeString(content_length)); response.setHeader("Content-Range", InclusiveByteRange.to416HeaderRangeString(content_length));
in.close();
return; return;
} }

View File

@@ -26,6 +26,7 @@ import net.i2p.I2PAppContext;
import net.i2p.app.*; import net.i2p.app.*;
import static net.i2p.app.ClientAppState.*; import static net.i2p.app.ClientAppState.*;
import java.io.InputStream;
import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
@@ -68,9 +69,12 @@ public class JettyStart implements ClientApp {
public void parseArgs(String[] args) throws Exception { public void parseArgs(String[] args) throws Exception {
Properties properties=new Properties(); Properties properties=new Properties();
XmlConfiguration last=null; XmlConfiguration last=null;
InputStream in = null;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if (args[i].toLowerCase().endsWith(".properties")) { if (args[i].toLowerCase().endsWith(".properties")) {
properties.load(Resource.newResource(args[i]).getInputStream()); in = Resource.newResource(args[i]).getInputStream();
properties.load(in);
in.close();
} else { } else {
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL()); XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL());
if (last!=null) if (last!=null)

View File

@@ -174,8 +174,9 @@ public class SAMStreamSend {
} }
public boolean openConnection() { public boolean openConnection() {
FileInputStream fin = null;
try { try {
FileInputStream fin = new FileInputStream(_destFile); fin = new FileInputStream(_destFile);
byte dest[] = new byte[1024]; byte dest[] = new byte[1024];
int read = DataHelper.read(fin, dest); int read = DataHelper.read(fin, dest);
@@ -200,6 +201,12 @@ public class SAMStreamSend {
} catch (IOException ioe) { } catch (IOException ioe) {
_log.error("Unable to connect", ioe); _log.error("Unable to connect", ioe);
return false; return false;
} finally {
if(fin != null) {
try {
fin.close();
} catch(IOException ioe) {}
}
} }
} }

View File

@@ -767,10 +767,10 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
if (bytesToSignInputStream != null) if (bytesToSignInputStream != null)
try { try {
bytesToSignInputStream.close(); bytesToSignInputStream.close();
fileInputStream.close();
} catch (IOException ioe) { } catch (IOException ioe) {
} }
fileInputStream = null;
} }
FileOutputStream fileOutputStream = null; FileOutputStream fileOutputStream = null;

View File

@@ -1,3 +1,6 @@
2015-02-10 dg
* I2PSnark, Jetty, SAM, crypto: findbugs resource leaks.
2015-02-07 zzz 2015-02-07 zzz
* SSU: Limit range for valid clock skew * SSU: Limit range for valid clock skew
* Transport: Ban routers if they are too old and we are non-DSA * Transport: Ban routers if they are too old and we are non-DSA