You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/09/29 10:22:37 UTC
svn commit: r451156 -
/james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
Author: norman
Date: Fri Sep 29 01:22:36 2006
New Revision: 451156
URL: http://svn.apache.org/viewvc?view=rev&rev=451156
Log:
Fix a minor leak which was caused by not closing a RandomAccesFile after reading
Modified:
james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
Modified: james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java?view=diff&rev=451156&r1=451155&r2=451156
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java (original)
+++ james/server/trunk/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java Fri Sep 29 01:22:36 2006
@@ -21,6 +21,8 @@
package org.apache.james.transport.matchers;
+import java.io.IOException;
+
import org.apache.oro.text.regex.MalformedPatternException;
import javax.mail.MessagingException;
@@ -34,8 +36,9 @@
* @see org.apache.james.transport.matchers.GenericRegexMatcher#init()
*/
public void init() throws MessagingException {
+ java.io.RandomAccessFile patternSource = null;
try {
- java.io.RandomAccessFile patternSource = new java.io.RandomAccessFile(getCondition(), "r");
+ patternSource = new java.io.RandomAccessFile(getCondition(), "r");
int lines = 0;
while(patternSource.readLine() != null) lines++;
patterns = new Object[lines][2];
@@ -44,8 +47,9 @@
String line = patternSource.readLine();
patterns[i][0] = line.substring(0, line.indexOf(':'));
patterns[i][1] = line.substring(line.indexOf(':')+1);
- }
+ }
compile(patterns);
+
}
catch (java.io.FileNotFoundException fnfe) {
throw new MessagingException("Could not locate patterns.", fnfe);
@@ -55,6 +59,15 @@
}
catch(MalformedPatternException mp) {
throw new MessagingException("Could not initialize regex patterns", mp);
+ } finally {
+ if (patternSource != null) {
+ // close the file
+ try {
+ patternSource.close();
+ } catch (IOException e) {
+ // just ignore on close
+ }
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org