db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Myrna van Lunteren (JIRA)" <j...@apache.org>
Subject [jira] Created: (DERBY-2265) bad logic in jvm:guessWSHome() in old test harness affects j9 runs
Date Tue, 23 Jan 2007 19:10:49 GMT
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:
         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

Running derbyall using either wcmte5.7_foundation or weme6.1 results in the following stack
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));
			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.

View raw message