You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/03/12 19:12:55 UTC

svn commit: r385328 - /jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java

Author: sebb
Date: Sun Mar 12 10:12:54 2006
New Revision: 385328

URL: http://svn.apache.org/viewcvs?rev=385328&view=rev
Log:
PatternCacheLRU is not Serialisable, so make transient and create in readResolve()

Modified:
    jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java

Modified: jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java?rev=385328&r1=385327&r2=385328&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/RegexFunction.java Sun Mar 12 10:12:54 2006
@@ -17,6 +17,7 @@
 
 package org.apache.jmeter.functions;
 
+import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
@@ -59,7 +60,7 @@
 
 	private static PatternCacheLRU patternCache = new PatternCacheLRU(1000, new Perl5Compiler());
 
-	private Pattern templatePattern;// initialised to the regex \$(\d+)\$
+	private transient Pattern templatePattern;// initialised to the regex \$(\d+)\$
 
 	private static ThreadLocal localMatcher = new ThreadLocal() {
 		protected Object initialValue() {
@@ -83,6 +84,13 @@
 	public RegexFunction() {
 		templatePattern = patternCache.getPattern("\\$(\\d+)\\$", Perl5Compiler.READ_ONLY_MASK);
 	}
+
+    // For serialised objects, do the same work as the constructor:
+    private Object readResolve() throws ObjectStreamException {
+        templatePattern = patternCache.getPattern("\\$(\\d+)\\$", Perl5Compiler.READ_ONLY_MASK);
+        return this;
+    }
+
 
 	public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
 			throws InvalidVariableException {



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org