You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below simple test case which fails with java.lang.ClassCastException
/* * Copyright 2013 Nicolas Morel * Copyright 2020 Stanislav Spiridonov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */packageorg.dominokit.jacksonapt.client.deser.array;
importorg.dominokit.jacksonapt.JsonDeserializer;
importorg.dominokit.jacksonapt.client.deser.AbstractJsonDeserializerTest;
importorg.dominokit.jacksonapt.deser.array.cast.PrimitiveDoubleArrayJsonDeserializer;
/** * @author Stanislav Spiridonov */@SuppressWarnings("nls")
publicclassDoubleArrayJsonDeserializerTestextendsAbstractJsonDeserializerTest<double[]> {
privatestaticfinaldoubleDELTA = 0.00000000000001;
@OverrideprotectedJsonDeserializer<double[]> createDeserializer() {
returnPrimitiveDoubleArrayJsonDeserializer.getInstance();
}
@OverridepublicvoidtestDeserializeValue() {
double[] orig = newdouble[]{-100, -0.5365623643346, 0, 0.5365623643346, 100};
double[] deserialize = deserialize("[-100, -0.5365623643346, 0, 0.5365623643346, 100]");
assertEquals(orig[0], deserialize[0], DELTA);
assertEquals(orig[1], deserialize[1], DELTA);
assertEquals(orig[2], deserialize[2], DELTA);
assertEquals(orig[3], deserialize[3], DELTA);
assertEquals(orig[4], deserialize[4], DELTA);
}
publicvoidtestDeserializeValueEmptyArray() {
double[] deserialize = deserialize("[]");
assertTrue(deserialize.length == 0);
}
}
exception is
java.lang.ClassCastException
at java.lang.Throwable.Throwable(Throwable.java:66)
at java.lang.Exception.Exception(Exception.java:29)
at java.lang.RuntimeException.RuntimeException(RuntimeException.java:29)
at java.lang.ClassCastException.ClassCastException(ClassCastException.java:27)
at javaemul.internal.InternalPreconditions.checkCriticalType(InternalPreconditions.java:154)
at com.google.gwt.lang.Cast.castToDouble(InternalPreconditions.java:138)
at org.dominokit.jacksonapt.deser.array.cast.BaseJsNumberArrayReader.$readNumberArray(BaseJsNumberArrayReader.java:25)
at org.dominokit.jacksonapt.deser.array.AbstractArrayJsonDeserializer.doDeserialize(JsDoubleArrayReader.java:19)
at org.dominokit.jacksonapt.JsonDeserializer.$deserialize(JsonDeserializer.java:57)
at org.dominokit.jacksonapt.client.deser.array.DoubleArrayJsonDeserializerTest.testDeserializeValue(JsonDeserializer.java:40)
at Unknown.anonymous(GWTTestMetadataImpl.java:8)
at com.google.gwt.junit.client.impl.GWTTestAccessor.$invoke(GWTTestAccessor.java:35)
at com.google.gwt.junit.client.impl.GWTRunner.$executeTestMethod(GWTRunner.java:226)
at com.google.gwt.junit.client.GWTTestCase.$doRunTest(GWTTestCase.java:157)
at com.google.gwt.junit.client.GWTTestCase.$runBare(TestCase.java:59)
at com.google.gwt.junit.client.GWTTestCase.$__doRunTest(GWTTestCase.java:115)
at com.google.gwt.junit.client.impl.GWTRunner.$runTest(GWTRunner.java:302)
at com.google.gwt.junit.client.impl.GWTRunner.$doRunTest(GWTRunner.java:235)
at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.$onSuccess(GWTRunner.java:106)
at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.$onSuccess(GWTRunner.java:61)
at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.onSuccess(GWTRunner.java:59)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.$onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.$fireOnResponseReceived(Request.java:250)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at Unknown.anonymous(XMLHttpRequest.java:329)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java:309)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:368)
at Unknown.anonymous(Impl.java:78)
The text was updated successfully, but these errors were encountered:
The first one is in BaseJsNumberArrayReader - nextInt crash on double in the array. It may be fixed with a simple change to nextDouble, but I preferred to leave nextInt for Integer and Short readers because they provide the more understandable error message if JSON array contains wrong formated INT values.
Below simple test case which fails with
java.lang.ClassCastException
exception is
The text was updated successfully, but these errors were encountered: