[Schmitzm-commits] r2016 - trunk/schmitzm-core/src/main/java/de/schmitzm/regex

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat May 26 23:19:49 CEST 2012


Author: alfonx
Date: 2012-05-26 23:19:49 +0200 (Sat, 26 May 2012)
New Revision: 2016

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
Log:


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-26 21:06:05 UTC (rev 2015)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-26 21:19:49 UTC (rev 2016)
@@ -185,13 +185,14 @@
 		final Pattern pattern = getPattern(regex);
 
 		ConcurrentHashMap<String, MyMatchResult> m;
-		synchronized (matcherResults) {
+//		synchronized (matcherResults) { matcherResults ist jetzt concurrent! 
 			m = matcherResults.get(pattern);
 			if (m == null) {
 				matcherResults.put(pattern, m = new ConcurrentHashMap<String, MyMatchResult>(
 						CACHE_VALUES_TO_RESULT_SIZE));
 			}
-		}
+//		}
+			
 		// LimitedConcurrentHashMap<String, MyMatchResult> m;
 		// synchronized (matchers) {
 		// m = matchers.get(pattern);
@@ -201,20 +202,22 @@
 		// }
 		// }
 
-		MyMatchResult matcher;
-		synchronized (m) {
-			matcher = m.get(value);
-			if (matcher == null) {
+		MyMatchResult mResult;
+//		synchronized (m) {
+			mResult = m.get(value);
+			if (mResult == null) {
 				// final Matcher xm = pattern.matcher(value);
 				final Matcher xm = getMatcher(regex, value);
 				if (xm.find())
-					matcher = new MyMatchResult(xm.toMatchResult());
+					mResult = new MyMatchResult(xm.toMatchResult());
 				else
-					matcher = new MyMatchResult(null);
+					mResult = new MyMatchResult(null);
+				
+				m.put(regex, mResult); // Hat die gefehlt?
 			}
-		}
+//		}
 
-		return matcher.matcherResult;
+		return mResult.matcherResult;
 	}
 
 }



More information about the Schmitzm-commits mailing list