You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2010/10/11 22:10:20 UTC
svn commit: r1021492 - in
/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src:
main/java/org/apache/jetspeed/components/portletregistry/
test/java/org/apache/jetspeed/components/portletregistry/
Author: woonsan
Date: Mon Oct 11 20:10:19 2010
New Revision: 1021492
URL: http://svn.apache.org/viewvc?rev=1021492&view=rev
Log:
JS2-1221: Fixing a bug of wrong usage on CacheElement with a unit test showing the exception case.
Modified:
portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java
portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java
portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java?rev=1021492&r1=1021491&r2=1021492&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java Mon Oct 11 20:10:19 2010
@@ -149,10 +149,18 @@ public class RegistryApplicationCache im
RegistryCacheObjectWrapper wrapper = w;
if (wrapper == null)
{
- wrapper = (RegistryCacheObjectWrapper)nameCache.get(key);
- if (wrapper == null)
- return;
+ CacheElement cacheElement = nameCache.get(key);
+ if (cacheElement != null)
+ {
+ wrapper = (RegistryCacheObjectWrapper) cacheElement.getContent();
+ }
}
+
+ if (wrapper == null)
+ {
+ return;
+ }
+
Identity oid = wrapper.getId();
PortletApplication pd = (PortletApplication)cacheLookup(oid);
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java?rev=1021492&r1=1021491&r2=1021492&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java Mon Oct 11 20:10:19 2010
@@ -148,10 +148,18 @@ public class RegistryPortletCache implem
RegistryCacheObjectWrapper wrapper = w;
if (wrapper == null)
{
- wrapper = (RegistryCacheObjectWrapper)nameCache.get(key);
- if (wrapper == null)
- return;
+ CacheElement cacheElement = nameCache.get(key);
+ if (cacheElement != null)
+ {
+ wrapper = (RegistryCacheObjectWrapper) cacheElement.getContent();
+ }
}
+
+ if (wrapper == null)
+ {
+ return;
+ }
+
Identity oid = wrapper.getId();
PortletDefinition pd = (PortletDefinition)cacheLookup(oid);
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java?rev=1021492&r1=1021491&r2=1021492&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java Mon Oct 11 20:10:19 2010
@@ -25,14 +25,16 @@ import org.apache.jetspeed.components.ut
import org.apache.jetspeed.engine.MockJetspeedEngine;
import org.apache.jetspeed.om.portlet.InitParam;
import org.apache.jetspeed.om.portlet.Language;
-import org.apache.jetspeed.om.portlet.Supports;
-import org.apache.jetspeed.om.portlet.UserAttribute;
-import org.apache.jetspeed.om.portlet.Preference;
-import org.apache.jetspeed.om.portlet.Preferences;
import org.apache.jetspeed.om.portlet.PortletApplication;
import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.om.portlet.Preferences;
+import org.apache.jetspeed.om.portlet.Supports;
+import org.apache.jetspeed.om.portlet.UserAttribute;
import org.apache.jetspeed.om.portlet.UserAttributeRef;
import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl;
+import org.apache.ojb.broker.Identity;
/**
* <p>
@@ -93,6 +95,20 @@ public class TestRegistryCache extends D
assertEquals(portletRegistry.getAllPortletDefinitions().iterator().next(), def);
}
+ public void testCacheDirectly() {
+ assertNotNull(portletRegistry);
+ PortletDefinition def = portletRegistry.getPortletDefinitionByUniqueName("PA-001::Portlet-1");
+ assertNotNull(def);
+
+ Identity testPortletDefOid = new Identity(PortletDefinitionImpl.class, PortletApplicationDefinitionImpl.class, new Object [] { "PA-001::Portlet-1" });
+ RegistryPortletCache.cacheAdd(testPortletDefOid, def);
+ assertNotNull(RegistryPortletCache.cacheLookup(testPortletDefOid));
+ assertEquals(def, RegistryPortletCache.cacheLookup(testPortletDefOid));
+
+ RegistryPortletCache.cacheRemoveQuiet(def.getUniqueName(), null);
+ assertNull(RegistryPortletCache.cacheLookup(testPortletDefOid));
+ }
+
private void buildTestData() throws RegistryException, LockFailedException
{
String lang = Locale.getDefault().toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org