java.lang.ArrayIndexOutOfBoundsException: -1

Sakai JIRA | Peter Dietz | 7 years ago
  1. 0

    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"; } }

    Sakai JIRA | 7 years ago | Peter Dietz
    java.lang.ArrayIndexOutOfBoundsException: -1
  2. 0

    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"; } }

    Sakai JIRA | 7 years ago | Peter Dietz
    java.lang.ArrayIndexOutOfBoundsException: -1
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  1. sriharshakiran 1 times, last 7 months ago
  2. tyson925 4 times, last 6 months ago
  3. Dragos 1 times, last 7 months ago
2 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ArrayIndexOutOfBoundsException

    -1

    at java.util.Arrays$ArrayList.get()
  2. Java RT
    Arrays$ArrayList.get
    1. java.util.Arrays$ArrayList.get(Arrays.java:3381)
    1 frame
  3. DSpace Kernel :: API and Implementation
    StatisticsDisplay.getDataset
    1. org.dspace.statistics.util.LocationUtils.getCountryName(LocationUtils.java:803)
    2. org.dspace.statistics.content.StatisticsDataVisits.getResultName(StatisticsDataVisits.java:403)
    3. org.dspace.statistics.content.StatisticsDataVisits.createDataset(StatisticsDataVisits.java:295)
    4. org.dspace.statistics.content.StatisticsDisplay.getDataset(StatisticsDisplay.java:91)
    4 frames