albfernandez / richfaces

RichFaces - JSF component framework
GNU Lesser General Public License v2.1
16 stars 7 forks source link

org.richfaces.resource.ResourceUtils causing OutOfMemoryError #77

Closed vagaone closed 1 year ago

vagaone commented 1 year ago

Hi,

my Server is randomly getting (all few Weeks) OutOfMemory Errors.

I tracked the stacktrace (below) down a bit and think, the ResourceUtils are causing this issue. ResourceUtils use the java.util.zip.Deflater, which seems to cause this error. See this Entry: https://stackoverflow.com/questions/13559258/strange-java-lang-outofmemoryerror-from-java-util-zip-inflater-initnative-metho

I am aware that you are using the the correct .end() call to avoid this bug, but somehow it still occurs for me.

Used RichFaces version is 4.6.20.ayg.

If more info is needed, the full stacktrace or something else, please let me know.

P.S.: I really appreciate your work here and thank you very much for looking into this issue.

Here is the Caused by part of the Stacktrace:

Caused by: java.lang.reflect.InvocationTargetException at jdk.internal.reflect.GeneratedMethodAccessor151.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at deployment.web-3.20.5.war//org.richfaces.application.ServiceTracker$1.invoke(ServiceTracker.java:153) ... 151 more Caused by: java.lang.OutOfMemoryError at java.base/java.util.zip.Deflater.init(Native Method) at java.base/java.util.zip.Deflater.(Deflater.java:208) at java.base/java.util.zip.Deflater.(Deflater.java:217) at deployment.web-3.20.5.war//org.richfaces.resource.ResourceUtils.encrypt(ResourceUtils.java:184) at deployment.web-3.20.5.war//org.richfaces.resource.ResourceUtils.encodeBytesData(ResourceUtils.java:230) at deployment.web-3.20.5.war//org.richfaces.resource.DefaultResourceCodec.encodeResourceRequestPath(DefaultResourceCodec.java:88) at deployment.web-3.20.5.war//org.richfaces.resource.AbstractBaseResource.getRequestPath(AbstractBaseResource.java:155) at deployment.web-3.20.5.war//org.richfaces.resource.mapping.ResourceServletMapping.getResourcePath(ResourceServletMapping.java:101) at deployment.web-3.20.5.war//org.richfaces.resource.mapping.ResourceServletMapping.getMappedPath(ResourceServletMapping.java:86) at deployment.web-3.20.5.war//org.richfaces.resource.mapping.ResourceServletMapping.getResourcePath(ResourceServletMapping.java:72) at deployment.web-3.20.5.war//org.richfaces.resource.external.MappedResourceFactoryImpl.createResource(MappedResourceFactoryImpl.java:112) ... 155 more

albfernandez commented 1 year ago

I'm not sure if this will fix the bug, but it's always a good idea to put end and close methods in a finally block to ensure resources are free.

I've just released a new version, can you try it?

vagaone commented 1 year ago

Hey, thank you. Yes i will give it a try, but it will take some time, as the error only occured randomly after a few days / weeks.