Skip to content

Fix Abdera ArrayIndexOutOfBoundsException with non-existent atom-entry-study.xml in SWORD jar (upstream ideally) #893

Description

@raprasad

Author Name: Philip Durbin (@pdurbin)
Original Redmine Issue: 3305, https://redmine.hmdc.harvard.edu/issues/3305
Original Date: 2013-09-16


If you attempt to create a study via SWORD with an Atom entry file that doesn't exist you will see "org.apache.abdera.parser.ParseException: java.lang.ArrayIndexOutOfBoundsException" from the client side...

murphy:dvn pdurbin$ file atom-entry-study.xml
atom-entry-study.xml: cannot open `atom-entry-study.xml' (No such file or directory)
murphy:dvn pdurbin$ curl --insecure -s --data-binary "@atom-entry-study.xml" -H "Content-Type: application/atom+xml" -u sword:sword https://localhost:8181/dvn/api/data-deposit/v1/swordv2/collection/dataverse/sword | xmllint -format -
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>GlassFish Server Open Source Edition 3.1.2.2 - Error report</title>
    <style type="text/css">
<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}-->
    </style>
  </head>
  <body>
    <h1>HTTP Status 500 - </h1>
    <hr />
    <p><b>type</b> Exception report</p>
    <p>
      <b>message</b>
    </p>
    <p><b>description</b>The server encountered an internal error () that prevented it from fulfilling this request.</p>
    <p>
      <b>exception</b>
      ```org.apache.abdera.parser.ParseException: java.lang.ArrayIndexOutOfBoundsException
</p>
<p>
  <b>note</b>
  <u>The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.</u>
</p>
<hr />
<h3>GlassFish Server Open Source Edition 3.1.2.2</h3>
murphy:dvn pdurbin$

... and in the Glassfish server.log, this error appears:

[#|2013-09-16T08:19:33.170-0400|WARNING|glassfis###1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=33;_ThreadName=Thread-4;|StandardWrapperValve[edu.harvard.iq.dvn.core.web.servlet.SWORDv2CollectionServlet]: PWC1406: Servlet.service() for servlet edu.harvard.iq.dvn.core.web.servlet.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:334)
at org.swordapp.server.CollectionAPI.post(CollectionAPI.java:156)
at edu.harvard.iq.dvn.core.web.servlet.SWORDv2CollectionServlet.doPost(SWORDv2CollectionServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:115)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:328)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at java.io.PushbackInputStream.unread(PushbackInputStream.java:218)
at org.apache.abdera.i18n.text.io.DynamicPushbackInputStream.unread(DynamicPushbackInputStream.java:91)
at org.apache.abdera.i18n.text.io.PeekAheadInputStream.peek(PeekAheadInputStream.java:61)
at org.apache.abdera.i18n.text.io.PeekAheadInputStream.peek(PeekAheadInputStream.java:52)
at org.apache.abdera.i18n.text.io.CharsetSniffingInputStream.detectEncoding(CharsetSniffingInputStream.java:110)
at org.apache.abdera.parser.stax.util.FOMSniffingInputStream.detectEncoding(FOMSniffingInputStream.java:39)
at org.apache.abdera.i18n.text.io.CharsetSniffingInputStream.(CharsetSniffingInputStream.java:81)
at org.apache.abdera.i18n.text.io.CharsetSniffingInputStream.(CharsetSniffingInputStream.java:74)
at org.apache.abdera.parser.stax.util.FOMSniffingInputStream.(FOMSniffingInputStream.java:35)
at org.apache.abdera.parser.stax.FOMParser.parse(FOMParser.java:107)
... 37 more
|#]


org.swordapp.server.SwordAPIEndpoint.addDepositPropertiesFromEntry(SwordAPIEndpoint.java:334) corresponds to https://github.com/IQSS/swordv2-java-server-library/blob/aeaef8342361bf3de7e9fc8f2a979cd742bc31ae/src/main/java/org/swordapp/server/SwordAPIEndpoint.java#L334 which is unmodified from https://github.com/swordapp/JavaServer2.0/blob/master/src/main/java/org/swordapp/server/SwordAPIEndpoint.java#L334

Here is the relevant block of code:

328 protected void addDepositPropertiesFromEntry(Deposit deposit, HttpServletRequest req)
329 throws IOException
330 {
331 InputStream entryPart = req.getInputStream();
332 Abdera abdera = new Abdera();
333 Parser parser = abdera.getParser();
334 Document entryDoc = parser.parse(entryPart);
335 Entry entry = entryDoc.getRoot();
336 deposit.setEntry(entry);
337 }


We should probably start by reporting this on the SWORD mailing list ( https://lists.sourceforge.net/lists/listinfo/sword-app-tech ) or submit another pull request as we did with https://github.com/swordapp/JavaServer2.0/pull/3


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions