Changeset 6508


Ignore:
Timestamp:
Aug 8, 2014, 8:37:10 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1828: Calling Directory.getNew() multiple times with overlapping non-existing paths

Added a test case. Here is the current stack trace:

net.sf.basedb.core.DatabaseException: ERROR: duplicate key value violates unique constraint "Directories_name_parent_id_key"
  Detail: Key (name, parent_id)=(foo, 536) already exists.
	at net.sf.basedb.core.HibernateUtil.commit(HibernateUtil.java:1173)
	at net.sf.basedb.core.DbControl.commit(DbControl.java:505)
	at TestDirectory.test_create_multiple(TestDirectory.java:167)
	at TestDirectory.test_all(TestDirectory.java:67)
	at TestDirectory.main(TestDirectory.java:47)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "Directories_name_parent_id_key"
  Detail: Key (name, parent_id)=(foo, 536) already exists.
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
	at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2435)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2875)
	at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
	at net.sf.basedb.core.HibernateUtil.commit(HibernateUtil.java:1168)
	... 4 more
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/test/TestDirectory.java

    r6502 r6508  
    6565    test_list(id1);
    6666   
     67    int[] pid = test_create_multiple("/foo", "/foo/bar1", "/foo/bar2", "/foo/bar1/sub1");
     68   
    6769    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     70    if (pid != null && pid.length > 0) test_delete(pid[0], true);
    6871    test_delete(id_sub2, false);
    6972
     
    147150  }
    148151 
     152  static int[] test_create_multiple(String... path)
     153  {
     154    if (!TestUtil.hasPermission(Permission.CREATE, Item.DIRECTORY)) return null;
     155    int id[] = new int[path.length];
     156    DbControl dc = null;
     157    try
     158    {
     159      dc = TestUtil.getDbControl();
     160      for (int i = 0; i < path.length; i++)
     161      {
     162        Path p = new Path(path[i], Path.Type.DIRECTORY);
     163        Directory d = Directory.getNew(dc, p);
     164        write_item(i, d);
     165        id[i] = d.getId();
     166      }
     167      dc.commit();
     168      write("--Create multiple by path OK");
     169    }
     170    catch (Throwable ex)
     171    {
     172      write("--Create multiple by path FAILED");
     173      ex.printStackTrace();
     174      ok = false;
     175    }
     176    finally
     177    {
     178      if (dc != null) dc.close();
     179    }
     180    return id;
     181  }
     182
     183 
    149184  static void test_load(int id)
    150185  {
Note: See TracChangeset for help on using the changeset viewer.