[ 
https://jira.duraspace.org/browse/DS-815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=24282#comment-24282
 ] 

Denys Slipetskyy commented on DS-815:
-------------------------------------

As Robin said the problem can occur if you try to edit item after metadata were 
imported (in my case it were imported from XML using DIMIngestionCrosswalk .... 
for some reason there was a text string instead of date).

And the worst thing is that now you are not able to check such kind of 
situation. validation against null will not help. E.g. in my case DCDate object 
was created (not null), BUT internal variable "calendar" was null. In this 
situation if you try to call some getter (getMonth() lets say), you'll have a 
NullPointerException.

I solved it make getters return -1 if calendar var is null, as was mentioned 
before in comments.
But may be better approach is to: .1) add some flag for error (which can be 
checked by caller later). .... 2) rise an Exception 3) return null object.

I'm not sure which is better. In any case we must handle that situation (as 
there is no guaranty that string representation of the date passed to the 
constructor will always be valid).
                
> DCDate throws NullPointerException with mangled dates
> -----------------------------------------------------
>
>                 Key: DS-815
>                 URL: https://jira.duraspace.org/browse/DS-815
>             Project: DSpace
>          Issue Type: Bug
>          Components: DSpace API
>    Affects Versions: 1.7.0
>         Environment: CentOS 5.4 with OpenJDK 64-Bit Server VM (build 
> 1.6.0-b09, mixed mode)
>            Reporter: Àlex Magaz Graça
>            Assignee: Mark H. Wood
>         Attachments: DCDate_test_mangled_date.patch
>
>
> DCDate.get*() methods throw a NullPointerException if the object has been 
> constructed with a wrong date like "[17--?]" (DCDateTest patch attached):
> java.lang.NullPointerException
>       at org.dspace.content.DCDate.getYear(DCDate.java:298)
>       at org.dspace.content.DCDateTest.testDCDateString(DCDateTest.java:301)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at java.lang.reflect.Method.invoke(Method.java:616)
>       at 
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>       at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>       at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>       at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at java.lang.reflect.Method.invoke(Method.java:616)
>       at 
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>       at 
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
> It makes the browse by issue date fail in JSPUI.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.duraspace.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to