OutOfMemoryError while collecting test output even when disabled
ZuluForce opened this issue · 1 comments
Description
I have a build where showStandardStreams
has the default value of false
. I get this error:
Caused by: java.lang.OutOfMemoryError: Java heap space
at com.adarshr.gradle.testlogger.logger.OutputCollector.removeTestOutput(OutputCollector.groovy:26)
at com.adarshr.gradle.testlogger.logger.SequentialTestLogger.afterTest(SequentialTestLogger.groovy:46)
at com.adarshr.gradle.testlogger.logger.TestLoggerAdapter.afterTest(TestLoggerAdapter.groovy:54)
at com.adarshr.gradle.testlogger.logger.TestLoggerWrapper.afterTest(TestLoggerWrapper.groovy:12)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:231)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:150)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:325)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:235)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy88.afterTest(Unknown Source)
at org.gradle.api.internal.tasks.testing.results.TestListenerAdapter.completed(TestListenerAdapter.java:50)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:231)
This appears to be caused by the toString
on the StringBuffer
consuming enough memory to push past the heap limits. Since the build has the collecting of standard streams disabled this is an unexpected failure. I think a simple solution would be to extend the checking of showStandardStreams
to the OutputCollector.collect
and simply leave the StringBuilder empty.
I can work around this by increasing the available heap but I'd prefer the test logger to have lower overhead when not asking for the extra features.
Versions
- Test logger version: 2.1.1 (although latest code appears to have same issue)
- Gradle version: 5.6.4
- Java version: 11.0.8
Type of test being run
Whether it is JUnit, Spock, TestNg, or anything else. Also, try to include a sample test here.
Test logger configuration
Everything is default so there is no explicit configuration in by gradle build file.
Additional information
Add any other information about the problem here.
Thanks for reporting this. This sounds bad and OutputCollector
shouldn't be in operation when showStandardStreams
is disabled.