jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r927898 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Date Fri, 26 Mar 2010 15:03:35 GMT
Author: jukka
Date: Fri Mar 26 15:03:35 2010
New Revision: 927898

URL: http://svn.apache.org/viewvc?rev=927898&view=rev
Log:
JCR-2586: Missing synchronization in InternalVersionHistoryImpl

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=927898&r1=927897&r2=927898&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Fri Mar 26 15:03:35 2010
@@ -118,7 +118,7 @@ class InternalVersionHistoryImpl extends
      *
      * @throws RepositoryException if an error occurs
      */
-    private void init() throws RepositoryException {
+    private synchronized void init() throws RepositoryException {
         nameCache.clear();
         versionCache.clear();
         labelCache.clear();
@@ -176,7 +176,7 @@ class InternalVersionHistoryImpl extends
      * Reload this object and all its dependent version objects.
      * @throws RepositoryException if an error occurs
      */
-    void reload() throws RepositoryException {
+    synchronized void reload() throws RepositoryException {
         tempVersionCache.putAll(versionCache);
 
         init();
@@ -195,7 +195,7 @@ class InternalVersionHistoryImpl extends
      * @return the new internal version
      * @throws IllegalArgumentException if the version does not exist
      */
-    InternalVersionImpl createVersionInstance(Name name) {
+    synchronized InternalVersionImpl createVersionInstance(Name name) {
         try {
             NodeStateEx nodeStateEx = node.getNode(name, 1);
             InternalVersionImpl v = createVersionInstance(nodeStateEx);
@@ -221,7 +221,7 @@ class InternalVersionHistoryImpl extends
      * @param child child node state
      * @return new version instance
      */
-    InternalVersionImpl createVersionInstance(NodeStateEx child) {
+    synchronized InternalVersionImpl createVersionInstance(NodeStateEx child) {
         InternalVersionImpl v = (InternalVersionImpl) tempVersionCache.remove(child.getNodeId());
         if (v != null) {
             v.clear();
@@ -266,7 +266,8 @@ class InternalVersionHistoryImpl extends
     /**
      * {@inheritDoc}
      */
-    public InternalVersion getVersion(Name versionName) throws VersionException {
+    public synchronized InternalVersion getVersion(Name versionName)
+            throws VersionException {
         NodeId versionId = nameCache.get(versionName);
         if (versionId == null) {
             throw new VersionException("Version " + versionName + " does not exist.");
@@ -282,7 +283,7 @@ class InternalVersionHistoryImpl extends
     /**
      * {@inheritDoc}
      */
-    public boolean hasVersion(Name versionName) {
+    public synchronized boolean hasVersion(Name versionName) {
         return nameCache.containsKey(versionName);
     }
 
@@ -315,7 +316,7 @@ class InternalVersionHistoryImpl extends
      * Returns the version from cache, or <code>null</code> if it is not
      * present.
      */
-    private InternalVersion getCachedVersion(NodeId id) {
+    private synchronized InternalVersion getCachedVersion(NodeId id) {
         InternalVersion v = versionCache.get(id);
         if (v == null) {
             for (Name versionName : nameCache.keySet()) {
@@ -331,7 +332,7 @@ class InternalVersionHistoryImpl extends
     /**
      * {@inheritDoc}
      */
-    public InternalVersion getVersionByLabel(Name label) {
+    public synchronized InternalVersion getVersionByLabel(Name label) {
         Name versionName = labelCache.get(label);
         if (versionName == null) {
             return null;
@@ -348,14 +349,14 @@ class InternalVersionHistoryImpl extends
     /**
      * {@inheritDoc}
      */
-    public Name[] getVersionNames() {
+    public synchronized Name[] getVersionNames() {
         return nameCache.keySet().toArray(new Name[nameCache.size()]);
     }
     
     /**
      * {@inheritDoc}
      */
-    public int getNumVersions() {
+    public synchronized int getNumVersions() {
         return nameCache.size();
     }
 
@@ -369,7 +370,7 @@ class InternalVersionHistoryImpl extends
     /**
      * {@inheritDoc}
      */
-    public Name[] getVersionLabels() {
+    public synchronized Name[] getVersionLabels() {
         return labelCache.keySet().toArray(new Name[labelCache.size()]);
     }
 
@@ -392,7 +393,7 @@ class InternalVersionHistoryImpl extends
      * @param versionName name of the version to remove
      * @throws VersionException if removal is not possible
      */
-    void removeVersion(Name versionName) throws RepositoryException {
+    synchronized void removeVersion(Name versionName) throws RepositoryException {
 
         InternalVersionImpl v = (InternalVersionImpl) getVersion(versionName);
         if (v.equals(rootVersion)) {
@@ -468,7 +469,7 @@ class InternalVersionHistoryImpl extends
      * @return the version that was previously assigned by this label or <code>null</code>.
      * @throws VersionException if the version does not exist or if the label is already
defined.
      */
-    InternalVersion setVersionLabel(Name versionName, Name label, boolean move)
+    synchronized InternalVersion setVersionLabel(Name versionName, Name label, boolean move)
             throws VersionException {
         InternalVersion version =
             (versionName != null) ? getVersion(versionName) : null;
@@ -526,7 +527,8 @@ class InternalVersionHistoryImpl extends
      * @return the newly created version
      * @throws RepositoryException if an error occurs
      */
-    InternalVersionImpl checkin(Name name, NodeStateEx src, Calendar created)
+    synchronized InternalVersionImpl checkin(
+            Name name, NodeStateEx src, Calendar created)
             throws RepositoryException {
 
         // copy predecessors from src node



Mime
View raw message