Disable some exception serialization asserts on java 9, likely StackTraceElement has new stuff in it and we have to think about what to do

This commit is contained in:
Robert Muir 2015-09-10 22:45:53 -04:00
parent 552d5b0f65
commit 6ba4d132df
2 changed files with 18 additions and 7 deletions

View File

@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexFormatTooNewException;
import org.apache.lucene.index.IndexFormatTooOldException;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.Constants;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
@ -324,7 +325,12 @@ public class ESExceptionTests extends ESTestCase {
} else {
assertEquals(e.getCause().getClass(), NotSerializableExceptionWrapper.class);
}
// TODO: fix this test
// on java 9, expected:<sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)>
// but was:<sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9.0/Native Method)>
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
assertArrayEquals(e.getStackTrace(), ex.getStackTrace());
}
assertTrue(e.getStackTrace().length > 1);
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), t);
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), ex);

View File

@ -21,6 +21,8 @@ package org.elasticsearch;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParseException;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.util.Constants;
import org.codehaus.groovy.runtime.typehandling.GroovyCastException;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.RoutingMissingException;
@ -567,6 +569,8 @@ public class ExceptionSerializationTests extends ESTestCase {
}
Throwable deserialized = serialize(t);
assertTrue(deserialized instanceof NotSerializableExceptionWrapper);
// TODO: fix this test for more java 9 differences
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace());
assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length);
if (t.getSuppressed().length > 0) {
@ -576,6 +580,7 @@ public class ExceptionSerializationTests extends ESTestCase {
}
}
}
}
public void testWithRestHeadersException() throws IOException {
ElasticsearchException ex = new ElasticsearchException("msg");