Skip to content

Apache Lucene open-source search software

SOLR-1791: Fix messed up core names on admin gui

Koji Sekiguchi2fbf7ec677ec
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 92e8247814e..22800af9882 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -371,6 +371,8 @@ Bug Fixes
* SOLR-1981: Solr will now fail correctly if solr.xml attempts to
specify multiple cores that have the same name (hossman)
+* SOLR-1791: Fix messed up core names on admin gui (yonik via koji)
+
Other Changes
----------------------
diff --git a/solr/src/webapp/web/admin/index.jsp b/solr/src/webapp/web/admin/index.jsp
index fe877988087..b2ee5449329 100644
--- a/solr/src/webapp/web/admin/index.jsp
+++ b/solr/src/webapp/web/admin/index.jsp
@@ -58,11 +58,16 @@
<%-- List the cores (that arent this one) so we can switch --%>
<% org.apache.solr.core.CoreContainer cores = (org.apache.solr.core.CoreContainer)request.getAttribute("org.apache.solr.CoreContainer");
if (cores!=null) {
- Collection<SolrCore> names = cores.getCores();
+ Collection<String> names = cores.getCoreNames();
if (names.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
- for (SolrCore name : names) {
- if(name.equals(core.getName())) continue;
- %>[<a href="../../<%=name.getName()%>/admin/"><%=name%></a>]<%
+ String url = request.getContextPath();
+ for (String name : names) {
+ String lname = name.length()==0 ? cores.getDefaultCoreName() : name; // use the real core name rather than the default
+ if(name.equals(core.getName())) {
+ %>[<%=lname%>]<%
+ } else {
+ %>[<a href="<%=url%>/<%=lname%>/admin/"><%=lname%></a>]<%
+ }
}%></td></tr><%
}}%>