[ https://issues.apache.org/jira/browse/TAP5-2687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17392419#comment-17392419 ]
Alex Craddock commented on TAP5-2687: ------------------------------------- A second note, this could lead to a memory issue, much slower memory issue with the updated code, but there could still be one. > 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 > Attachments: Screenshot 2021-08-03 at 16.52.44.png > > > 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)