Opened 14 years ago

Closed 14 years ago

#844 closed defect (fixed)

File.isUsed() doesn't check if a file has been used in a FileSet.

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: BASE 2.5
Component: core Version:
Keywords: Cc:

Description

The file is reported as not used, but when trying to delete it the following stack trace is displayed and logged in Tomcat's log:

12:56:15,275 ERROR [jsp]:253 - Servlet.service() for servlet jsp threw exception
net.sf.basedb.core.BaseException: could not delete: [net.sf.basedb.core.data.FileData#41839]
  at net.sf.basedb.core.HibernateUtil.flush(HibernateUtil.java:993)
  at net.sf.basedb.core.DbControl.commit(DbControl.java:387)
  at org.apache.jsp.views.trashcan.index_jsp._jspService(index_jsp.java:259)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  at net.sf.basedb.clients.web.servlet.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:72)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
  at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
  at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.ConstraintViolationException: could not delete: [net.sf.basedb.core.data.FileData#41839]
  at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2541)
  at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697)
  at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74)
  at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
  at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
  at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
  at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
  at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
  at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
  at net.sf.basedb.core.HibernateUtil.flush(HibernateUtil.java:989)
  ... 25 more
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "Files" violates foreign key constraint "fkf42e4513c391d3ee" on table "FileSetMembers"
  Detail: Key (id)=(41839) is still referenced from table "FileSetMembers".
  at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
  at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
  at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:305)
  at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
  at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2523)
... 34 more

Change History (3)

comment:1 Changed 14 years ago by Martin Svensson

Owner: changed from everyone to Martin Svensson
Status: newassigned

comment:2 Changed 14 years ago by Nicklas Nordborg

Owner: changed from Martin Svensson to Nicklas Nordborg
Status: assignednew

comment:3 Changed 14 years ago by Nicklas Nordborg

Resolution: fixed
Status: newclosed

(In [4006]) Fixes #844: File.isUsed() doesn't check if a file has been used in a FileSet?. References #721

Note: See TracTickets for help on using tickets.