jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1362927 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Date Wed, 18 Jul 2012 13:03:22 GMT
Author: reschke
Date: Wed Jul 18 13:03:22 2012
New Revision: 1362927

URL: http://svn.apache.org/viewvc?rev=1362927&view=rev
Log:
JCR-3393: InternalVersionManagerBase.calculateCheckinVersionName may fail with NPE on broken
versioning persistence

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1362924

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=1362927&r1=1362926&r2=1362927&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Wed Jul 18 13:03:22 2012
@@ -699,6 +699,13 @@ abstract class InternalVersionManagerBas
     protected String calculateCheckinVersionName(InternalVersionHistoryImpl history,
                                                  NodeStateEx node, boolean simple)
             throws RepositoryException {
+
+        if (history == null) {
+            String message = "Node " + node.getNodeId() + " has no version history";
+            log.error(message);
+            throw new VersionException(message);
+        }
+
         InternalVersion best = null;
         if (simple) {
             // 1. in simple versioning just take the 'head' version
@@ -721,12 +728,24 @@ abstract class InternalVersionManagerBas
 
             for (InternalValue value: values) {
                 InternalVersion pred = history.getVersion(value.getNodeId());
+                if (pred == null) {
+                    String message = "Could not instantiate InternalVersion for nodeId "
+ value.getNodeId() + " (VHR + " + history.getId() + ", node " + node.getNodeId() + ")";
+                    log.error(message);
+                    throw new VersionException(message);
+                }
                 if (best == null
                         || pred.getName().getLocalName().length() < best.getName().getLocalName().length())
{
                     best = pred;
                 }
             }
         }
+
+        if (best == null) {
+            String message = "Could not find 'best' predecessor node for " + node.getNodeId();
+            log.error(message);
+            throw new VersionException(message);
+        }
+
         // 2. generate version name (assume no namespaces in version names)
         String versionName = best.getName().getLocalName();
         int pos = versionName.lastIndexOf('.');



Mime
View raw message