-
Notifications
You must be signed in to change notification settings - Fork 31
Add test for grabbed class cleanup after Pipeline completion #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/test/java/org/jenkinsci/plugins/workflow/libs/LibraryMemoryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jenkinsci/plugins/workflow/libs/LibraryMemoryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jenkinsci/plugins/workflow/libs/LibraryMemoryTest.java
Outdated
Show resolved
Hide resolved
| // is first initialized by a Pipeline that uses @Grab, the grabbed classes will be available when | ||
| // BulkFlowNodeStorage.XSTREAM2 is instantiated, causing them to be strongly retained. | ||
| // Specifically com.thoughtworks.xstream.converters.extended.DurationConverter and org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl cause problems. | ||
| // TODO: Should we add an @Initializer to BulkFlowNodeStorage.XSTREAM to avoid this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this to have the field loaded at a consistent time during startup, but as-is, at worst this will only leak resources from a single build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/test/java/org/jenkinsci/plugins/workflow/libs/LibraryMemoryTest.java
Outdated
Show resolved
Hide resolved
| clearInvocationCaches.setAccessible(true); | ||
| clearInvocationCaches.invoke(metaClass); | ||
|
|
||
| // TODO: GrapeIvy's $callSiteArray softly references the class that most recently used @Grab. I have not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words, if you change line 115 to for (int i = 0; i < 10; i++) r.buildAndAssertSuccess(p);, only the final build will be softly referenced by GrapeIvy's CallSiteArray and the others will be cleaned up promptly. So as far as real-world usage, at worst I think this would be a single-build leak.
| } | ||
| } | ||
|
|
||
| @Test public void loaderReleasedWithGrab() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without jenkinsci/workflow-cps-plugin#1086, this test either passes very slowly, or fails, depending on whether or not the SoftReference is cleared prior to an OutOfMemoryError. With jenkinsci/jenkins-test-harness#1029 the failure becomes consistent.
With jenkinsci/workflow-cps-plugin#1086, the test passes quickly.
See jenkinsci/workflow-cps-plugin#1086.
Testing done
See new automated test.
Submitter checklist