DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCJODATIME-3
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Victor Ott
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Types : JodaTime

NPE when storing "null" value of jodatime types

Created: 31/Mar/10 04:17 AM   Updated: 13/Apr/10 03:32 PM   Resolved: 31/Mar/10 06:21 AM
Component/s: None
Affects Version/s: 2.0.2
Fix Version/s: 2.1.0.m1

File Attachments: 1. Text File JodaDateTimeMapping_npe_in_setobject.patch (0.7 kB)

Environment: JDK 6u18, DataNucleus 2.0.2

Datastore: PostgreSQL
Severity: Production


 Description  « Hide
org.datanucleus.store.mapped.mapping.JodaDateTimeMapping
NPE occurs in method setObject() line 112 when parameter "value" is null.

The other mapping classes, JodaDurationMapping, etc, seem all to have same issue.

Suggested fix: add "return" statement in first if() block, here the patch content:


Index: rdst/src/main/java/org/datanucleus/store/mapped/mapping/JodaDateTimeMapping.java
===================================================================
--- rdst/src/main/java/org/datanucleus/store/mapped/mapping/JodaDateTimeMapping.java Wed Mar 31 05:08:20 CEST 2010
+++ rdst/src/main/java/org/datanucleus/store/mapped/mapping/JodaDateTimeMapping.java Wed Mar 31 05:08:20 CEST 2010
@@ -93,6 +93,7 @@
         if (value == null)
         {
             getDatastoreMapping(0).setObject(preparedStatement, exprIndex[0], null);
+ return;
         }
         if (datastoreMappings != null && datastoreMappings.length > 0 && datastoreMappings[0].isStringBased())
         {


Victor Ott added a comment - 31/Mar/10 04:20 AM
Patch file for suggested fix.

Victor Ott made changes - 31/Mar/10 04:20 AM
Field Original Value New Value
Attachment JodaDateTimeMapping_npe_in_setobject.patch [ 11112 ]
Andy Jefferson made changes - 31/Mar/10 06:20 AM
Summary NPE when storing "null" DateTime value NPE when storing "null" value of jodatime types
Andy Jefferson added a comment - 31/Mar/10 06:21 AM
SVN trunk has this.
SVN branches/2.0 doesn't have this

Andy Jefferson made changes - 31/Mar/10 06:21 AM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 2.1.0.m1 [ 10915 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 13/Apr/10 03:32 PM
Status Resolved [ 5 ] Closed [ 6 ]