- Code that is running from a plugin and on the master's JVM is guaranteed to never get null from this method (any cases where you do get null are bugs in core)
- Code that is running from a plugin and on a remote JVM should never be allowed to load the Jenkins class in their classloader, so should never use Jenkins.getInstance()... we are annotating the method with @Nullable so that such code can have some evolution time
- Code that is running in core and on one of two special paths should use the Jenkins.getInstanceOrNull() method so that the UI can be presented to users before the singleton has been instantiated / after the singleton has been destroyed
- The remaining 95% of uses in core (and 100% of uses in plugins) can safely assume that the instance is never null
This reverts commit bb7c8fcedb.
Closes#2090, I'll redo this as a PR... though if that PR is subject to multiple rounds of review before being merged then I will take that of evidence of the exact problem that committing directly was supposed to resolve... namely exponentially multiplying the effort required to make actual improvements to the code base.
- It is never too late to do the right thing.
- The vast majority of usages of `Jenkins.getInstance()` in core currently assume that its return value is non-null
- This commit changes those that are written to correctly check for non-null values will call `Jenkins.getInstanceOrNull()`
- We deprecate the `Jenkins.getActiveInstance()` madness
- I checked with @kohsuke who said not to bother with a PR and just commit this strongly opinionated change direct to master as a PR will just degrade into a bikeshedding.
Otherwise get a meaningless error:
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:267)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:44)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:915)
at jenkins.model.Jenkins.<init>(Jenkins.java:814)
at hudson.model.Hudson.<init>(Hudson.java:83)
at hudson.model.Hudson.<init>(Hudson.java:79)
at hudson.WebAppMain$3.run(WebAppMain.java:225)
A truly conforming servlet 3.0 container does not allow us to set "secure cookie" flag beyond ServletContextListener.onInitialized().
If we see that, don't scare the users.
* origin/master: (28 commits)
Need to run install during prepare, or else the release:perform fails miserably.
Enabled more convenient access to the XSTREAM field
added a method to help plugins rename classes and still keep backward compatibility
Rely on released versions
Test files accidentally crept in.
modified to use the type-safe tag lib interface.
Hooking the taglib interface generation.
[JENKINS-9326] add integration tests with eclipse tycho relocation
experimenting with the taglib interface generator
fixed NPE
Converted a few more pages into Groovy to test the behaviour. Allow global.jelly to be written in Groovy.
Jenkins
auto-completes instance and descriptor
Support global.groovy as well as config.groovy
A few more Jelly files switched to Groovy as a test
Looks like a dead code.
added DSLD for Eclipse
1.166 shipped
not specifying the file extension so that different pieces can be implemented by different view technologies
replaced i18n by '_' since it shows up a lot.
...
Conflicts:
core/src/main/java/hudson/model/Hudson.java
Honor $JENKINS_HOME (just like we used to do $HUDSON_HOME)
We still fall back to $HUDSON_HOME every step of the way
for maximum backward compatibility.
I wasn't initially planning to do this for the first version,
but working on native packages made me think we should deliver this.
This reverts commit becb2768bd.
Conflicts:
core/src/main/java/hudson/init/InitializerFinder.java
core/src/main/java/hudson/matrix/AxisList.java
While looking at PollingResult I noticed that import statements used in
javadoc are removed.
https://www.dev.java.net/svn/hudson/branches/rc
........
r16380 | kohsuke | 2009-03-19 17:10:38 -0700 (Thu, 19 Mar 2009) | 1 line
PeriodicWork change broke the tests, because the timer registration wasn't kicking in
........
r16381 | kohsuke | 2009-03-19 17:33:14 -0700 (Thu, 19 Mar 2009) | 1 line
fixed a test so that it's no longer timing sensitive
........
r16433 | kohsuke | 2009-03-20 18:35:55 -0700 (Fri, 20 Mar 2009) | 1 line
[maven-release-plugin] prepare release hudson-1_293
........
r16435 | kohsuke | 2009-03-20 18:36:21 -0700 (Fri, 20 Mar 2009) | 1 line
[maven-release-plugin] prepare for next development iteration
........
r16438 | kohsuke | 2009-03-20 19:10:29 -0700 (Fri, 20 Mar 2009) | 1 line
updated changelog as a part of the release
........
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16441 71c3de6d-444a-0410-be80-ed276b4c234a
This should fix the unit test failures in twitter4j I'm seeing at:
-------------------------------------------------------------------------------
Test set: hudson.plugins.twitter.ShouldIncludeURLTest
-------------------------------------------------------------------------------
Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.389 sec <<< FAILURE!
testTrueInDescriptor(hudson.plugins.twitter.ShouldIncludeURLTest) Time elapsed: 0.358 sec <<< ERROR!
java.lang.ExceptionInInitializerError
at hudson.plugins.twitter.ShouldIncludeURLTest.setUp(ShouldIncludeURLTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.NullPointerException
at hudson.model.Queue$MaintainTask.<init>(Queue.java:928)
at hudson.model.Queue.<init>(Queue.java:195)
at hudson.model.Hudson.<init>(Hudson.java:144)
at hudson.plugins.twitter.HudsonUtil.<clinit>(HudsonUtil.java:32)
... 25 more
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10993 71c3de6d-444a-0410-be80-ed276b4c234a