Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-1090

CC license process fails with java.lang.NegativeArraySizeException.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.0, 1.7.1, 1.7.2, 1.8.0
    • Fix Version/s: 1.8.1
    • Component/s: JSPUI, XMLUI
    • Labels:
      None
    • Attachments:
      1
    • Comments:
      4
    • Documentation Status:
      Needed

      Description

      version 1.8.0 has no error, but fails silently.

      version 1.7.X gives an error and cannot continue.
      When adding CC license to a submission, we get the following error
      Exception:
      java.lang.NegativeArraySizeException
      at org.dspace.license.CreativeCommons.fetchURL(CreativeCommons.java:393)
      at org.dspace.license.CreativeCommons.fetchLicenseText(CreativeCommons.java:268)
      at org.dspace.license.CreativeCommons.setLicense(CreativeCommons.java:130)
      at org.dspace.app.webui.servlet.admin.EditItemServlet.showEditForm(EditItemServlet.java:379)
      at org.dspace.app.webui.servlet.admin.EditItemServlet.doDSGet(EditItemServlet.java:135)
      ...

      The line
      byte[] bytes = new byte[connection.getContentLength()];
      fails because it presumably can't get the content-length of the license upfront.

      Possible Workaround:

      Add to the imports...
      import java.io.BufferedReader;
      import java.io.InputStreamReader;

      Replace everything in the try{} block with...
      String line = "";
      URL url = new URL(url_string);
      URLConnection connection = url.openConnection();
      InputStream inputStream = connection.getInputStream();
      BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
      StringBuilder sb = new StringBuilder();

      while ((line = reader.readLine()) != null)
      sb.append(line);

      return sb.toString().getBytes();

        Attachments

          Activity

            People

            Assignee:
            peterdietz Peter Dietz
            Reporter:
            dishimitsu Dan Ishimitsu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: