Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for the null column? #14

Open
kienllam opened this issue Dec 18, 2017 · 3 comments
Open

Default value for the null column? #14

kienllam opened this issue Dec 18, 2017 · 3 comments
Labels

Comments

@kienllam
Copy link

kienllam commented Dec 18, 2017

How can we handle the null value for the data mapping process? I'm getting the encoding exception if the value of the column coming back from SQL database is NULL.

org.springframework.core.codec.EncodingException: JSON encoding error: (was java.lang.NullPointerException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: java.util.ArrayList[0]->com.sun.proxy.$Proxy96["sales_dollars"])
at org.springframework.http.codec.json.AbstractJackson2Encoder.encodeValue(AbstractJackson2Encoder.java:135) ~[spring-web-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.http.codec.json.AbstractJackson2Encoder.lambda$encode$3(AbstractJackson2Encoder.java:108) ~[spring-web-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) ~[reactor-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1085) ~[reactor-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at reactor.core.publisher.MonoCollectList$MonoBufferAllSubscriber.onComplete(MonoCollectList.java:117) ~[reactor-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at io.reactivex.internal.util.HalfSerializer.onComplete(HalfSerializer.java:91) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.subscribers.StrictSubscriber.onComplete(StrictSubscriber.java:109) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drainLoop(FlowableFlatMap.java:426) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drain(FlowableFlatMap.java:366) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.onComplete(FlowableFlatMap.java:338) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.subscriptions.DeferredScalarSubscription.complete(DeferredScalarSubscription.java:135) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.operators.single.SingleToFlowable$SingleToFlowableObserver.onSuccess(SingleToFlowable.java:63) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64) ~[rxjava-2.1.7.jar:na]
at org.davidmoten.rx.pool.MemberSingle$Emitter.run(MemberSingle.java:528) ~[rxjava2-jdbc-0.1-RC23.jar:na]
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:260) ~[rxjava-2.1.7.jar:na]
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:225) ~[rxjava-2.1.7.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]
Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: java.util.ArrayList[0]->com.sun.proxy.$Proxy96["sales_dollars"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:391) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:351) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:727) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:400) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1392) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1120) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:950) ~[jackson-databind-2.9.1.jar:2.9.1]
at org.springframework.http.codec.json.AbstractJackson2Encoder.encodeValue(AbstractJackson2Encoder.java:129) ~[spring-web-5.0.0.RELEASE.jar:5.0.0.RELEASE]
... 18 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.sun.proxy.$Proxy96.sales_dollars(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:687) ~[jackson-databind-2.9.1.jar:2.9.1]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:719) ~[jackson-databind-2.9.1.jar:2.9.1]
... 28 common frames omitted

@davidmoten
Copy link
Owner

davidmoten commented Dec 19, 2017 via email

@davidmoten
Copy link
Owner

davidmoten commented Dec 19, 2017 via email

@davidmoten
Copy link
Owner

davidmoten commented Dec 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants