jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1449729 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java NodeImpl.java
Date Mon, 25 Feb 2013 14:49:18 GMT
Author: jukka
Date: Mon Feb 25 14:49:18 2013
New Revision: 1449729

URL: http://svn.apache.org/r1449729
Log:
OAK-652: ItemImpl.checkProtected() is too slow

Add a temporary flag for disabling the transient item definition checks

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1449729&r1=1449728&r2=1449729&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Mon Feb 25 14:49:18 2013
@@ -36,6 +36,13 @@ import org.slf4j.LoggerFactory;
  */
 abstract class ItemImpl<T extends ItemDelegate> extends AbstractItem {
 
+    /**
+     * Flag to disable expensive transient item definition checks.
+     * FIXME: This flag should be removed once OAK-652 gets resolved.
+     */
+    protected static final boolean DISABLE_TRANSIENT_DEFINITION_CHECKS =
+            Boolean.getBoolean("OAK-652");
+
     protected final SessionDelegate sessionDelegate;
     protected final T dlg;
 
@@ -169,6 +176,10 @@ abstract class ItemImpl<T extends ItemDe
     }
 
     void checkProtected() throws RepositoryException {
+        if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
+            return;
+        }
+
         ItemDefinition definition;
         try {
             definition = (isNode()) ? ((Node) this).getDefinition() : ((Property) this).getDefinition();

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1449729&r1=1449728&r2=1449729&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Mon Feb 25 14:49:18 2013
@@ -1465,19 +1465,24 @@ public class NodeImpl<T extends NodeDele
                                 sessionDelegate, dlg.getLocation().getChild(oakName)));
                     }
                 } else {
-                    PropertyDefinition definition;
-                    if (hasProperty(jcrName)) {
-                        definition = getProperty(jcrName).getDefinition();
+                    Value targetValue;
+                    if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
+                        targetValue = value;
                     } else {
-                        definition = dlg.sessionDelegate.getDefinitionProvider().getDefinition(NodeImpl.this,
oakName, false, type, exactTypeMatch);
-                    }
-                    checkProtected(definition);
-                    if (definition.isMultiple()) {
-                        throw new ValueFormatException("Cannot set single value to multivalued
property");
-                    }
+                        PropertyDefinition definition;
+                        if (hasProperty(jcrName)) {
+                            definition = getProperty(jcrName).getDefinition();
+                        } else {
+                            definition = dlg.sessionDelegate.getDefinitionProvider().getDefinition(NodeImpl.this,
oakName, false, type, exactTypeMatch);
+                        }
+                        checkProtected(definition);
+                        if (definition.isMultiple()) {
+                            throw new ValueFormatException("Cannot set single value to multivalued
property");
+                        }
 
-                    int targetType = getTargetType(value, definition);
-                    Value targetValue = ValueHelper.convert(value, targetType, getValueFactory());
+                        int targetType = getTargetType(value, definition);
+                        targetValue = ValueHelper.convert(value, targetType, getValueFactory());
+                    }
 
                     return new PropertyImpl(dlg.setProperty(oakName, targetValue));
                 }
@@ -1504,19 +1509,24 @@ public class NodeImpl<T extends NodeDele
                                 sessionDelegate, dlg.getLocation().getChild(oakName)));
                     }
                 } else {
-                    PropertyDefinition definition;
-                    if (hasProperty(jcrName)) {
-                        definition = getProperty(jcrName).getDefinition();
+                    Value[] targetValues;
+                    if (DISABLE_TRANSIENT_DEFINITION_CHECKS) {
+                        targetValues = values;
                     } else {
-                        definition = dlg.sessionDelegate.getDefinitionProvider().getDefinition(NodeImpl.this,
oakName, true, type, exactTypeMatch);
-                    }
-                    checkProtected(definition);
-                    if (!definition.isMultiple()) {
-                        throw new ValueFormatException("Cannot set value array to single
value property");
-                    }
+                        PropertyDefinition definition;
+                        if (hasProperty(jcrName)) {
+                            definition = getProperty(jcrName).getDefinition();
+                        } else {
+                            definition = dlg.sessionDelegate.getDefinitionProvider().getDefinition(NodeImpl.this,
oakName, true, type, exactTypeMatch);
+                        }
+                        checkProtected(definition);
+                        if (!definition.isMultiple()) {
+                            throw new ValueFormatException("Cannot set value array to single
value property");
+                        }
 
-                    int targetType = getTargetType(values, definition);
-                    Value[] targetValues = ValueHelper.convert(values, targetType, getValueFactory());
+                        int targetType = getTargetType(values, definition);
+                        targetValues = ValueHelper.convert(values, targetType, getValueFactory());
+                    }
 
                     Iterable<Value> nonNullValues = Iterables.filter(
                             Arrays.asList(targetValues),



Mime
View raw message