You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/09/23 22:12:29 UTC
svn commit: r818235 - in /myfaces/trinidad/branches/1.2.12.1-branch:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/
Author: jwaldman
Date: Wed Sep 23 20:12:28 2009
New Revision: 818235
URL: http://svn.apache.org/viewvc?rev=818235&view=rev
Log:
TRINIDAD-1574 Caching broken in FileSystemStyleCache causing slow memory le
patch by Blake Sullivan
1.2.12.1-branch
Modified:
myfaces/trinidad/branches/1.2.12.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
myfaces/trinidad/branches/1.2.12.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Modified: myfaces/trinidad/branches/1.2.12.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java?rev=818235&r1=818234&r2=818235&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/AccessibilityProfile.java Wed Sep 23 20:12:28 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/branches/1.2.12.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=818235&r1=818234&r2=818235&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Wed Sep 23 20:12:28 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;