Possible bug in 3.10 using custom converter

26 views
Skip to first unread message

jamesl...@gmail.com

unread,
Mar 9, 2018, 1:35:56 PM3/9/18
to jOOQ User Group
We recently tried upgrading from jOOQ 3.9.6 to 3.10.5 and ran into an issue I thought was worthy of being mentioned.

The test was attempting to insert a new record and it was throwing a NullPointerException. Here is the relevant stacktrace:
java.lang.NullPointerException
at com.everydollar.type.ImmutableValue.toString(ImmutableValue.java:32)
at java.lang.String.valueOf(String.java:2994)
at org.jooq.impl.AbstractParam.name(AbstractParam.java:109)
at org.jooq.impl.AbstractParam.<init>(AbstractParam.java:82)
at org.jooq.impl.AbstractParam.<init>(AbstractParam.java:78)
at org.jooq.impl.Val.<init>(Val.java:60)
at org.jooq.impl.DSL.val(DSL.java:18569)
at org.jooq.impl.DSL.val(DSL.java:18537)
at org.jooq.impl.FieldMapsForInsert.addFields(FieldMapsForInsert.java:233)
at org.jooq.impl.FieldMapsForInsert.set(FieldMapsForInsert.java:258)
at org.jooq.impl.FieldMapsForInsert$2.put(FieldMapsForInsert.java:333)
at org.jooq.impl.FieldMapsForInsert$2.put(FieldMapsForInsert.java:299)
at org.jooq.impl.AbstractStoreQuery.addValue(AbstractStoreQuery.java:93)
at org.jooq.impl.TableRecordImpl.addValue(TableRecordImpl.java:297)
at org.jooq.impl.TableRecordImpl.addValue(TableRecordImpl.java:304)
at org.jooq.impl.TableRecordImpl.addChangedValues(TableRecordImpl.java:288)
at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:179)
at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:168)
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:125)
at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:164)
at org.jooq.impl.TableRecordImpl.insert(TableRecordImpl.java:152)
at org.jooq.impl.TableRecordImpl.insert(TableRecordImpl.java:147)

It appears this issue is a result of our custom converter not returning null when receiving a null. I traced it back to the `addFields` method in `FieldMapsForInsert`. It calls `DSL.val(null, f)` which calls our converts `from` method. Which seemed odd to be since the test was only performing an insert and not a select.

The fix is fairly easy since I can update our converter to check for null inputs. The original thinking there was this field is NON NULL in all the tables and so I felt it wasn't necessary to check for nulls. But I guess that isn't the case anymore.

I see in the javadoc for Converter that it's recommended to return null if receiving a null, so I'll take that approach. I just though it was worth bringing up in case it was a bug or at least to help others if they upgrade to 3.10.

Thanks,
James Lorenzen

Lukas Eder

unread,
Mar 12, 2018, 7:45:19 AM3/12/18
to jooq...@googlegroups.com
Thank you very much for your report. I have created an issue to track this:
https://github.com/jOOQ/jOOQ/issues/7285

However, I wasn't able to reproduce it from your description. Would you mind sharing your converter and how it can be used in an example jOOQ API call in order to produce this stack trace?

Thanks,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jamesl...@gmail.com

unread,
Mar 12, 2018, 1:33:02 PM3/12/18
to jOOQ User Group
Sure. I'll post the code examples to the github issue.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.

Lukas Eder

unread,
Mar 15, 2018, 11:34:05 AM3/15/18
to jooq...@googlegroups.com
For the record, the error was in the ImmutableValue.toString() method, so in client code, not jOOQ code.
Reply all
Reply to author
Forward
0 new messages