Hugh Mc Guinness created SLING-3554:
---------------------------------------

             Summary: createDataStoreGarbageCollector returns null
                 Key: SLING-3554
                 URL: https://issues.apache.org/jira/browse/SLING-3554
             Project: Sling
          Issue Type: Bug
          Components: JCR
    Affects Versions: JCR Jackrabbit Server 2.1.2
         Environment: Any
            Reporter: Hugh Mc Guinness


Using a reference to a SlingServerRepository, calling 
createDataStoreGarbageCollector() returns null. This prevents the datastore 
garbage collector from being run.

The problem appears to stem from a refactor where this code:
{code:title=SlingServerRepository.java|borderStyle=solid}
public DataStoreGarbageCollector createDataStoreGarbageCollector() throws 
RepositoryException {
        RepositoryImpl repository = (RepositoryImpl) getRepository();
        if (repository != null) {
                return repository.createDataStoreGarbageCollector();
        }

        throw new RepositoryException("Repository couldn't be acquired");
}
{code}
was changed to this code:
{code:title=SlingServerRepository.java|borderStyle=solid}
public DataStoreGarbageCollector createDataStoreGarbageCollector() throws 
RepositoryException {
        final Repository base = this.getRepository();
        if (base instanceof RepositoryManager) {
                return ((RepositoryManager) 
base).createDataStoreGarbageCollector();
        }

        return null;
}
{code}

The problem here is that this method exists in two places, the 
RepositoryManager interface and the RepositoryImpl class. The Repository object 
being referenced above is not a RepositoryManager but it is a RepositoryImpl.

For the project I'm using Sling for I custom built using the following 
modification which works fine however you may wish to leave out the reference 
to RepositoryManager entirely:
{code:title=SlingServerRepository.java|borderStyle=solid}
public DataStoreGarbageCollector createDataStoreGarbageCollector() throws 
RepositoryException {
        final Repository base = this.getRepository();
        if (base instanceof RepositoryManager) {
                return ((RepositoryManager) 
base).createDataStoreGarbageCollector();
        } else if (base instanceof RepositoryImpl) {
                return ((RepositoryImpl) 
base).createDataStoreGarbageCollector();
        }

        return null;
}
{code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to