Bug 212242 - StringIndexOutOfBoundsException when "id" for jsp:usebean contains space
Summary: StringIndexOutOfBoundsException when "id" for jsp:usebean contains space
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-12-07 02:32 EST by Amy Wu CLA
Modified: 2008-04-29 16:43 EDT (History)
1 user (show)

See Also:
thatnitind: review+
thatnitind: review-


Attachments
Patch to fix StringIndexOutOfBounds (1.43 KB, patch)
2008-03-24 17:56 EDT, Nick Sandonato CLA
no flags Details | Diff
different direction - report the problem (11.62 KB, patch)
2008-03-24 22:50 EDT, Nitin Dahyabhai CLA
bjorn.freeman-benson: iplog+
Details | Diff
Adding support for more validation scenarios (14.10 KB, patch)
2008-03-25 15:43 EDT, Nick Sandonato CLA
no flags Details | Diff
Fixed missing //$NON-NLS-1$ (14.16 KB, patch)
2008-03-26 11:42 EDT, Nick Sandonato CLA
no flags Details | Diff
patch (1.68 KB, patch)
2008-04-04 15:32 EDT, Nick Sandonato CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Wu CLA 2007-12-07 02:32:23 EST
using a wtp 3.0m4 build from dec 6

1. create a new jsp
2. add a jsp:usebean tag with an id containing a space like id="my space" 
3. add the type attribute and start typing something then invoking content assist.

You get the below exception:
java.lang.StringIndexOutOfBoundsException
	at java.lang.String.substring(String.java:1088)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.appendUseBeanToBuffer(JSPTranslator.java:2255)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.appendToBuffer(JSPTranslator.java:2069)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.appendToBuffer(JSPTranslator.java:2034)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.translateUseBean(JSPTranslator.java:2536)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.translateXMLNode(JSPTranslator.java:1280)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.translateRegionContainer(JSPTranslator.java:1018)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslator.translate(JSPTranslator.java:863)
	at org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter.getJSPTranslation(JSPTranslationAdapter.java:127)
	at org.eclipse.jst.jsp.ui.internal.contentassist.JSPCompletionProcessor.computeCompletionProposals(JSPCompletionProcessor.java:83)
	at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaContentAssistProcessor.computeCompletionProposals(JSPJavaContentAssistProcessor.java:95)
	at org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor.getJSPJavaCompletionProposals(JSPContentAssistProcessor.java:1061)
	at org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor.getImportProposals(JSPContentAssistProcessor.java:945)
	at org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor.computeCompletionProposals(JSPContentAssistProcessor.java:936)
	at org.eclipse.wst.sse.ui.internal.contentassist.CompoundContentAssistProcessor.computeCompletionProposals(CompoundContentAssistProcessor.java:300)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1808)
Comment 1 Nick Sandonato CLA 2008-03-24 17:56:17 EDT
Created attachment 93329 [details]
Patch to fix StringIndexOutOfBounds

Checks for the existence of the opening parenthesis before using it as an index.
Comment 2 Nitin Dahyabhai CLA 2008-03-24 22:50:57 EDT
Created attachment 93346 [details]
different direction - report the problem

Hmmm, actually I think it's better if we can report the problem(s) instead of just working around them.  Nick, please use this patch as a starting point and flesh out the other cases in the spec that I've missed.
Comment 3 Nitin Dahyabhai CLA 2008-03-24 22:53:41 EDT
Apparently I've dropped a number of //$NON-NLS-1$ markers as well...
Comment 4 Nick Sandonato CLA 2008-03-25 15:43:06 EDT
Created attachment 93480 [details]
Adding support for more validation scenarios

Addressed in this patch:
1) Clearing previous validation messages--everything was being appended before
2) Added support for using the beanName attribute in the jsp:useBean tag
3) Expanded on the previous patch's validations to include
   a. Validate that both class and beanName are not both defined
   b. Validate that a type for the bean can be resolved (either by explicit declaration through the type attribute or through inferring from the class attribute)

These changes are on top of those found in attachment 93346 [details], so that attachment should be made obsolete.
Comment 5 Nick Sandonato CLA 2008-03-26 11:42:39 EDT
Created attachment 93621 [details]
Fixed missing //$NON-NLS-1$

Fixed up the missing //$NON-NLS-1$
Comment 6 Nitin Dahyabhai CLA 2008-03-26 18:27:54 EDT
Committed.
Comment 7 Nick Sandonato CLA 2008-04-04 15:31:29 EDT
Reopening bug. Patch code differs from what was committed to the repository causing bug 225798.
Comment 8 Nick Sandonato CLA 2008-04-04 15:32:27 EDT
Created attachment 94901 [details]
patch

Patch to add back missing line of code.
Comment 9 Nitin Dahyabhai CLA 2008-04-10 01:52:46 EDT
Fixed.
Comment 10 David Williams CLA 2008-04-24 00:45:26 EDT
mass change to add 'contributed' keyword based on bugzilla query, please correct if that's not accurate (by marking patches as obsolete and removing the 'contributed' keyword. 
Comment 11 Nick Sandonato CLA 2008-04-29 16:43:47 EDT
Verified in I20080429053810. Closing.