JDK 1.6.0_18 Bug

Found a bug in JDK 1.6.0_18.

This, abeit brain-dead, code causes some sort of deadlock condition where multiple threads get stuck in the replaceAll() method:

// Replace all double spaces with single spaces
while ( string.indexOf(" ") != -1 ) {
   string = string.replaceAll("\\s\\s", " ");
}

Modify it to this makes it go away:

// Replace all double spaces with single spaces
string = string.replaceAll("\\s+", " ");

Maybe the first version of the code was not supposed to work in the first place.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: