You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Stefan Guggisberg (JIRA)" <ji...@apache.org> on 2011/07/06 15:43:16 UTC
[jira] [Commented] (JCR-2985) Transient space bug in combination
with removeItem() + addNode() + itemExists()
[ https://issues.apache.org/jira/browse/JCR-2985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13060575#comment-13060575 ]
Stefan Guggisberg commented on JCR-2985:
----------------------------------------
i was able to reproduce the issue. it's most likely a CachingHierarchyManager-related issue.
> Transient space bug in combination with removeItem() + addNode() + itemExists()
> -------------------------------------------------------------------------------
>
> Key: JCR-2985
> URL: https://issues.apache.org/jira/browse/JCR-2985
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: jackrabbit-core
> Affects Versions: 2.2.5
> Environment: Win7
> Reporter: Thomas Auinger
>
> Please see my original mailing list mail, and reply from Jukka following below
> Hi,
> I just tested against the brandnew 2.2.7, and can still repro this bug. Would you please check yourself? The test class code is below.
> Simply grab a repositorty.xml file (I took mine from "jackrabbit-core-2.2.7-sources.jar\org\apache\jackrabbit\core\repository.xml").
> When you start the test on a missing or empty repo-folder, it works. Running it a second time doesn't.
> Thanks!
> Tom
> package de.byteconsult.spoon.cmd;
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.FileNotFoundException;
> import javax.jcr.Node;
> import javax.jcr.Repository;
> import javax.jcr.RepositoryException;
> import javax.jcr.Session;
> import javax.jcr.SimpleCredentials;
> import org.apache.jackrabbit.core.RepositoryImpl;
> import org.apache.jackrabbit.core.config.RepositoryConfig;
> import org.junit.Assert;
> import org.junit.Test;
> public class TestRepoBug {
> @Test
> public void addTest() throws Exception {
> Repository repo = this.createFileBasedRepository("target/test-jackrabbit",
> "src/test/resources/test-repository.xml");
> if (repo != null) {
> System.out.println("Version: " + repo.getDescriptor(Repository.REP_VERSION_DESC));
> SimpleCredentials credentials = new SimpleCredentials("admin", "admin".toCharArray());
> Session session = repo.login(credentials);
> String path = "/test";
> if (session.itemExists(path)) {
> System.out.println("removing item at " + path);
> session.removeItem(path);
> }
> Node node = session.getRootNode().addNode("test");
> boolean existsBefore = session.itemExists(path);
> node.getPath();
> boolean existsAfter = session.itemExists(path);
> Assert.assertTrue("Node must already exist before calling node.getPath()", existsBefore);
> Assert.assertTrue("Node must still exist after calling node.getPath()", existsAfter);
> session.save();
> }
> else {
> Assert.fail("Failed to create repository");
> }
> }
> protected Repository createFileBasedRepository(String folderPath, String repositoryXmlPath)
> throws RepositoryException, FileNotFoundException {
> // create homedir
> File homeDir = new File(folderPath);
> homeDir.mkdirs();
> File confFile = new File(repositoryXmlPath);
> if (!confFile.isFile()) {
> throw new IllegalArgumentException("Repository config file is not a valid file: "
> + confFile.getAbsolutePath());
> }
> // create RepositoryConfig instance
> RepositoryConfig repositoryConfig = RepositoryConfig.create(new FileInputStream(confFile),
> homeDir.getAbsolutePath());
> Repository repository = RepositoryImpl.create(repositoryConfig);
> return repository;
> }
> }
> -----Ursprüngliche Nachricht-----
> Von: Tobias Bocanegra [mailto:tripod@adobe.com]
> Gesendet: Mittwoch, 8. Juni 2011 09:05
> An: users@jackrabbit.apache.org
> Betreff: Re: Session Question
> hi,
> i tested it with jackrabbit 2.2.5 and 2.2.6 and i always get 'true', 'true'.
> but with this test case:
> @Test
> public void addTest() throws RepositoryException {
> TransientRepository repo = new TransientRepository();
> System.out.println("Version: " + repo.getDescriptor(Repository.REP_VERSION_DESC));
> Session session = repo.login();
> String path = "/test";
> if (session.itemExists(path)) {
> System.out.println("removing item at " + path);
> session.removeItem(path);
> }
> Node node = session.getRootNode().addNode("test");
> System.out.println(session.itemExists(path));
> node.getPath();
> System.out.println(session.itemExists(path));
> }
> regards, toby
> On Tue, Jun 7, 2011 at 2:37 AM, Thomas Auinger <au...@byteconsult.de> wrote:
> > A very basic problem has just come up (Jackrabbit 2.2.5). It seems that session.itemExists() returns true for a newly created Node only after node.getPath() has been called.?!
> >
> > Here is the code:
> >
> > Session session = prompt.getSession();
> > String path = "/test";
> > if (session.itemExists(path)) {
> > System.out.println("removing item at " + path);
> > session.removeItem(path);
> > }
> > Node node = session.getRootNode().addNode("test");
> > System.out.println(session.itemExists(path));
> > node.getPath();
> > System.out.println(session.itemExists(path));
> >
> > And the output is
> >
> > removing item at /test
> > false
> > true
> >
> > Does that make any sense at all? I know that I can get it to work by
> > calling session.save() after the addNode() line, but since its all the
> > same session, it seems like a bug. Yet a bug too fundamental to really
> > be one... :O
> >
> > The code runs with Spring Testing Framework, in-VM Repository, Session
> > created via Springmodules Bean
> >
> > Thanks
> > Tom
> ----------------------------------
> Jukka Zitting wrote:
> Looks like Jackrabbit gets confused by the transient removeItem() operation that precedes the addNode(). Basically, the problem is not that addNode() + itemExists() wouldn't work, but that the much less common removeItem() + addNode() + itemExists() combination is having trouble. You can avoid the issue by adding a session.save() call after removeItem().
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira