* Fix a race condition in Util.loadFile()
If the file is deleted in between when its existence is checked and the
file is opened for reading, then the method will fail to return an empty
string.
* Switch to using FileUtils.readFileToString()
(cherry picked from commit aaae71af4b)
* [JENKINS-49112] Revert use of Files.newBufferedReader() in Util.loadFile()
This partially reverts 67076834a2.
* Restore the use of StringBuilder and reading into buf
* Use NIO in tryOnceDeleteFile and makeWritable
* Don't try to set PosixFileAttributes on Windows
* Do not create arbitrary exceptions in makeWritable to fix test failures on Windows
* Remove unhelpful layer of exception wrapping
* Add test exercising Util#makeWritable in Util#tryOnceDeleteFile
* Add test for deleting a non-existant file
* Return early if changing permissions with NIO succeeds
* Use NIO for FilePath#chmod and IOUtils#mode
* Add tests for NIO mode and chmod implementations
* Add test, remove new method, and update JavaDoc
* Provide system property to use native implementations of chmod and mode
* Revert unrelated whitespace modification
* Don't remove exception from throws and put imports in original location
* Fix broken JavaDoc links
* Ignore file type bits (above 0o7777) in Util#modeToPermission
* Use octal for constants and don't include file type bits
* Revert unnecessary changes to TarArchiverTest
* Add assertion that non-permission bits are ignored by chmod
* Use NIO copy with StandardCopyOption.COPY_ATTRIBUTES in copyToWithPermissions where possible
* Catch InvalidPathException and convert it to IOException
* Create utility method for File#toPath and use File#createDirectories after review
* Remove useless calls to toAbsolutePath and getAbsoluteFile
* Fix typos and use octal for constant after review
* Add test for behavior of copyToWithPermission with special bits
* Always use NIO to detect symlinks
* Make assertion failure message consistent
* Catch NoSuchFileException to keep tests passing
* Make method name more specific and simlify assumption
* Remove obsolete comment and reword the main comment in isSymlink
* Deprecate Kernel32Util#isJunctionOrSymlink
* Use assumptions for junction creation and add messages to assumptions
* Replace deprecated code with recommended alternative
* Add comment explaining call to DosFileAttributes#isOther
* Do not fall back to native code when creating symlinks
* Log FileSystemExceptions when creating symbolic links
* Catch InvalidPathException and rethrow as IOException
* Deprecate Kernel32Utils#createSymbolicLink and #getWin32FileAttributes
* Preserve original logging behavior on Windows and remove useless call to Util#displayIOException
* A test to verify JENKINS-44657 is working in core
* [JENKINS-44657] Move sub-job's buildsdir when outside of itemrootdir.
* [JENKINS-44657] Fix UsageStatisticsTest
Because we've added a test dependency that affects it.
* [JENKINS-44657] Normalize the path before comparing
* [JENKINS-44657] Use MockFolder instead of folders-plugin
for tests
* [JENKINS-44657] Document and annotate isDefaultBuildDir
* [JENKINS-44657] isDescendant doesn't throw IOException any more
* [JENKINS-44657] catch InvalidPathException and rethrow as IOException
* Clean up usages of IOUtils.closeQuietly and related calls predating Java 7.
* Review comments from @oleg-nenashev.
* Noticed another place where try-with-resources would protect against a potential leak.
* Test Windows junctions before Java 7 symlink
Apparently Java 7 (and later) do not count Windows junctions as
symlinks. When you drill down into the BasicFileAttributes structure,
reparse points are only counted under isOther. So, since we already
have code that properly detects Windows Junctions, let's use that first
and then fallback to the Java 7 code.
* Add comment for change & link bug.
* Add test case
* Switch to Functions.isWindows().
* Use non-deprecated APIs for tmp file/dir mgmt
* Add better debugging.
* Allow spaces in junction name & dir name.
To do that, it was easier to use ProcessBuilder vs building up the correct
string in code to send to cmd.exe.
Also, I'll note that according to http://ss64.com/nt/syntax-internal.html,
mklink is in internal cmd.exe command. So, it must be invoked through
"cmd.exe /c" for it to work.
* Remove comment mentioning bug number.
* Remove debugging output, per Baptiste's request
* Add newline at end of file.
* Make sure that the junction was removed.
* Use assertEquals to show retcode of Process.waitFor.
* Fix compilation errors by importing functions
* [JENKINS-37332] - Improve diagnostics of non-closed streams during reading of the manifests in PluginManager
* [JENKINS-37332] - Leakless processing of JarUrlConnection during Manifest parsing
* [JENKINS-37332] - Also implement leak-safe method for retrieving file modification date
* [JENKINS-37332] - Add spotcheck methods for manifest file access + Javadoc
* [JENKINS-37332] - Also test multi-line and empty attributes in the test
* [JENKINS-34854] - Migrate missing Integer and Boolean properties to SystemProperties
* [JENKINS-34854] - API methods for Long variables
* [JENKINS-34854] - Migrate Long settings to SystemProperties
* [JENKINS-34854] - Leftover change (I should use Save All)
* [JENKINS-34854] - Some fixes in Long methods Javadoc and log messages
The number of deletion attempts and the time it waits between deletes are configurable via system properties (like hudson.Util.noSymlink etc).
Util.DELETION_MAX is set by -Dhudson.Util.deletionMax. Default is 3 attempts.
Util.WAIT_BETWEEN_DELETION_RETRIES is set by -Dhudson.Util.deletionRetryWait. Defaults is 100 milliseconds.
Util.GC_AFTER_FAILED_DELETE is set by -Dhudson.Util.performGCOnFailedDelete. Default is false.
Added unit-tests for new functionality.
Accomplished by centralizing calls to System.getProperty(String) and related into new file SystemProperties.java.
There, we first check for existence of system property; if not, we look for property in context.xml
This is done for "application" properties (like hudson.DNSMultiCast.disabled) but not for java properties (like user.name)
The change adds annotations for all methods inside the class. The initial idea - enforce checks of symlink methods to prevent NPEs on Windows platforms.
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
Retrying 3 times while waiting for 100 millis between retries (at
recreating symlink after "deleting" it). Ends up throwing FAE exception
if thrown for a 4th time in a row - as not much can be done at that
point. A warning is logged in that case, prior to throwing the last FAE.
Given these <variable,value> mappings: <A,a> and <A.B,a-b>, $A.B would
evaluate to $a.B, as it currently does, and ${A.B} to a-b instead of the
current ${A.B}.
Existing ${A.B}-like references will break (not evaluate to ${A.B}) if
there actually is an A.B variable defined, which I think is very
unlikely.