Author: chris.laprun(a)jboss.com
Date: 2012-03-21 12:51:26 -0400 (Wed, 21 Mar 2012)
New Revision: 8627
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
Log:
Bug 805472 - NSE [java.util.regex.Matcher] at any validated input (in cluster mode):
remember the regular expression and create/reset Matcher on demand.
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2012-03-21
10:35:50 UTC (rev 8626)
+++
epp/portal/branches/EPP_5_2_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2012-03-21
16:51:26 UTC (rev 8627)
@@ -36,7 +36,8 @@
@Serialized
public class ExpressionValidator extends AbstractValidator
{
- private Matcher matcher;
+ private String regexp;
+ private transient Matcher matcher;
private String key_;
@@ -47,16 +48,29 @@
public ExpressionValidator(final String regex)
{
- matcher = Pattern.compile(regex).matcher("");
- key_ = "ExpressionValidator.msg.value-invalid";
+ this(regex, "ExpressionValidator.msg.value-invalid");
}
public ExpressionValidator(final String regex, final String key)
{
- matcher = Pattern.compile(regex).matcher("");
+ this.regexp = regex;
key_ = key;
}
+ private Matcher getMatcherFor(String input)
+ {
+ if(matcher == null)
+ {
+ matcher = Pattern.compile(regexp).matcher(input);
+ }
+ else
+ {
+ matcher.reset(input);
+ }
+
+ return matcher;
+ }
+
@Override
protected String getMessageLocalizationKey()
{
@@ -66,8 +80,7 @@
@Override
protected boolean isValid(String value, UIFormInput uiInput)
{
- matcher.reset(value);
- return matcher.matches();
+ return getMatcherFor(value).matches();
}
@Override
Show replies by date