Commit Graph
203 Commits
Author SHA1 Message Date
Baptiste Mathus 5588df315d Add @since on Util.isSafeToRedirectTo() 2016-11-09 09:36:52 +01:00
Daniel Beck 72cb842b6c Cleaning up @since TODO / @since XXX 2016-10-15 23:22:20 +02:00
Oliver Gondža 7f6f495f86 Avoid deprecated findbugs annotations (#2144)
* Avoid deprecated findbugs annotations

* One more forgotten annotation
2016-10-15 12:53:56 -07:00
Nicolas De Loof 7b39424495 rely on try-with-resources 2016-10-03 15:12:48 +02:00
dbroady1 f4edf91782 [JENKINS-29956] Test Windows junctions before Java 7 symlink (#1787)
* 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
2016-08-22 15:21:33 +02:00
Oleg Nenashev 96c97860b0 [FIXED JENKINS-37332] - Prevent File descriptor leaks when reading manifests from JARs (#2516)
* [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
2016-08-21 00:00:41 +02:00
Oleg Nenashev 3c31cb9692 FindBugs: Suppress DM_GC in hudson.Util#pauseBetweenDeletes(), because it's a desired behavior for custom setting 2016-07-16 02:16:50 +03:00
Pavel Janousek b21ab921de [JENKINS-35570] List of computer's names extracted to Util (#2408)
* [JENKINS-35570] List of computer's names extracted to Util
2016-07-12 09:13:33 +02:00
Oleg Nenashev 1d2b15173c [JENKINS-34854] - Migrate missing settings to SystemProperties (#2362)
* [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
2016-05-21 09:36:18 +04:00
Oleg Nenashev ce8922bd74 Merge branch 'master' into JENKINS-34755
Conflicts:
	core/src/main/java/hudson/Util.java
	core/src/main/java/hudson/WebAppMain.java
	core/src/main/java/hudson/model/Item.java
	core/src/main/java/hudson/model/Queue.java
	core/src/main/java/hudson/model/UpdateCenter.java
	core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java
	core/src/main/java/hudson/slaves/NodeProvisioner.java
	core/src/main/java/jenkins/model/Jenkins.java
	core/src/main/java/jenkins/slaves/NioChannelSelector.java
	core/src/main/java/jenkins/util/xml/XMLUtils.java
2016-05-12 12:05:24 +02:00
Jesse Glick c2d0a5778e Merge commit '97a0fa0d036b9d3873c9b269123020a42e7ee3e9' into security-master 2016-05-11 12:07:25 -04:00
Daniel Beck 240405dfc3 Merge pull request #2026 from pjdarton/fix_jenkins_15331
[FIX JENKINS-15331] Windows file locking workaround
2016-05-04 01:32:27 +02:00
Jesse Glick 888ca85784 Merge branch 'security-stable-1.651' into security-master 2016-04-28 17:38:40 -04:00
Jesse Glick 11120802c1 Merge branch 'security-stable-1.625' into security-stable-1.642 2016-04-28 17:37:52 -04:00
Jesse Glick c88268d870 Merge branch 'security-stable-1.609' into security-stable-1.625 2016-04-28 17:36:42 -04:00
Daniel Beck e6efae7d0d [SECURITY-276] Better method name, add tests 2016-04-27 13:51:10 +02:00
Daniel Beck 2ed0c046df [FIX SECURITY-276] Don't allow open redirect using scheme-rel. URL 2016-04-25 19:50:53 +02:00
Baptiste Mathus 99c43c8ccd Remove pre Java 7 reflection's based invocations
Simplify the code now the minimum version is Java 7.
2016-04-13 23:09:22 +02:00
Baptiste Mathus 8b3e4f43a2 Multi-catch refactoring when applicable 2016-04-12 10:17:42 +02:00
Peter Darton 879f0556e3 Renamed system property from ...deletionMax to ...maxFileDeletionRetries (as requested during code review). 2016-02-15 10:44:38 +00:00
Peter Darton 310c674762 FIXED JENKINS-15331 by changing Util.deleteContentsRecursive, Util.deleteFile and Util.deleteRecursive so that they can retry failed deletions.
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.
2016-02-12 16:22:35 +00:00
Johannes Ernst 9303136c9d Incorporated pull request feedback:
* moved to jenkins.util.SystemProperties
* consistent naming getString/getInteger/getBoolean
* improved code formatting
Improved JavaDoc
2015-11-18 18:26:41 +00:00
Johannes Ernst 709fe5b9aa Allow setting of system properties from context.xml in addition to setting from command-line.
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)
2015-11-17 01:38:51 +00:00
Antonio Muñiz 89a0050cea [JENKINS-30002] Improve Util.isOverridden 2015-10-05 10:13:42 +02:00
David Hoover 1709ed3a2e Add @Deprecated annotations to things documented as @deprecated. 2015-04-19 14:50:12 -07:00
Stephen Connolly 77abe1d11c tidy up @since tags after merge 2015-03-20 16:56:53 +00:00
Stephen Connolly 1cb69f8cc0 Move isRelativePath to Util and use from hudson.model.Slave's descriptor 2015-03-19 13:56:38 +00:00
Daniel Beck daacb02057 [JENKINS-16184] Also escape greater-than character 2014-10-09 00:38:22 +02:00
Oleg Nenashev 6c2fffb248 Fixed annotations in hudson/Util.java according to the discussion with @jglick and @kutzi
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
2014-05-05 22:26:12 +04:00
Oleg Nenashev 48cc7e03d4 Annotate hudson.Util methods.
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>
2014-05-04 12:39:02 +04:00
Marco Miller d0f84c2e53 [FIXED JENKINS-20610] symlink FileAlreadyExistsException
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.
2013-11-15 16:32:27 -05:00
Jesse Glick c2366eeda5 Updated a couple of comments referring to Java 5. 2013-11-15 08:46:14 -05:00
Jesse Glick 4825967fe3 Deleting code using @IgnoreJRERequirement for Java 5 compatibility. 2013-11-15 08:43:40 -05:00
Jesse Glick 15ac490af1 Now that we use Java 6, can finally deprecate IOException2. 2013-11-15 08:19:59 -05:00
Larry North 3376cf0158 [FIXED JENKINS-16660] Allow variable names with dots in bracketed references.
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.
2013-07-26 21:15:51 -07:00
Jesse Glick 11953750ab [[JENKINS-16301] Use a buffered input stream to get somewhat better performance also from Maven archiving.
Introducing Util.getDigestOf(File) as a convenience.
2013-07-24 16:30:48 -04:00
Jesse Glick e0a3a1ddf5 [FIXED JENKINS-18178] Reverting an inessential part of the fix of JENKINS-16301 since it broke some Maven builds.
Apparently the Maven 2 process factory fails to adequately insulate the Maven process from Jenkins library dependencies;
if you specify a build extension that can override dependencies used by Jenkins core classes!
A real fix would involve changing class loader delegation, since presumably similar bugs could still occur.
2013-07-24 16:22:48 -04:00
Jesse Glick a0ff0b2f76 Typo in Javadoc. 2013-07-24 14:56:09 -04:00
Jesse Glick 7f966f6f31 [FIXED JENKINS-18351] Better fix for file handle leak. 2013-06-14 18:11:14 -04:00
Jesse Glick b1c82f1e30 stephenc asks to use TODO rather than XXX 2013-06-10 11:53:13 -04:00
Jesse Glick 2a1d1631bd [FIXED JENKINS-14351] jna-posix → jnr-posix upgrade (opt in). 2013-05-31 14:36:15 -04:00
Jesse Glick 51fbd2d867 [JENKINS-16301] Replace impl of getDigestOf with standard (Commons Codec) DigestUtils.md5Hex, for simplicity. 2013-05-21 17:41:39 -04:00
Jesse Glick 3c2b50ecfe [FIXED JENKINS-17681] Do not try to call resolveSymlink on a nonexistent link as you will just get an IOException, breaking peephole permalinks in some Windows environments. 2013-05-01 20:13:18 -04:00
Kohsuke Kawaguchi 368d8c7394 Don't let the error icon get clipped when the text is short.
On Chrome (and possibly others), an inline element like span doesn't enlarge
its size to cover its content, so the 1px place holder wasn't taking effect.

To ensure the minimum height of 16px, make it an inline-block element. I'm
not entirely sure how an inline-block element with no fixed width would behave,
but with a bit of casual testing, the text inside seems to wrap OK.
2013-04-19 10:11:28 -07:00
Kohsuke Kawaguchi b27bc585a8 merged back the RC branch 2013-04-06 18:58:00 -07:00
Kohsuke Kawaguchi dc94b7d063 [FIXED JENKINS-8686]
As I mentioned in the comment, I doubt if this makes any behaviour change, but this seems like a sensible defensive measure that wouldn't hurt.
2013-04-02 09:58:50 -07:00
Kohsuke Kawaguchi a016f3da07 [FIXED JENKINS-17343]
Don't break Windows XP, fall back gracefully to no-op.
2013-04-02 09:27:09 -07:00
Jesse Glick 21912fe3dd @code in Javadoc. 2013-03-28 14:53:54 -04:00
Jesse Glick 78b263421f [FIXED JENKINS-17271] Util.deleteFile should give a concrete reason for failure. 2013-03-19 11:05:21 -04:00
Jesse Glick 606a9e1de9 File.setWritable should be the first, and if possible only, thing we try for makeWritable. 2013-03-19 10:13:19 -04:00