提交 17b4a46f 编写于 作者: M mindless

[FIXED HUDSON-6938] Avoid infinite loop with invalid or null primary view,

such as in upgrade from older Hudson.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@33194 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0646acb3
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc.,
* Seiji Sogabe, Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi,
* Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc., Seiji Sogabe,
* Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
......@@ -1257,10 +1258,12 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
if(v.getViewName().equals(name))
return v;
}
// Fallback to subview of primary view if it is a ViewGroup
View pv = getPrimaryView();
if (pv instanceof ViewGroup)
return ((ViewGroup)pv).getView(name);
if (name != null && !name.equals(primaryView)) {
// Fallback to subview of primary view if it is a ViewGroup
View pv = getPrimaryView();
if (pv instanceof ViewGroup)
return ((ViewGroup)pv).getView(name);
}
return null;
}
......
......@@ -38,11 +38,13 @@ import hudson.security.SecurityRealm;
import hudson.tasks.Ant;
import hudson.tasks.BuildStep;
import hudson.tasks.Ant.AntInstallation;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Email;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.recipes.LocalData;
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.List;
......@@ -170,4 +172,19 @@ public class HudsonTest extends HudsonTestCase {
BuildStep.PUBLISHERS.remove(dummy);
assertNull(hudson.getDescriptor(HudsonTest.class.getName()));
}
/**
* Verify null/invalid primaryView setting doesn't result in infinite loop.
*/
@Bug(6938)
public void testInvalidPrimaryView() throws Exception {
Field pv = Hudson.class.getDeclaredField("primaryView");
pv.setAccessible(true);
String value = null;
pv.set(hudson, value);
assertNull("null primaryView", hudson.getView(value));
value = "some bogus name";
pv.set(hudson, value);
assertNull("invalid primaryView", hudson.getView(value));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册