Hi Sergiu, Cool you fixed this. See below. On Apr 25, 2008, at 1:41 AM, sdumitriu (SVN) wrote:
Author: sdumitriu Date: 2008-04-25 01:41:36 +0200 (Fri, 25 Apr 2008) New Revision: 9363
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ doc/XWikiAttachment.java Log: XWIKI-2336: Broken attachments can break working with a document XWIKI-1937: importing a document with attachments over an existing document fails Done.
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/ xwiki/doc/XWikiAttachment.java =================================================================== --- xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ doc/XWikiAttachment.java 2008-04-24 21:10:23 UTC (rev 9362) +++ xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/ doc/XWikiAttachment.java 2008-04-24 23:41:36 UTC (rev 9363) @@ -48,7 +48,7 @@ public class XWikiAttachment { private static final Log LOG = LogFactory.getLog(XWikiAttachment.class); - + private XWikiDocument doc;
private int filesize; @@ -489,15 +489,25 @@
public void loadContent(XWikiContext context) throws XWikiException { - if (attachment_content == null) - context.getWiki().getAttachmentStore().loadAttachmentContent(this, context, true); + if (attachment_content == null) { + try { + context.getWiki().getAttachmentStore().loadAttachmentContent(this, context, true); + } catch (Exception ex) { + LOG.error("Failed to load content for attachment [" + getFilename() + "]", ex);
I think we should always explain what is going to happen and what state the system is in when we log an error and we carry on without stopping the action. Can we add some comment in the log that explains what it means? The user will see a big stack trace and he'll wonder what he has to do to fix it. What can we tell him? OTOH if there's nothing he should do then we shouldn't show a stack trace, only a warning with no trace.
+ } + } }
public XWikiAttachmentArchive loadArchive(XWikiContext context) throws XWikiException { if (attachment_archive == null) { - attachment_archive = context.getWiki().getAttachmentVersioningStore() - .loadArchive(this, context, true); + try { + attachment_archive = + context.getWiki().getAttachmentVersioningStore().loadArchive(this, context, + true); + } catch (Exception ex) { + LOG.error("Failed to load archive for attachment [" + getFilename() + "]", ex); + }
Same here. Thanks -Vincent