You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/08/02 19:18:00 UTC
[jira] [Commented] (TAP5-2687) Streamable Resource doesn't
implement equals/hashCode
[ https://issues.apache.org/jira/browse/TAP5-2687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17391775#comment-17391775 ]
ASF subversion and git services commented on TAP5-2687:
-------------------------------------------------------
Commit e4defd2ae1d20e6e1bbd84099e6b1373b722ebe4 in tapestry-5's branch refs/heads/master from Thiago H. de Paula Figueiredo
[ https://gitbox.apache.org/repos/asf?p=tapestry-5.git;h=e4defd2 ]
TAP5-2687: optimize AssetChecksumGeneratorImpl
to avoid storing whole StreamableResource instances in its cache. In
addition, use computeIfAbsent() instead of put() to avoid the
possibility of duplicate entries in the cache.
Also:
* StreamableResourceImpl now implements hashCode() and equals()
* ContentType used to implement just equals() and now implements
hashCode()
> Streamable Resource doesn't implement equals/hashCode
> -----------------------------------------------------
>
> Key: TAP5-2687
> URL: https://issues.apache.org/jira/browse/TAP5-2687
> Project: Tapestry 5
> Issue Type: Bug
> Reporter: Alex Craddock
> Priority: Critical
>
> We use AssetChecksumGeneratorImpl to cache the file assets. I have found an issue where two seemingly identical resources are storing two copies of the same item in the cache.
>
> I believe this is down to having two different StreamableResources which are equal based on the fields but when you try to use .hashMap on them they are not seen as equal (which I believe ConcurrentHashMap.get uses equals)
>
> {code:java}
> // code placeholder
> package com.pubfactory.hk.web.services;
> import org.apache.tapestry5.http.ContentType;
> import org.apache.tapestry5.internal.services.assets.StreamableResourceImpl;
> import org.apache.tapestry5.services.assets.CompressionStatus;
> public class Test {
> public static void main(String [] args) {
> StreamableResourceImpl streamableResource = new StreamableResourceImpl("description", new ContentType("application/json"), CompressionStatus.COMPRESSABLE,123456l,
> null, null, null);
> StreamableResourceImpl streamableResource2 = new StreamableResourceImpl("description", new ContentType("application/json"), CompressionStatus.COMPRESSABLE,123456l,
> null, null, null);
> System.out.print(streamableResource.hashCode() == streamableResource2.hashCode());
> }
> }
> {code}
> I wrote a test, which produces false when I would expect it to be true.
>
> This is causing a memory leak on our sites. I monitored the AssetChecksumGeneratorImpl cache and it has gone from 1G in size to over 2G due to duplicate objects in the cache.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)