Author: jalkanen
Date: Sun Jun 29 23:45:24 2008
New Revision: 672715
URL: http://svn.apache.org/viewvc?rev=672715&view=rev
Log:
JSPWIKI-299: Deleting an attachment from a page which had been recently renamed
caused an NPE. Reported by Harry Metske.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=672715&r1=672714&r2=672715&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Jun 29 23:45:24 2008
@@ -1,3 +1,11 @@
+2008-06-30 Janne Jalkanen <[EMAIL PROTECTED]>
+
+ * 2.7.0-svn-52
+
+ * JSPWIKI-299: Deleting an attachment from a page which
+ had been recently renamed caused an NPE. Reported by Harry
+ Metske.
+
2008-06-29 Janne Jalkanen <[EMAIL PROTECTED]>
* Moved all pages from wikipages under wikipages/en, and
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=672715&r1=672714&r2=672715&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sun Jun 29
23:45:24 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "51";
+ public static final String BUILD = "52";
/**
* This is the generic version string you should use
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java?rev=672715&r1=672714&r2=672715&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/providers/CachingAttachmentProvider.java
Sun Jun 29 23:45:24 2008
@@ -31,6 +31,7 @@
import com.ecyrd.jspwiki.attachment.AttachmentManager;
import com.ecyrd.jspwiki.util.ClassUtil;
import com.opensymphony.oscache.base.Cache;
+import com.opensymphony.oscache.base.CacheEntry;
import com.opensymphony.oscache.base.NeedsRefreshException;
import com.opensymphony.oscache.base.events.*;
@@ -419,6 +420,21 @@
m_provider.moveAttachmentsForPage(oldParent, newParent);
m_cache.removeEntry( newParent );
m_cache.removeEntry( oldParent );
+
+ //
+ // This is a kludge to make sure that the pages are removed
+ // from the other cache as well.
+ //
+ String checkName = oldParent + "/";
+
+ Collection<String> names = cloneCollection(
m_allCollector.m_allItems.keySet() );
+ for( String name : names )
+ {
+ if( name.startsWith( checkName ) )
+ {
+ m_attCache.removeEntry( name );
+ }
+ }
}
/**
@@ -456,11 +472,17 @@
{
log.debug( "attachment cache entry removed: " +
aEvent.getKey() );
}
- Attachment item = (Attachment) aEvent.getEntry().getContent();
-
- if( item != null )
+
+ CacheEntry e = aEvent.getEntry();
+
+ if( e != null )
{
- m_allItems.remove( item.getName() );
+ Attachment item = (Attachment) e.getContent();
+
+ if( item != null )
+ {
+ m_allItems.remove( item.getName() );
+ }
}
}
}