Menu

#439 Nullable UUID column in PostgreSQL caused NPE

v2.7.*
closed-fixed
None
2.7.3
5
2021-10-30
2021-04-18
No

There's a chance that having a null value in a nullable UUID column in PostgreSQL will cause an NPE if the code accesses it.

I am not sure if this really a bug, since we use dbuint non-directly via two test frameworks/libraries on top of each other, but changing the problematic line fixed it in my case.

File http://dbunit.sourceforge.net/xref/org/dbunit/ext/postgresql/UuidType.html, line 67.

It calls UUidType#typeCast(Object) without verifying if it is null.

I think it should be not return arg0.toString();, but instead

if (arg0 == null) {
    return null;
} else {
    return arg0.toString();
}

Completely not sure if this won't break any existing contracts or cause sudden NPEs somewhere in the callstack.

Still, altering this line fixed our tests. :)

Stacktrace, if needed:

java.lang.NullPointerException: null
at org.dbunit.ext.postgresql.UuidType.typeCast (UuidType.java:67)
at org.dbunit.dataset.datatype.AbstractDataType.compare (AbstractDataType.java:83)
at org.dbunit.assertion.comparer.value.IsActualEqualToExpectedValueComparer.isExpected (IsActualEqualToExpectedValueComparer.java:22)
...
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
at java.lang.Thread.run (Thread.java:834)

I will try to provide a minimum example, patch file and tests, but I don't know how soon. Better to think that never. :/

Discussion

  • Paul Maminov

    Paul Maminov - 2021-04-18

    Found in release 2.6.0, verified to be in 2.7.0 as well.

     
  • Jeff Jensen

    Jeff Jensen - 2021-10-30
    • status: open --> closed-fixed
    • assigned_to: Jeff Jensen
    • Fixed Release: (not fixed) --> 2.7.3
     
  • Jeff Jensen

    Jeff Jensen - 2021-10-30

    Thank you for the report and fix. I applied it and all tests still pass. Would greatly appreciate you supplying a test(s) that proves the issue if you have a chance.

     

Log in to post a comment.

MongoDB Logo MongoDB