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

Retrieving country names in SOLR can return ArrayIndexOutOfBounds when country code is unchecked

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 1.6.1, 1.7.0
    • Component/s: Solr
    • Labels:
      None
    • Attachments:
      1
    • Comments:
      5
    • Documentation Status:
      Not Required

      Description

      When viewing SOLR statistics about an item/collection/community the section that displays the list of countries with the most visits can choke out when it encounters an invalid country code. It will just leave a blank section for countries when displaying the stats page.

      It is unknown why invalid/blank country codes make it in to SOLR statistics, but errors can be prevented when querying. Perhaps some additional checks on the ingest of SOLR data would also be useful.

      == Error as discovered in dspace.log ==
      2010-03-09 13:04:32,703 ERROR org.dspace.app.xmlui.aspect.statistics.StatisticsTransformer @ Error occured while creating statistics for dso with ID: 993 and type 2 and handle: 1811/706
      java.lang.ArrayIndexOutOfBoundsException: -1
      at java.util.Arrays$ArrayList.get(Arrays.java:3381)
      at org.dspace.statistics.util.LocationUtils.getCountryName(LocationUtils.java:803)
      at org.dspace.statistics.content.StatisticsDataVisits.getResultName(StatisticsDataVisits.java:403)
      at org.dspace.statistics.content.StatisticsDataVisits.createDataset(StatisticsDataVisits.java:295)
      at org.dspace.statistics.content.StatisticsDisplay.getDataset(StatisticsDisplay.java:91)
      ...

      http://scm.dspace.org/svn/repo/dspace/trunk/dspace-stats/src/main/java/org/dspace/statistics/util/LocationUtils.java

      Original Code
      public static String getCountryName(String countryCode)

      { int index = countryCodeList.indexOf(countryCode); return countryNameList.get(index).toString(); }

      Revised Code
      public static String getCountryName(String countryCode){
      if(countryCodeList.contains(countryCode))

      { int index = countryCodeList.indexOf(countryCode); return countryNameList.get(index).toString(); }

      else

      { return "Unknown Country"; }

      }

        Attachments

          Activity

            People

            • Assignee:
              peterdietz Peter Dietz
              Reporter:
              peterdietz Peter Dietz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: