[ 
https://issues.apache.org/jira/browse/SOLR-12206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16431520#comment-16431520
 ] 

Shawn Heisey commented on SOLR-12206:
-------------------------------------

We should not assume that the exception will have a message.  Patch that might 
fix it:

{code}
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java 
b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index a768a32157..f6c9df664f 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -728,9 +728,14 @@ public class SolrCLI {
     } catch (ClientProtocolException cpe) {
       // Currently detecting authentication by string-matching the HTTP 
response
       // Perhaps SolrClient should have thrown an exception itself??
-      if (cpe.getMessage().contains("HTTP ERROR 401") || 
cpe.getMessage().contentEquals("HTTP ERROR 403")) {
-        int code = cpe.getMessage().contains("HTTP ERROR 401") ? 401 : 403; 
-        throw new SolrException(SolrException.ErrorCode.getErrorCode(code), 
+      String msg = null;
+      if (cpe != null)
+      {
+        msg = cpe.getMessage();
+      }
+      if (msg != null && (msg.contains("HTTP ERROR 401") || 
msg.contentEquals("HTTP ERROR 403"))) {
+        int code = msg.contains("HTTP ERROR 401") ? 401 : 403;
+        throw new SolrException(SolrException.ErrorCode.getErrorCode(code),
             "Solr requires authentication for " + getUrl + ". Please supply 
valid credentials. HTTP code=" + code);
       } else {
         throw cpe;
{code}


> SolrCLI can swallow all information about an exception from a request to Solr
> -----------------------------------------------------------------------------
>
>                 Key: SOLR-12206
>                 URL: https://issues.apache.org/jira/browse/SOLR-12206
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: scripts and tools
>    Affects Versions: 7.3
>            Reporter: Shawn Heisey
>            Assignee: Shawn Heisey
>            Priority: Minor
>
> User got an NPE when trying to create a core, no useful information:
> {code}
> $ /usr/local/solr/bin/solr create -V -c new_core
> WARNING: Using _default configset with data driven schema functionality.
> NOT RECOMMENDED for production use.
>          To turn off: bin/solr config -c new_core -p 8983 -property
> update.autoCreateFields -value false
> Exception in thread "main" java.lang.NullPointerException
>       at org.apache.solr.util.SolrCLI.getJson(SolrCLI.java:731)
>       at org.apache.solr.util.SolrCLI.getJson(SolrCLI.java:642)
>       at org.apache.solr.util.SolrCLI$CreateTool.runImpl(SolrCLI.java:1773)
>       at org.apache.solr.util.SolrCLI$ToolBase.runTool(SolrCLI.java:176)
>       at org.apache.solr.util.SolrCLI.main(SolrCLI.java:282)
> {code}
> Looking at the code, this happened because SolrCLI got a 
> ClientProtocolException in its call to HttpClient, but that exception did NOT 
> have a message string attached, so when the code in the catch block tried to 
> look at the message, it threw NPE.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to