Skip to content
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

[JENKINS-4409] Disable URLConnection.useCache in tests on Windows #1572

Merged

Conversation

@ikedam
Copy link
Member

ikedam commented Feb 14, 2015

https://issues.jenkins-ci.org/browse/JENKINS-4409

Plugin tests on Windows leave %TEMP%\hudsonXXXXXXXXXXtmp with output like this (this doesn't affect test results):

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 62.997 sec - in hudson.plugins.copyartifact.BuildSelectorParameterTest
java.nio.file.FileSystemException: C:\Users\ikedam\AppData\Local\Temp\hudson7190248855254390892tmp\credentials\WEB-INF\lib\classes.jar: The process cannot access the file because it is being used by another process.

        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
        at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
        at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
        at java.nio.file.Files.delete(Files.java:1077)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at hudson.Util.deleteFile(Util.java:247)
        at hudson.Util.deleteRecursive(Util.java:310)
        at hudson.Util.deleteContentsRecursive(Util.java:212)
        at hudson.Util.deleteRecursive(Util.java:301)
        at hudson.Util.deleteContentsRecursive(Util.java:212)
        at hudson.Util.deleteRecursive(Util.java:301)
        at hudson.Util.deleteContentsRecursive(Util.java:212)
        at hudson.Util.deleteRecursive(Util.java:301)
        at hudson.Util.deleteContentsRecursive(Util.java:212)
        at hudson.Util.deleteRecursive(Util.java:301)
        at org.jvnet.hudson.test.TestPluginManager$1.run(TestPluginManager.java:146)

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

This is caused for localizer and sezpoz read streams from classes.jar and URLConnection doesn't release the handle to classes.jar even after they closed streams.

This change disables the caching by URLConnection in tests on Windows.

This is an alternate approach for kohsuke/localizer#9 and jglick/sezpoz#9.
This affects only tests on Windows, and never cause performance issues in production environments.
But I'm not sure disabling caching in URLConnection really cause performance issues.
I expect reviews by experts of performance.

If jglick/sezpoz#9 is merged to sezpoz, we no longer need this change.

…ws. It prevents deleting temporary directories when tests finish.
@@ -276,6 +277,8 @@
*/
protected File explodedWarDir;

private boolean origDefaultUseCache = true;

This comment has been minimized.

Copy link
@jglick

jglick Feb 23, 2015

Member

I generally do not bother patching HudsonTestCase any more, especially after most of its usages have already been fixed in core to be JenkinsRule, but since you have already done the work…

jglick added a commit that referenced this pull request Feb 23, 2015
…onnectionCache

[JENKINS-4409] Disable URLConnection.useCache in tests on Windows
@jglick jglick merged commit c8abbfc into jenkinsci:master Feb 23, 2015
1 check passed
1 check passed
Jenkins This pull request looks good
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.