File classFile = slash("BIN").slash(name.replace('.', File.separatorChar) + ".class");
if (classFile.exists()) {
try {
- byte[] b = InputStreamToByteArray.convert(new FileInputStream(classFile));
+ FileInputStream fis = new FileInputStream(classFile);
+ byte[] b = InputStreamToByteArray.convert(fis);
+ fis.close();
Log.debug(this, " loading " + name + " from " + classFile.getAbsolutePath());
return defineClass(b, 0, b.length);
} catch (Exception e) {
if (ze != null) {
byte[] b = InputStreamToByteArray.convert(zf.getInputStream(ze));
Log.debug(this, " loading " + name + " from " + f.getAbsolutePath());
+ zf.close();
return defineClass(b, 0, b.length);
}
+ zf.close();
}
}
} catch (Exception e) {
if (ze != null) {
byte[] b = InputStreamToByteArray.convert(zf.getInputStream(ze));
Log.debug(this, " loading " + name + " from " + f.getAbsolutePath());
+ zf.close();
return defineClass(b, 0, b.length);
}
+ zf.close();
}
}
} catch (Exception e) {
} catch (Exception e) {
Log.error(l.getClass(), "Listener threw exception");
Log.error(l.getClass(), e);
+ } finally {
+ conn.close();
}
} }.start();
return;
private static void check(String s) { if (s.startsWith("4")||s.startsWith("5")) throw new MailException(s); }
private static boolean attempt(final Message m, final InetAddress mx) {
boolean accepted = false;
+ Connection conn = null;
try {
Log.info(SMTP.Outgoing.class, "connecting to " + mx + "...");
- Connection conn = new Connection(new Socket(mx, 25), InetAddress.getLocalHost().getHostName());
+ conn = new Connection(new Socket(mx, 25), InetAddress.getLocalHost().getHostName());
conn.setTimeout(60 * 1000);
Log.info(SMTP.Outgoing.class, "connected");
check(conn.readln()); // banner
Log.warn(SMTP.Outgoing.class, "unable to send; error=" + e);
Log.warn(SMTP.Outgoing.class, e);
return false;
+ } finally {
+ if (conn != null) conn.close();
}
return accepted;
}
}
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(uidNext)));
int ret = Integer.parseInt(br.readLine());
+ br.close();
if (inc) {
File tmp = new File(uidNext + "-");
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tmp)));
if (cur >= names.length) return null;
try {
File file = new File(path + File.separatorChar + names[cur]);
- return new Message(null, null, new Stream(new FileInputStream(file)));
+ FileInputStream fis = new FileInputStream(file);
+ Message ret = new Message(null, null, new Stream(fis));
+ fis.close();
+ return ret;
} catch (IOException e) { throw new MailException.IOException(e);
} catch (Message.Malformed e) { throw new MailException(e.getMessage()); }
}