Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2200

decrementBinaryReferenceCount() fails when InfinispanBinaryStore and Federation are enabled

    XMLWordPrintable

Details

    Description

      When I have a repository with federated data sources (e.g. the FileSystemConnector) and am using the InfinispanBinaryStore, I get this NPE removing a node with a binary property, e.g.:

      @Test
      public void testDeleteDatastreamNode() throws Exception {
        Session session = repo.login();
      
        final Node node = new JcrTools().findOrCreateNode(session, "/testDatastreamNode1", NT_FILE);
      
        final Node contentNode = new JcrTools().findOrCreateChild(node, JCR_CONTENT, NT_RESOURCE);
      
        final ValueFactory modevf =
            (ValueFactory) node.getSession().getValueFactory();
        final javax.jcr.Binary binary = modevf.createBinary(new ByteArrayInputStream("asdf".getBytes()));
      
        contentNode.setProperty(JCR_DATA, binary);
        session.save();
        session.logout();
      
      
        session = repo.login();
        session.getNode("/testDatastreamNode1").remove();
        session.save();  ## The NPE occurs here
        session.logout();
      }
      

      The stack trace (under 4.0.0.Alpha2) includes:

      javax.jcr.RepositoryException: java.lang.NullPointerException
      	at org.modeshape.jcr.cache.document.DocumentTranslator.decrementBinaryReferenceCount(DocumentTranslator.java:1265)
      	at org.modeshape.jcr.cache.document.WritableSessionCache.persistChanges(WritableSessionCache.java:952)
      	at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:613)
      	at org.modeshape.jcr.JcrSession.save(JcrSession.java:1131)
      

      Here is a snippet of an offending Modeshape configuration:

      ...
           "storage" : {
              "cacheName" : "FedoraRepository",
              "cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/testing/infinispan-basic.xml}",
              "binaryStorage" : {
                  "type" : "cache",
                  "dataCacheName" : "dataCache",
                  "metadataCacheName" : "metadataCache"
              }
          },
          "externalSources" : {
            "fileSystem" : { "classname" : "org.modeshape.connector.filesystem.FileSystemConnector",
              "directoryPath" : "target/test-classes/test-objects",
              "readonly" : false,
              "extraPropertiesStorage": "json",
              "cacheTtlSeconds" : 5,
              "projections" : [ "default:/files => /" ]
            }
          },
      ...
      

      This configuration works fine if I remove the binary store configuration:

      ...
      
          "storage" : {
              "cacheName" : "FedoraRepository",
              "cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/testing/infinispan-basic.xml}"
          },
          "externalSources" : {
            "fileSystem" : { "classname" : "org.modeshape.connector.filesystem.FileSystemConnector",
              "directoryPath" : "target/test-classes/test-objects",
              "readonly" : false,
              "extraPropertiesStorage": "json",
              "cacheTtlSeconds" : 5,
              "projections" : [ "default:/files => /" ]
            }
          },
      

      Or the external sources:

      ...
      
          "storage" : {
              "cacheName" : "FedoraRepository",
              "cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/testing/infinispan-basic.xml}",
              "binaryStorage" : {
                  "type" : "cache",
                  "dataCacheName" : "dataCache",
                  "metadataCacheName" : "metadataCache"
              }
          }
      

      I added some logging in the failing case and saw the FederatedDocumentStore attempts to find the "-ref" node in the connectors, fails, and returns null:

      TRACE 14:56:02.338 (DocumentTranslator) decrementBinaryReferenceCount for binary (3B, SHA1=0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33)
      TRACE 14:56:02.338 (DocumentTranslator) documentStore: org.modeshape.jcr.federation.FederatedDocumentStore@2263811f
      TRACE 14:56:02.338 (DocumentTranslator) documentStore.get(0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33-ref)
      TRACE 14:56:02.338 (FederatedDocumentStore) get(0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33-ref)
      TRACE 14:56:02.338 (FederatedDocumentStore) looking in connectors
      TRACE 14:56:02.338 (FederatedDocumentStore) giving up
      

      Attachments

        Activity

          People

            rhauch Randall Hauch (Inactive)
            cbeer_jira Chris Beer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: