Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 476315

Summary: GitFileDecorator throws StringIndexOutOfBoundsException
Product: [ECD] Orion Reporter: Andrew Audibert <aaudibert>
Component: GitAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 9.0   
Target Milestone: 10.0   
Hardware: All   
OS: All   
Whiteboard:

Description Andrew Audibert CLA 2015-09-01 09:38:23 EDT
Repro:
1. Link a directory to Orion with orion.file.allowedPaths=/path/to/directory.
2. Create a git repo in the linked directory. (mkdir repo && cd repo && git init)
3. Create a file with a SHORTER name than the git repo's name in the linked directory (not inside the git repo)
4. Navigate to the git repo in the Orion UI. GitFileDecorator will get confused thinking the file is inside the git repo, and throw a StringIndexOutOfBoundsException.
Comment 1 John Arthorne CLA 2015-09-02 10:22:55 EDT
I am seeing this in server logs as well. Here is a sample stack:

java.lang.StringIndexOutOfBoundsException: String index out of range: 78
	at java.lang.String.substring(String.java:1219) ~[na:1.7.0]
	at org.eclipse.orion.server.git.GitFileDecorator.addGitLinks(GitFileDecorator.java:223) ~[na:na]
	at org.eclipse.orion.server.git.GitFileDecorator.addAtributesFor(GitFileDecorator.java:118) ~[na:na]
	at org.eclipse.orion.server.servlets.OrionServlet.decorateResponse(OrionServlet.java:120) [org.eclipse.orion.server.servlets_1.0.0.v20150807-1716.jar:na]