This also refactors some test calls to mklink into a package-private Util method due to additional tests needing to create junction points.
Signed-off-by: Matt Sicker <boards@gmail.com>
The simplified form that this replaces has an issue where a file contained somewhere inside a symbolic link is also considered a symbolic link on Windows.
Signed-off-by: Matt Sicker <boards@gmail.com>
This removes duplicated tests from UtilTest that were added in PathRemoverTest. This also ports the sleep/gc strategy for use by default to preserve backward compatibility.
Signed-off-by: Matt Sicker <boards@gmail.com>
* Reduce memory footprint for the plugin info by presizing hashmaps to reduce waste for small maps and interning commonly duplicated plugin strings
* Replace duplicated empty string arrays with the one in MemoryReductionUtil
* Fix interning where strings are null
* Fix to deal with the fact that we directly mutate dependency fields for UpdateSite, sigh
* Reduce starting HashMap size for some hashmaps likely to be empty or tiny
* Cleanup per review comments
* Trim some extra waste out of the UpdateSite warnings
* Fix count of optional dependencies
* Move predicates for dependency matching to top-level static final field so they are not duplicated
- in case of migration we put null instead of now
- improve also the difference in days for the Xxx day(s) ago to take calendar day in difference and not the total duration (<24h = 0 days, which seems wrong in UI)
* 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)
* 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()
* Organize imports
* Use StandardCharsets
* Delete a redundant cast
* Replace use of _ as an identifier
_ is a keyword in Java 9.
* Use Logger message formatting
* Use fileToPath()
* Switch to using Files.createTempDirectory()
* Document that Util.touch() will truncate an existing file
* Replace an unnecessary use of Throwable.initCause()
* Implement deprecated copyStream() using IOUtils
* Copy to NULL_OUTPUT_STREAM
Also, closing source is moved to a finally block, to guarantee that it
will be closed per the documentation; it was technically possible for
the input stream to not be closed if construction of the MessageDigest,
DigestInputStream, or byte[] buffer failed for some reason (e.g. out of
memory).
* Delete an unnecessary try-with-resources
* Throw an IllegalArgumentException if data has odd length
Previously, a StringIndexOutOfBoundsException would be thrown, which is
less clear.
* Specify expanded POSIX file permissions