Reputation: 665
I have written following java code. It is throwing array index out of range exception
Exceptions: exception_name = java.lang.ArrayIndexOutOfBoundsException
exception_message = Array index out of range: 1
Can some resolve this issue plz
public class UnifiedClus1toNfastfastsamehost extends UnifiedClus1toNfastfastsamehostHelper
{
/**
* Script Name : <b>UnifiedClus1toNfastfastsamehost</b>
* Generated : <b>Aug 3, 2007 1:16:35 AM</b>
* Description : Functional Test Script
* Original Host : WinNT Version 5.1 Build 2600 (S)
*
* @since 2007/08/03
* @author Administrator
*/
String[] dataToPass = new String[1];
public void testMain(Object[] args)
{
String options = "" + args[0];
callScript("Cleanup");
functions.formatall();
dataToPass[0]= "resyncdatagen";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "configurepair1";
callScript("Clus1toNfastfastsamehost",dataToPass);
if (options.toLowerCase().contains("Failover"))
{
dataToPass[0]= "failover";
callScript("Clus1toNfastfastsamehost",dataToPass);
}
dataToPass[0]= "WFE1";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "configurepair2";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "WFE2";
callScript("Clus1toNfastfastsamehost",dataToPass);
sleep(180);
dataToPass[0]= "vsnap1";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "dataverf1";
callScript("Clus1toNfastfastsamehost",dataToPass);
/* if (options.toLowerCase().contains("failover"))
{
dataToPass[0]= "diffdatagen1fover";
callScript("Clus1toNfastfastsamehost",dataToPass);
}
else
if (options.toLowerCase().contains("normal"))
{
dataToPass[0]= "diffdatagen1normal";
callScript("Clus1toNfastfastsamehost",dataToPass);
}
dataToPass[0]= "vsnap2";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "dataverf2";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "clean";
callScript("Clus1toNfastfastsamehost",dataToPass);
dataToPass[0]= "formatallsource";
callScript("Clus1toNfastfastsamehost",dataToPass);
if (options.toLowerCase().contains("failover"))
{
dataToPass[0]= "formatallclusfover";
callScript("Clus1toNfastfastsamehost",dataToPass);
}
else
if (options.toLowerCase().contains("normal"))
{
dataToPass[0]= "formatallclusnormal";
callScript("Clus1toNfastfastsamehost",dataToPass);
}*/
}
}
Upvotes: 0
Views: 242
Reputation: 4574
Check that while making call to testMain(Object[] args) the param "args" should not be null. Better put a null check in the method itself
String options = ""; if (args!=null){ options = options+ args[0]; }
Upvotes: 0
Reputation: 67750
It's unfortunate your exception doesn't show source file or line number, this leaves us to guess.
I don't see any use of a subscript 1 in the code shown, so the problem is likely in one of the called methods.
if (options.toLowerCase().contains("Failover"))
contains a bug, though: Once you lowercase options
, the resulting String will not contain a capital "F" as in "Failover"
!
Upvotes: 1