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/10/08 19:18:12 UTC
svn commit: r454175 -
/james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
Author: norman
Date: Sun Oct 8 10:18:12 2006
New Revision: 454175
URL: http://svn.apache.org/viewvc?view=rev&rev=454175
Log:
Backport JAMES-644
Modified:
james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
Modified: james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java?view=diff&rev=454175&r1=454174&r2=454175
==============================================================================
--- james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java (original)
+++ james/server/branches/v2.3/src/java/org/apache/james/transport/matchers/FileRegexMatcher.java Sun Oct 8 10:18:12 2006
@@ -17,6 +17,8 @@
package org.apache.james.transport.matchers;
+import java.io.IOException;
+
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.mailet.RFC2822Headers;
import javax.mail.MessagingException;
@@ -27,8 +29,9 @@
*/
public class FileRegexMatcher extends GenericRegexMatcher {
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];
@@ -37,8 +40,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);
@@ -48,6 +52,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