bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1764610 - in /bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr: ConfigurationImpl.java ConstraintValidation.java DefaultConstraintValidatorFactory.java
Date Thu, 13 Oct 2016 07:21:04 GMT
Author: rmannibucau
Date: Thu Oct 13 07:21:04 2016
New Revision: 1764610

URL: http://svn.apache.org/viewvc?rev=1764610&view=rev
Log:
BVAL-148 ensuring our double state locking does what we want - we can evaluate to remove it
later too

Modified:
    bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
    bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java
    bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java?rev=1764610&r1=1764609&r2=1764610&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java Thu Oct 13
07:21:04 2016
@@ -75,22 +75,22 @@ public class ConfigurationImpl implement
      * Configured {@link MessageInterpolator}
      */
     protected MessageInterpolator defaultMessageInterpolator = new DefaultMessageInterpolator();
-    protected MessageInterpolator messageInterpolator = defaultMessageInterpolator;
+    protected volatile MessageInterpolator messageInterpolator = defaultMessageInterpolator;
     protected Class<? extends MessageInterpolator> messageInterpolatorClass = null;
 
     /**
      * Configured {@link ConstraintValidatorFactory}
      */
     protected ConstraintValidatorFactory defaultConstraintValidatorFactory = new DefaultConstraintValidatorFactory();
-    protected ConstraintValidatorFactory constraintValidatorFactory = defaultConstraintValidatorFactory;
+    protected volatile ConstraintValidatorFactory constraintValidatorFactory = defaultConstraintValidatorFactory;
     protected Class<? extends ConstraintValidatorFactory> constraintValidatorFactoryClass
= null;
 
     protected TraversableResolver defaultTraversableResolver = new DefaultTraversableResolver();
-    protected TraversableResolver traversableResolver = defaultTraversableResolver;
+    protected volatile TraversableResolver traversableResolver = defaultTraversableResolver;
     protected Class<? extends TraversableResolver> traversableResolverClass = null;
 
     protected ParameterNameProvider defaultParameterNameProvider = new DefaultParameterNameProvider();
-    protected ParameterNameProvider parameterNameProvider = defaultParameterNameProvider;
+    protected volatile ParameterNameProvider parameterNameProvider = defaultParameterNameProvider;
     protected Class<? extends ParameterNameProvider> parameterNameProviderClass = null;
 
     protected BootstrapConfiguration  bootstrapConfiguration;

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java?rev=1764610&r1=1764609&r2=1764610&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ConstraintValidation.java Thu Oct
13 07:21:04 2016
@@ -64,7 +64,7 @@ public class ConstraintValidation<T exte
     private final boolean reportFromComposite;
     private final Map<String, Object> attributes;
     private T annotation; // for metadata request API
-    private ConstraintValidator<T, ?> validator;
+    private volatile ConstraintValidator<T, ?> validator;
 
     private Set<ConstraintValidation<?>> composedConstraints;
 

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java?rev=1764610&r1=1764609&r2=1764610&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
(original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
Thu Oct 13 07:21:04 2016
@@ -34,7 +34,7 @@ import java.util.concurrent.CopyOnWriteA
  */
 public class DefaultConstraintValidatorFactory implements ConstraintValidatorFactory, Closeable
{
     private final Collection<BValExtension.Releasable<?>> releasables = new CopyOnWriteArrayList<BValExtension.Releasable<?>>();
-    private Boolean useCdi = null; // store it to avoid NoClassDefFoundError when cdi is
not present (it is slow) + lazily (to wait cdi is started)
+    private volatile Boolean useCdi = null; // store it to avoid NoClassDefFoundError when
cdi is not present (it is slow) + lazily (to wait cdi is started)
 
     /**
      * Instantiate a Constraint.
@@ -47,7 +47,7 @@ public class DefaultConstraintValidatorF
             synchronized (this) {
                 if (useCdi == null) {
                     try {
-                        useCdi = Boolean.valueOf(BValExtension.getBeanManager() != null);
+                        useCdi = BValExtension.getBeanManager() != null;
                     } catch (final NoClassDefFoundError error) {
                         useCdi = Boolean.FALSE;
                     } catch (final Exception e) {
@@ -60,7 +60,7 @@ public class DefaultConstraintValidatorF
         // 2011-03-27 jw: Do not use PrivilegedAction.
         // Otherwise any user code would be executed with the privileges of this class.
         try {
-            if (useCdi.booleanValue()) {
+            if (useCdi) {
                 try {
                     final BValExtension.Releasable<T> instance = BValExtension.inject(constraintClass);
                     if (instance != null) {



Mime
View raw message