From 44ecadd2ffc1fb5124a66ca1ad8c9507978fe60a Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Fri, 6 Oct 2017 16:47:40 +0200 Subject: [PATCH] Fix #1810 GephiFormatException can cause ArrayIndexOutOfBoundsException: 0 --- .../org/gephi/project/io/GephiFormatException.java | 13 ++++++++++--- modules/ProjectAPI/src/main/nbm/manifest.mf | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/ProjectAPI/src/main/java/org/gephi/project/io/GephiFormatException.java b/modules/ProjectAPI/src/main/java/org/gephi/project/io/GephiFormatException.java index 888bfdfbb..ebb26a488 100644 --- a/modules/ProjectAPI/src/main/java/org/gephi/project/io/GephiFormatException.java +++ b/modules/ProjectAPI/src/main/java/org/gephi/project/io/GephiFormatException.java @@ -38,7 +38,7 @@ made subject to such option by the copyright holder. Contributor(s): Portions Copyrighted 2011 Gephi Consortium. -*/ + */ package org.gephi.project.io; import org.openide.util.NbBundle; @@ -83,8 +83,15 @@ public class GephiFormatException extends RuntimeException { Object[] params = new Object[4]; params[0] = cause.getClass().getSimpleName(); params[1] = cause.getLocalizedMessage(); - params[2] = cause.getStackTrace()[0].getClassName(); - params[3] = cause.getStackTrace()[0].getLineNumber(); + + StackTraceElement[] stackTrace = cause.getStackTrace(); + if (stackTrace != null && stackTrace.length > 0) { + params[2] = stackTrace[0].getClassName(); + params[3] = stackTrace[0].getLineNumber(); + } else { + params[2] = "Unknown"; + params[3] = "Unknown"; + } if (isImport) { return String.format(NbBundle.getMessage(GephiFormatException.class, "gephiFormatException_import"), params); diff --git a/modules/ProjectAPI/src/main/nbm/manifest.mf b/modules/ProjectAPI/src/main/nbm/manifest.mf index 33a655f4e..b34b62326 100644 --- a/modules/ProjectAPI/src/main/nbm/manifest.mf +++ b/modules/ProjectAPI/src/main/nbm/manifest.mf @@ -2,6 +2,6 @@ Manifest-Version: 1.0 AutoUpdate-Essential-Module: true OpenIDE-Module-Layer: org/gephi/project/api/layer.xml OpenIDE-Module-Localizing-Bundle: org/gephi/project/api/Bundle.properties -OpenIDE-Module-Specification-Version: ${gephi.modules.specification.version} +OpenIDE-Module-Specification-Version: 0.9.2.1 OpenIDE-Module-Display-Category: Gephi Core OpenIDE-Module-Name: Project API \ No newline at end of file -- GitLab