Merge branch 'master' into security-master

This commit is contained in:
Jesse Glick committed 2015-11-05 17:01:47 -05:00
commit f76f795b44
17 files changed
+26 -132

No files matched your search

+6 -1
View File
@@ -55,7 +55,12 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class="bug">
Remove useless warnings about a JDK named <em>null</em>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-31217">issue 31217</a>)
<li class="rfe">
New <tt>OptionalJobProperty</tt> class to simplify <tt>JobProperty</tt> creation.
(<a href="https://github.com/jenkinsci/jenkins/pull/1888">pull 1888</a>)
</ul>
</div><!--=TRUNK-END=-->
<h3><a name=v1.636>What's new in 1.636</a> (2015/11/01)</h3>
@@ -156,7 +156,6 @@ public class AnnotatedLargeText<T> extends LargeText {
/**
* Calls {@link LargeText#writeLogTo(long, OutputStream)} without stripping annotations as {@link #writeLogTo(long, OutputStream)} would.
* @inheritDoc
* @since 1.577
*/
public long writeRawLogTo(long start, OutputStream out) throws IOException {
@@ -37,6 +37,7 @@ public abstract class AbstractDescribableImpl<T extends AbstractDescribableImpl<
* By default looks for a nested class (conventionally named {@code DescriptorImpl}) implementing {@link Descriptor} and marked with {@link Extension}.
* <p>{@inheritDoc}
*/
@Override
public Descriptor<T> getDescriptor() {
return Jenkins.getInstance().getDescriptorOrDie(getClass());
}
@@ -1090,6 +1090,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* or if the blockBuildWhenUpstreamBuilding option is true and an upstream
* project is building, but derived classes can also check other conditions.
*/
@Override
public boolean isBuildBlocked() {
return getCauseOfBlockage()!=null;
}
@@ -587,6 +587,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* {@inheritDoc}
*/
@Override
public void taskAccepted(Executor executor, Queue.Task task) {
// dummy implementation
}
@@ -594,6 +595,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* {@inheritDoc}
*/
@Override
public void taskCompleted(Executor executor, Queue.Task task, long durationMS) {
// dummy implementation
}
@@ -601,6 +603,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* {@inheritDoc}
*/
@Override
public void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) {
// dummy implementation
}
@@ -325,6 +325,7 @@ public class HealthReport implements Serializable, Comparable<HealthReport> {
/**
* {@inheritDoc}
*/
@Override
public int compareTo(HealthReport o) {
return (this.score < o.score ? -1 : (this.score == o.score ? 0 : 1));
}
+1 -1
View File
@@ -67,7 +67,7 @@ public final class JDK extends ToolInstallation implements NodeSpecific<JDK>, En
// DEFAULT_NAME took this value prior to 1.598.
return true;
}
return DEFAULT_NAME.equals(name);
return DEFAULT_NAME.equals(name) || name == null;
}
/**
@@ -99,6 +99,7 @@ public abstract class JobProperty<J extends Job<?,?>> implements ReconfigurableD
/**
* {@inheritDoc}
*/
@Override
public JobPropertyDescriptor getDescriptor() {
return (JobPropertyDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
@@ -153,6 +154,7 @@ public abstract class JobProperty<J extends Job<?,?>> implements ReconfigurableD
* <p>
* Invoked after {@link Publisher}s have run.
*/
@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
return true;
}
@@ -79,6 +79,7 @@ public abstract class ManagementLink implements ExtensionPoint, Action {
* In case of {@link ManagementLink}, this value is put straight into the href attribute,
* so relative paths are interpreted against the root {@link Jenkins} object.
*/
@Override
public abstract String getUrlName();
/**
@@ -155,6 +155,7 @@ public abstract class ParameterDefinition implements
/**
* {@inheritDoc}
*/
@Override
public ParameterDescriptor getDescriptor() {
return (ParameterDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
@@ -202,6 +202,7 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal
* it's always configured through <tt>config.jelly</tt> and never with
* <tt>global.jelly</tt>.
*/
@Override
public Descriptor<SecurityRealm> getDescriptor() {
return super.getDescriptor();
}
@@ -104,6 +104,7 @@ public class CrumbFilter implements Filter {
/**
* {@inheritDoc}
*/
@Override
public void destroy() {
}
@@ -55,6 +55,7 @@ public class ComputerRetentionWork extends PeriodicWork {
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected void doRun() {
final long startRun = System.currentTimeMillis();
for (final Computer c : Jenkins.getInstance().getComputers()) {
@@ -65,6 +65,7 @@ public abstract class BuildStepCompatibilityLayer implements BuildStep {
* @inheritDoc
* @return Delegates to {@link SimpleBuildStep#perform(Run, FilePath, Launcher, TaskListener)} if possible, always returning true or throwing an error.
*/
@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
if (this instanceof SimpleBuildStep) {
// delegate to the overloaded version defined in SimpleBuildStep
@@ -1,127 +0,0 @@
package jenkins.model;
import hudson.Extension;
import hudson.Plugin;
import hudson.model.UnprotectedRootAction;
import hudson.util.TimeUnit2;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.inject.Inject;
import javax.servlet.ServletException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Enumeration;
/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class AssetManager implements UnprotectedRootAction {
@Inject
Jenkins jenkins;
// not shown in the UI
@Override
public String getIconFileName() {
return null;
}
@Override
public String getDisplayName() {
return null;
}
@Override
public String getUrlName() {
return "assets";
}
/**
* Binds the plugin asset space to the URL space.
*/
public AssetSpace getPlugin(String shortName) {
Plugin p = jenkins.getPlugin(shortName);
if (p==null) return null;
return new AssetSpace(p.getWrapper().classLoader);
}
/**
* Binds the core asset space to the URL space.
*/
public AssetSpace getCore() {
return new AssetSpace(Jenkins.class.getClassLoader());
}
/**
* Represents assets that belong to one classloader, such as a plugin or core.
*/
final class AssetSpace {
private final ClassLoader cl;
private AssetSpace(ClassLoader cl) {
this.cl = cl;
}
/**
* Exposes assets in the classloader over HTTP.
*/
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String path = req.getRestOfPath();
// Stapler routes requests like the "/static/.../foo/bar/zot" to be treated like "/foo/bar/zot"
// and this is used to serve long expiration header, by using Jenkins.VERSION_HASH as "..."
// to create unique URLs. Recognize that and set a long expiration header.
String requestPath = req.getRequestURI().substring(req.getContextPath().length());
boolean staticLink = requestPath.startsWith("/static/");
long expires = staticLink ? TimeUnit2.DAYS.toMillis(365) : -1;
// use serveLocalizedFile to support automatic locale selection
rsp.serveLocalizedFile(req, findResource(path), expires);
}
/**
* Locates the asset from the classloader.
*
* <p>
* To allow plugins to bring its own assets without worrying about colliding with the assets in core,
* look for child classloader first. But to support plugins that get split, if the child classloader
* doesn't find it, fall back to the parent classloader.
*/
private URL findResource(String path) throws IOException {
try {
if (path.contains("..")) // crude avoidance of directory traversal attack
throw new IllegalArgumentException(path);
String name = "assets/" + path;
URL url = (URL) $findResource.invoke(cl, name);
if (url==null) {
// pick the last one, which is the one closest to the leaf of the classloader tree.
Enumeration<URL> e = cl.getResources(name);
while (e.hasMoreElements()) {
url = e.nextElement();
}
}
return url;
} catch (InvocationTargetException|IllegalAccessException e) {
throw new Error(e);
}
}
}
private static final Method $findResource = init();
private static Method init() {
try {
Method m = ClassLoader.class.getDeclaredMethod("findResource", String.class);
m.setAccessible(true);
return m;
} catch (NoSuchMethodException e) {
throw (Error)new NoSuchMethodError().initCause(e);
}
}
}
@@ -161,6 +161,7 @@ public abstract class IdStrategy extends AbstractDescribableImpl<IdStrategy> imp
/**
* {@inheritDoc}
*/
@Override
@Nonnull
public String keyFor(@Nonnull String id) {
return id.toLowerCase(Locale.ENGLISH);
@@ -288,6 +289,7 @@ public abstract class IdStrategy extends AbstractDescribableImpl<IdStrategy> imp
/**
* {@inheritDoc}
*/
@Override
@Nonnull
public String keyFor(@Nonnull String id) {
return id;
@@ -348,6 +350,7 @@ public abstract class IdStrategy extends AbstractDescribableImpl<IdStrategy> imp
/**
* {@inheritDoc}
*/
@Override
@Nonnull
public String keyFor(@Nonnull String id) {
int index = id.lastIndexOf('@'); // The @ can be used in local-part if quoted correctly
@@ -36,8 +36,8 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class JDKNameTest {
@Test
public void nullIsNotDefaultName() {
assertThat(JDK.isDefaultName(null), is(false));
public void nullIsDefaultName() {
assertThat(JDK.isDefaultName(null), is(true));
}
@Test