Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:41:17+00:00 2026-06-12T22:41:17+00:00

Here is a very simple chunk of code using a jre 1.6 run time

  • 0

Here is a very simple chunk of code using a jre 1.6 run time environment and running in a 64 bit server Server 2008 R2:
….

        cntr = 0;
       while (cntr < localheaders.size()) {
                    String tempText = textstring.toUpperCase();
        int pos = 0;
        int lastindx = 0;
        int lendPos;
        int tendPos = 0;
        while ((pos > -1) && (tempText.length() > 0)) {
            int headerLengthbeforeUpper = localheaders.get(cntr).header.length();
            String aHeader = localheaders.get(cntr).header.toUpperCase(); 
            int headerLengthafterUpper = aHeader.length();                                                              
            pos = tempText.indexOf(aHeader);  
            // 10_21_2010
            if (pos > 0) { // ef 07-10-2011
                char c;
                try {
                    c = tempText.charAt(pos - 1);
                    if (Character.isLetterOrDigit(c))
                        pos = -1;
                } catch (Exception e) {
                    System.out.println("Value of pos->" + pos);
                    System.out.println("Length of the string->"
                            + tempText.length());
                                            System.out.println("header length before->"+headerLengthbeforeUpper);
                    System.out.println("header length after->"+headerLengthafterUpper);
                    e.printStackTrace();
                }

            }
........

What I am finding is that the statement pos = tempText.toUpperCase().indexOf(aHeader); (about 10 lines down)
is being set intermittently to a value in the string tempText that is greater than the length of the string. This results in a java.lang.StringIndexOutOfBoundsException. The index is always within 100 of the actual length of the string. For example, in a test I ran this evening, the pos varaible was set to 24432 for a string of length 24404. Header length is the same before and after uppercasing to address one of the comments below. Note, if I re-run the code on the same file twice in a row, the error does not occur, the second time.

Some additional information:

  1. I don’t believe its a threading issue since there is only one thread being used.
  2. The code runs fine in a 32 bit XP environment.
  3. Both pos and tempText are locally defined variables.
  4. When I type java -version, I see the following:

Java version “1.6.0_20”
Jav(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

The test environment is running in a VMware Workstation.

I believe this is an environment issue, give the strangeness of the error and the fact that it only shows up in my 64 bit test environment. I’m trying to figure out the source of the problem. Has anyone, had this kind of error in the past? Is anyone aware of bugs related to this particular java build that might cause this kind of error?

Any ideas on how to trouble shoot this problem?

Thank you,

Elliott

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:41:18+00:00Added an answer on June 12, 2026 at 10:41 pm

    Looks like this bug maybe related to your problem:

    https://bugs.java.com/bugdatabase/view_bug?bug_id=6942326

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is very simple code, #include <iostream> using namespace std; int main() { unsigned
Here's a very simple example using SQL Server CE 3.5 SP1 where I attempt
Here's a very simple program using the function: #include <windows.h> #include <tchar.h> #include <atlstr.h>
Ok here is a very simple question: In the following code section, the cin.getline()
I have a very simple chunk of code that is designed to simulate keyboard
Here is a very simple program: a = [[]]*3 print str(a) a[0].append(1) a[1].append(2) a[2].append(3)
Here's a very simple thing I'd like to do: when the pointer is within
I hope I am not missing something very simple here. I have done a
I'm pretty sure there is a very simple solution here but I can't seem
I guess there will be a very simple answer to this. But here goes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.