You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Myrna van Lunteren (JIRA)" <ji...@apache.org> on 2007/01/24 01:55:49 UTC

[jira] Closed: (DERBY-2265) bad logic in jvm:guessWSHome() in old test harness affects j9 runs

     [ https://issues.apache.org/jira/browse/DERBY-2265?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Myrna van Lunteren closed DERBY-2265.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.3.0.0

committed http://svn.apache.org/viewvc?view=rev&revision=499200

> bad logic in jvm:guessWSHome() in old test harness affects j9 runs
> ------------------------------------------------------------------
>
>                 Key: DERBY-2265
>                 URL: https://issues.apache.org/jira/browse/DERBY-2265
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.0.0
>         Environment: wctme5.7_foundation (j2ME 1.0) or weme6.1 (foundation, j2ME 1.1)
>            Reporter: Myrna van Lunteren
>         Assigned To: Myrna van Lunteren
>            Priority: Minor
>             Fix For: 10.3.0.0
>
>         Attachments: DERBY-2265_20070123.diff
>
>
> Running derbyall using either wcmte5.7_foundation or weme6.1 results in the following stack trace.
> Exception in thread "main" java.lang.StringIndexOutOfBoundsException
>         at java.lang.String.substring(String.java:1043)
>         at org.apache.derbyTesting.functionTests.harness.jvm.guessWSHome(jvm.java:301)
>         at org.apache.derbyTesting.functionTests.harness.jvm.getSecurityProps(jvm.java:356)
>         at org.apache.derbyTesting.functionTests.harness.jvm.setSecurityProps(jvm.java:336)
>         at org.apache.derbyTesting.functionTests.harness.RunTest.buildTestCommand(RunTest.java:2350)
>         at org.apache.derbyTesting.functionTests.harness.RunTest.testRun(RunTest.java:498)
>         at org.apache.derbyTesting.functionTests.harness.RunTest.main(RunTest.java:368)
> I think this code was not reached until various security related changes recently, but the code is just bad.
> I think this code was used at one point to attempt to kick off another jvm to run a server with, but that is now defunct.
> Rather than try to make the code work, or try to clean it up, I'd rather spend time converting tests to the junit framework, so I will just fix this up so we don't hit the error.
> The bad code is: 
> 		wshome = jhome.substring(0,jhome.indexOf(sep + "jre"));
> 		wshome = wshome.substring(0,wshome.lastIndexOf(sep));
> If the jhome ( System.getProperty("java.home")) does not contain 'jre', we will get -1 as the 2nd parameter in jhome.substring, and thus cause the ArrayIndexOutOfBounds.
> I propose to fix this piece of code as follows:
> 		int havejre=jhome.indexOf(sep + "jre");
> 		if (havejre > 0)
> 		{
> 			wshome = jhome.substring(0,jhome.indexOf(sep + "jre"));
> 			wshome = wshome.substring(0,wshome.lastIndexOf(sep));
> 		}
> 		else
> 			wshome = jhome.substring(0,jhome.lastIndexOf(sep));	

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.