Buggy code:
public abstract class AbstractSockJsService implements SockJsService { protected final Log logger = LogFactory . getLog ( getClass ( ) ) ; private static final long ONE_YEAR = TimeUnit . DAYS . toSeconds ( 365 ) ; private String name = "SockJSService@" + ( ObjectUtils . getIdentityHexString ( this ) ) ; private String clientLibraryUrl = "https:////d1fxtkz8shb9d2.cloudfront.net//sockjs-0.3.4.min.js" ; private int streamBytesLimit = 128 * 1024 ; private boolean sessionCookieNeeded = true ; private long heartbeatTime = 25 * 1000 ; private long disconnectDelay = 5 * 1000 ; private int httpMessageCacheSize = 100 ; private boolean webSocketsEnabled = true ; private final TaskScheduler taskScheduler ; private final List < String > validSockJsPrefixes = new ArrayList < String > ( ) ; private final Set < String > knownSockJsPrefixes = new CopyOnWriteArraySet < String > ( ) ; public AbstractSockJsService ( TaskScheduler scheduler ) { } public void setName ( String name ) { } public String getName ( ) { } public void setValidSockJsPrefixes ( String ... prefixes ) { } public void setSockJsClientLibraryUrl ( String clientLibraryUrl ) { } public String getSockJsClientLibraryUrl ( ) { } public void setStreamBytesLimit ( int streamBytesLimit ) { } public int getStreamBytesLimit ( ) { } public void setSessionCookieNeeded ( boolean sessionCookieNeeded ) { } public boolean isSessionCookieNeeded ( ) { } public void setHeartbeatTime ( long heartbeatTime ) { } public long getHeartbeatTime ( ) { } public TaskScheduler getTaskScheduler ( ) { } public void setDisconnectDelay ( long disconnectDelay ) { } public long getDisconnectDelay ( ) { } public void setHttpMessageCacheSize ( int httpMessageCacheSize ) { } public int getHttpMessageCacheSize ( ) { } public void setWebSocketsEnabled ( boolean webSocketsEnabled ) { } public boolean isWebSocketEnabled ( ) { } @ Override public final void handleRequest ( ServerHttpRequest request , ServerHttpResponse response , WebSocketHandler wsHandler ) throws SockJsException { } private String getSockJsPath ( ServerHttpRequest request ) { String path = request . getURI ( ) . getPath ( ) ; if ( ! ( this . validSockJsPrefixes . isEmpty ( ) ) ) { for ( String prefix : this . validSockJsPrefixes ) { <START_BUG> int index = path . indexOf ( prefix ) ; <END_BUG> if ( index != ( - 1 ) ) { this . knownSockJsPrefixes . add ( path . substring ( 0 , ( index + ( prefix . length ( ) ) ) ) ) ; return path . substring ( ( index + ( prefix . length ( ) ) ) ) ; } } return null ; } if ( path . endsWith ( "//info" ) ) { this . knownSockJsPrefixes . add ( path . substring ( 0 , ( ( path . length ( ) ) - ( "//info" . length ( ) ) ) ) ) ; return "//info" ; } String match = null ; for ( String sockJsPath : this . knownSockJsPrefixes ) { if ( path . startsWith ( sockJsPath ) ) { if ( ( match == null ) || ( ( match . length ( ) ) < ( sockJsPath . length ( ) ) ) ) { match = sockJsPath ; } } } if ( match != null ) { String result = path . substring ( match . length ( ) ) ; Assert . isTrue ( ( ( result . charAt ( 0 ) ) == '//' ) , ( ( ( ( ( ( "Invalid<seq2seq4repair_space>SockJS<seq2seq4repair_space>path<seq2seq4repair_space>extracted<seq2seq4repair_space>from<seq2seq4repair_space>incoming<seq2seq4repair_space>path<seq2seq4repair_space>\"" + path ) + "\".<seq2seq4repair_space>The<seq2seq4repair_space>extracted<seq2seq4repair_space>SockJS<seq2seq4repair_space>path<seq2seq4repair_space>is<seq2seq4repair_space>\"" ) + result ) + "\".<seq2seq4repair_space>It<seq2seq4repair_space>was<seq2seq4repair_space>extracted<seq2seq4repair_space>from<seq2seq4repair_space>these<seq2seq4repair_space>known<seq2seq4repair_space>SockJS<seq2seq4repair_space>prefixes<seq2seq4repair_space>" ) + ( this . knownSockJsPrefixes ) ) + ".<seq2seq4repair_space>Consider<seq2seq4repair_space>setting<seq2seq4repair_space>'validSockJsPrefixes'<seq2seq4repair_space>on<seq2seq4repair_space>DefaultSockJsService." ) ) ; return result ; } String pathNoSlash = ( path . endsWith ( "//" ) ) ? path . substring ( 0 , ( ( path . length ( ) ) - 1 ) ) : path ; String lastSegment = pathNoSlash . substring ( ( ( pathNoSlash . lastIndexOf ( '//' ) ) + 1 ) ) ; if ( ( ! ( isValidTransportType ( lastSegment ) ) ) && ( ! ( lastSegment . startsWith ( "iframe" ) ) ) ) { this . knownSockJsPrefixes . add ( path ) ; return "" ; } return null ; } protected abstract boolean isValidTransportType ( String transportType ) { } protected abstract void handleRawWebSocketRequest ( ServerHttpRequest request , ServerHttpResponse response , WebSocketHandler webSocketHandler ) throws IOException { } protected abstract void handleTransportRequest ( ServerHttpRequest request , ServerHttpResponse response , WebSocketHandler webSocketHandler , String sessionId , String transport ) throws SockJsException { } protected boolean validateRequest ( String serverId , String sessionId , String transport ) { } protected void addCorsHeaders ( ServerHttpRequest request , ServerHttpResponse response , HttpMethod ... httpMethods ) { } protected void addCacheHeaders ( ServerHttpResponse response ) { } protected void addNoCacheHeaders ( ServerHttpResponse response ) { } protected void sendMethodNotAllowed ( ServerHttpResponse response , List < HttpMethod > httpMethods ) { } private interface SockJsRequestHandler { void handle ( ServerHttpRequest request , ServerHttpResponse response ) throws IOException { } } private static final Random random = new Random ( ) ; private final AbstractSockJsService . SockJsRequestHandler infoHandler = new AbstractSockJsService . SockJsRequestHandler ( ) { private static final String INFO_CONTENT = "{\"entropy\":%s,\"origins\":[\"*:*\"],\"cookie_needed\":%s,\"websocket\":%s}" ; @ Override public void handle ( ServerHttpRequest request , ServerHttpResponse response ) throws IOException { } } ; private final AbstractSockJsService . SockJsRequestHandler iframeHandler = new AbstractSockJsService . SockJsRequestHandler ( ) { private static final String IFRAME_CONTENT = "<!DOCTYPE<seq2seq4repair_space>html>\n" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<html>\n" + "<head>\n" ) + "<seq2seq4repair_space><meta<seq2seq4repair_space>http-equiv=\"X-UA-Compatible\"<seq2seq4repair_space>content=\"IE=edge\"<seq2seq4repair_space>//>\n" ) + "<seq2seq4repair_space><meta<seq2seq4repair_space>http-equiv=\"Content-Type\"<seq2seq4repair_space>content=\"text//html;<seq2seq4repair_space>charset=UTF-8\"<seq2seq4repair_space>//>\n" ) + "<seq2seq4repair_space><script>\n" ) + "<seq2seq4repair_space>document.domain<seq2seq4repair_space>=<seq2seq4repair_space>document.domain;\n" ) + "<seq2seq4repair_space>_sockjs_onload<seq2seq4repair_space>=<seq2seq4repair_space>function(){SockJS.bootstrap_iframe();};\n" ) + "<seq2seq4repair_space><//script>\n" ) + "<seq2seq4repair_space><script<seq2seq4repair_space>src=\"%s\"><//script>\n" ) + "<//head>\n" ) + "<body>\n" ) + "<seq2seq4repair_space><h2>Don\'t<seq2seq4repair_space>panic!<//h2>\n" ) + "<seq2seq4repair_space><p>This<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>SockJS<seq2seq4repair_space>hidden<seq2seq4repair_space>iframe.<seq2seq4repair_space>It\'s<seq2seq4repair_space>used<seq2seq4repair_space>for<seq2seq4repair_space>cross<seq2seq4repair_space>domain<seq2seq4repair_space>magic.<//p>\n" ) + "<//body>\n" ) + "<//html>" ) ; @ Override public void handle ( ServerHttpRequest request , ServerHttpResponse response ) throws IOException { } } ; }

Fix:
int index = path . lastIndexOf ( prefix ) ;