swordapp / JavaServer2.0

Java server library for supporting integration with SWORDv2
Other
1 stars 19 forks source link

feeding an empty Atom entry file to CollectionAPI.post results in org.apache.abdera.parser.ParseException: java.lang.ArrayIndexOutOfBoundsException #6

Open pdurbin opened 10 years ago

pdurbin commented 10 years ago

If atom-entry-empty.xml is an empty file (i.e. touch atom-entry-empty.xml to create it) and I try to feed it into CollectionAPI.post like this...

curl -s --insecure --data-binary @scripts/api/data-deposit/data/atom-entry-empty.xml -H 'Content-Type: application/atom+xml' https://pete:pete@localhost:8181/dvn/api/data-deposit/v1/swordv2/collection/dataverse/peteTop

... I get the exception below. Perhaps a try/catch could be added?

Here's the relevant line: https://github.com/swordapp/JavaServer2.0/blob/sword2-server-1.0/src/main/java/org/swordapp/server/SwordAPIEndpoint.java#L355

StandardWrapperValve[edu.harvard.iq.dataverse.api.datadeposit.SWORDv2CollectionServlet]: Servlet.service() for servlet edu.harvard.iq.dataverse.api.datadeposit.SWORDv2CollectionServlet threw exception
org.apache.abdera.parser.ParseException: java.lang.ArrayIndexOutOfBoundsException
        at org.apache.abdera.parser.stax.FOMParser.parse(FOMParser.java:128)
        at org.apache.abdera.util.AbstractParser.parse(AbstractParser.java:65)
        at org.swordapp.server.SwordAPIEndpoint.addDepositPropertiesFromEntry(SwordAPIEndpoint.java:355)
        at org.swordapp.server.CollectionAPI.post(CollectionAPI.java:156)
        at edu.harvard.iq.dataverse.api.datadeposit.SWORDv2CollectionServlet.doPost(SWORDv2CollectionServlet.java:34)

The Java SWORD library is upstream of me but here's where I'm tracking this issue: https://github.com/IQSS/dataverse/issues/893

pdurbin commented 10 years ago

A related bug is that we get org.apache.abdera.parser.ParseException when trying to create a SWORD entry with some XML that contains an invisible character:

https://github.com/IQSS/dataverse/blob/master/scripts/api/data-deposit/data/atom-entry-study-894-invisible-character.xml

However, I was able to catch org.apache.abdera.parser.ParseException in my code

https://github.com/IQSS/dataverse/commit/f181c0d7bc447b9fbe43f161fb25e01336deba36