SOLR-6387: Add better error messages throughout Solr and supply a work around for Java bug #8047340 to SystemInfoHandler: On Turkish default locale, some JVMs fail to fork on MacOSX, BSD, AIX, and Solaris platforms.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1618672 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2014-08-18 17:33:49 +00:00
parent 52b2a30bcc
commit 52fe544a4c
6 changed files with 36 additions and 9 deletions

View File

@ -285,6 +285,10 @@ Bug Fixes
* SOLR-6383: RegexTransformer returns no results after replaceAll if regex does not match a value.
(Alexander Kingson, shalin)
* SOLR-6387: Add better error messages throughout Solr and supply a work around for
Java bug #8047340 to SystemInfoHandler: On Turkish default locale, some JVMs fail
to fork on MacOSX, BSD, AIX, and Solaris platforms. (hossman, Uwe Schindler)
Optimizations
---------------------

View File

@ -18,6 +18,7 @@ package org.apache.solr.hadoop;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
@ -35,13 +36,15 @@ public abstract class MRUnitBase extends SolrTestCaseJ4 {
@BeforeClass
public static void setupClass() throws Exception {
assumeFalse("This test fails on UNIX with Turkish default locale (https://issues.apache.org/jira/browse/SOLR-6387)",
new Locale("tr").getLanguage().equals(Locale.getDefault().getLanguage()));
solrHomeZip = SolrOutputFormat.createSolrHomeZip(new File(RESOURCES_DIR + "/solr/mrunit"));
assertNotNull(solrHomeZip);
}
@AfterClass
public static void teardownClass() throws Exception {
solrHomeZip.delete();
if (solrHomeZip != null) solrHomeZip.delete();
}
protected void setupHadoopConfig(Configuration config) throws IOException {

View File

@ -84,6 +84,8 @@ public class AbstractSolrMorphlineTestBase extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
assumeFalse("This test fails on UNIX with Turkish default locale (https://issues.apache.org/jira/browse/SOLR-6387)",
new Locale("tr").getLanguage().equals(Locale.getDefault().getLanguage()));
myInitCore(DEFAULT_BASE_DIR);
}

View File

@ -20,6 +20,7 @@ package org.apache.solr.morphlines.solr;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.SolrServerException;
@ -68,6 +69,8 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
@BeforeClass
public static void setupClass() throws Exception {
assumeFalse("This test fails on UNIX with Turkish default locale (https://issues.apache.org/jira/browse/SOLR-6387)",
new Locale("tr").getLanguage().equals(Locale.getDefault().getLanguage()));
solrHomeDirectory = createTempDir();
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(SOLR_INSTANCE_DIR, solrHomeDirectory);

View File

@ -78,7 +78,18 @@ class RunExecutableListener extends AbstractSolrEventListener {
if (doLog) {
log.debug("About to exec " + cmd[0]);
}
Process proc = Runtime.getRuntime().exec(cmd, envp ,dir);
final Process proc;
try {
proc = Runtime.getRuntime().exec(cmd, envp ,dir);
} catch (Error err) {
// Create better error message
if (err.getMessage() != null && err.getMessage().contains("posix_spawn")) {
Error newErr = new Error("Error forking command due to JVM locale bug (see https://issues.apache.org/jira/browse/SOLR-6387): " + err.getMessage());
newErr.setStackTrace(err.getStackTrace());
err = newErr;
}
throw err;
}
if (wait) {
try {

View File

@ -17,9 +17,9 @@
package org.apache.solr.handler.admin;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
@ -213,20 +213,24 @@ public class SystemInfoHandler extends RequestHandlerBase
*/
private static String execute( String cmd )
{
DataInputStream in = null;
InputStream in = null;
Process process = null;
try {
process = Runtime.getRuntime().exec(cmd);
in = new DataInputStream( process.getInputStream() );
in = process.getInputStream();
// use default charset from locale here, because the command invoked also uses the default locale:
return IOUtils.toString(new InputStreamReader(in, Charset.defaultCharset()));
}
catch( Exception ex ) {
} catch( Exception ex ) {
// ignore - log.warn("Error executing command", ex);
return "(error executing: " + cmd + ")";
}
finally {
} catch (Error err) {
if (err.getMessage() != null && err.getMessage().contains("posix_spawn")) {
log.warn("Error forking command due to JVM locale bug (see https://issues.apache.org/jira/browse/SOLR-6387): " + err.getMessage());
return "(error executing: " + cmd + ")";
}
throw err;
} finally {
if (process != null) {
IOUtils.closeQuietly( process.getOutputStream() );
IOUtils.closeQuietly( process.getInputStream() );