myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r818240 - in /myfaces/trinidad/trunk: trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Date Wed, 23 Sep 2009 20:27:41 GMT
Author: jwaldman
Date: Wed Sep 23 20:27:41 2009
New Revision: 818240

URL: http://svn.apache.org/viewvc?rev=818240&view=rev
Log:
TRINIDAD-1574 Caching broken in FileSystemStyleCache causing slow memory leak
patch by Blake Sullivan
trunk

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java?rev=818240&r1=818239&r2=818240&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
Wed Sep 23 20:27:41 2009
@@ -127,6 +127,31 @@
     return (_fontSize == FontSize.LARGE);
   }
   
+  @Override
+  public final int hashCode()
+  {
+    return _hashCode;
+  }
+  
+  @Override
+  public boolean equals(Object o)
+  {
+    if (this == o)
+      return true;
+    else if (o instanceof AccessibilityProfile)
+    {
+      AccessibilityProfile otherProfile = (AccessibilityProfile)o;
+      
+      return (_hashCode == otherProfile._hashCode) &&
+              _colorContrast.equals(otherProfile._colorContrast) &&
+              _fontSize.equals(otherProfile._fontSize);
+    }
+    else
+    {
+      return false;
+    }
+  }
+  
   // No need to support subclassing yet, so keep the constructor private.
   // Clients should use the getInstance() factory method.
   private AccessibilityProfile(
@@ -136,6 +161,7 @@
   {
     _colorContrast = (colorContrast == null) ? ColorContrast.STANDARD : colorContrast;
     _fontSize = (fontSize == null) ? FontSize.MEDIUM : fontSize;
+    _hashCode = _colorContrast.hashCode() * 37 + _fontSize.hashCode();
   }
 
   //Serialization for SerializableAccessibilityProfile internal subclass requires no-arg
constructor
@@ -147,6 +173,10 @@
 
   private final ColorContrast _colorContrast;
   private final FontSize      _fontSize;
+  
+  // hashCode could be transient, but then we would have to recalculate it when deserializing
+  // and it couldn't be final
+  private final int           _hashCode;
 
   // Default instance
   private static final AccessibilityProfile _sDefaultInstance =

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=818240&r1=818239&r2=818240&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Wed Sep 23 20:27:41 2009
@@ -1257,19 +1257,19 @@
       if ((o.hashCode() == hashCode()) &&  (o instanceof Key))
       {
         Key key = (Key)o;
+        
         // Check the easy stuff first
-        if  (!((_short == key._short)             &&
-               (_portlet == key._portlet)         &&
-               (_direction == key._direction)     &&
-               (_browser == key._browser)         &&
-               (_platform == key._platform)))
-          {
-              return false;
-          }
-
-          if (_version != null && !(_version.equals(key._version)))          return
false;
-          if (_locale != null && !(_locale.equals(key._locale)))             return
false;
-          if (_accProfile != null && !(_accProfile.equals(key._accProfile))) return
false;
+        if  ((_short == key._short)             &&
+             (_portlet == key._portlet)         &&
+             (_direction == key._direction)     &&
+             (_browser == key._browser)         &&
+             (_platform == key._platform))
+        {
+          // now check the optional objects
+          if ((_version == null) || _version.equals(key._version))
+            if ((_locale == null) || _locale.equals(key._locale))
+              return ((_accProfile == null) || _accProfile.equals(key._accProfile));
+        }
       }
 
       return false;



Mime
View raw message