Java Code Examples for org.apache.solr.client.solrj.SolrServerException#getCause()

The following examples show how to use org.apache.solr.client.solrj.SolrServerException#getCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentUpdateSolrClientBuilderTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Test that connection timeout information is passed to the HttpSolrClient that handles non add operations.
 */
@Test(timeout = 10000)
public void testSocketTimeoutOnCommit() throws IOException, SolrServerException {
  InetAddress localHost = InetAddress.getLocalHost();
  try (ServerSocket server = new ServerSocket(0, 1, localHost);
       ConcurrentUpdateSolrClient client = new ConcurrentUpdateSolrClient.Builder(
           "http://" + localHost.getHostAddress() + ":" + server.getLocalPort() + "/noOneThere")
           .withSocketTimeout(1)
           .build()){
    // Expecting an exception
    client.commit();
    fail();
  }
  catch (SolrServerException e) {
    if (!(e.getCause() instanceof SocketTimeoutException)) {
      throw e;
    }
    // else test passses
  }
}
 
Example 2
Source File: PutSolrContentStream.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private boolean causedByIOException(SolrServerException e) {
    boolean foundIOException = false;
    Throwable cause = e.getCause();
    while (cause != null) {
        if (cause instanceof IOException) {
            foundIOException = true;
            break;
        }
        cause = cause.getCause();
    }
    return foundIOException;
}
 
Example 3
Source File: SolrExceptionTranslator.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
	if (ex.getCause() instanceof SolrServerException) {
		SolrServerException solrServerException = (SolrServerException) ex.getCause();
		if (solrServerException.getCause() instanceof SolrException) {
			SolrException solrException = (SolrException) solrServerException.getCause();
			// solr 4.x moved ParseExecption from
			// org.apache.lucene.queryParser to
			// org.apache.lucene.queryparser.classic
			// therefore compare ShortClassName instead of using instanceof
			// expression
			if (solrException.getCause() != null && ClassUtils.getShortName(solrException.getCause().getClass())
					.equalsIgnoreCase("ParseException")) {
				return new InvalidDataAccessApiUsageException((solrException.getCause()).getMessage(),
						solrException.getCause());
			} else {
				ErrorCode errorCode = ErrorCode.getErrorCode(solrException.code());
				switch (errorCode) {
				case NOT_FOUND:
				case SERVICE_UNAVAILABLE:
				case SERVER_ERROR:
					return new DataAccessResourceFailureException(solrException.getMessage(), solrException);
				case FORBIDDEN:
				case UNAUTHORIZED:
					return new PermissionDeniedDataAccessException(solrException.getMessage(), solrException);
				case BAD_REQUEST:
					return new InvalidDataAccessApiUsageException(solrException.getMessage(), solrException);
				case UNKNOWN:
					return new UncategorizedSolrException(solrException.getMessage(), solrException);
				default:
					break;
				}
			}
		} else if (solrServerException.getCause() instanceof ConnectException) {
			return new DataAccessResourceFailureException(solrServerException.getCause().getMessage(),
					solrServerException.getCause());
		}
	}
	return null;
}
 
Example 4
Source File: PutSolrRecord.java    From nifi with Apache License 2.0 5 votes vote down vote up
private boolean causedByIOException(SolrServerException e) {
    boolean foundIOException = false;
    Throwable cause = e.getCause();
    while (cause != null) {
        if (cause instanceof IOException) {
            foundIOException = true;
            break;
        }
        cause = cause.getCause();
    }
    return foundIOException;
}
 
Example 5
Source File: PutSolrContentStream.java    From nifi with Apache License 2.0 5 votes vote down vote up
private boolean causedByIOException(SolrServerException e) {
    boolean foundIOException = false;
    Throwable cause = e.getCause();
    while (cause != null) {
        if (cause instanceof IOException) {
            foundIOException = true;
            break;
        }
        cause = cause.getCause();
    }
    return foundIOException;
}