Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-1517: only do reverse DNS lookup of localhost once in a static block

Chris M. Hostetter9b1b5e9206eb
diff --git a/CHANGES.txt b/CHANGES.txt
index 46cd7757982..82424914ca8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -632,6 +632,11 @@ Bug Fixes
often calculated offsets incorrectly for entities.
(Anders Melchiorsen via yonik)
+74. SOLR-1517: Admin pages could stall waiting for localhost name resolution
+ if reverse DNS wasn't configured; this was changed so the DNS resolution
+ is attempted only once the first time an admin page is loaded.
+ (hossman)
+
Other Changes
----------------------
1. Upgraded to Lucene 2.4.0 (yonik)
diff --git a/src/webapp/web/admin/_info.jsp b/src/webapp/web/admin/_info.jsp
index 2914a3f0731..05a9f4ce35a 100644
--- a/src/webapp/web/admin/_info.jsp
+++ b/src/webapp/web/admin/_info.jsp
@@ -25,6 +25,22 @@
<%@ page import="org.apache.solr.common.SolrException"%>
<%@ page import="org.apache.lucene.LucenePackage"%>
<%@ page import="java.net.UnknownHostException" %>
+
+<%!
+ // only try to figure out the hostname once in a static block so
+ // we don't have a potentially slow DNS lookup on every admin request
+ static InetAddress addr = null;
+ static String hostname = "unknown";
+ static {
+ try {
+ addr = InetAddress.getLocalHost();
+ hostname = addr.getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ //default to unknown
+ }
+ }
+%>
+
<%
//
SolrCore core = (SolrCore) request.getAttribute("org.apache.solr.SolrCore");
@@ -48,14 +64,6 @@
}
String collectionName = schema!=null ? schema.getName():"unknown";
- InetAddress addr = null;
- String hostname = "unknown";
- try {
- addr = InetAddress.getLocalHost();
- hostname = addr.getCanonicalHostName();
- } catch (UnknownHostException e) {
- //default to unknown
- }
String defaultSearch = "";
{