Buggy code:
public class RuleManagerComponent extends SearchComponent implements SolrCoreAware { public static final int PAGE_SIZE = 40 ; public static final String RANKING_SEPARATOR = "|" ; public static final String CUSTOM_RANKING_PARAM_NAME = "customRankingRule" ; private static Logger logger = LoggerFactory . getLogger ( RuleManagerComponent . class ) ; CoreContainer coreContainer = null ; String rulesCoreBaseName = "rule" ; String facetsCoreBaseName = "facets" ; String categoriesCoreBaseName = "categories" ; String rulesCoreName ; String facetsCoreName ; DocumentObjectBinder binder = new DocumentObjectBinder ( ) ; public enum PageType { search , category , rule ; } @ Override public void init ( NamedList args ) { } public void inform ( SolrCore core ) { } @ Override public String getDescription ( ) { } @ Override public String getSource ( ) { } @ Override public void prepare ( ResponseBuilder rb ) { } @ Override public void process ( ResponseBuilder rb ) throws IOException { } private String getCoreName ( SolrCore core , String baseName ) { } private String getCoreName ( SolrCore core , String baseName , boolean hasLocale ) { } public SearchHandler getSearchHandler ( SolrCore core ) throws IOException { } private static RuleManagerComponent . PageType getPageType ( SolrParams requestParams ) { } private Map < RuleManagerComponent . RuleType , List < Document > > searchRules ( SolrParams requestParams , RuleManagerComponent . PageType pageType ) throws IOException { } private boolean filterExactMatch ( String q , Document rule ) { } private boolean isExactMatch ( String query ) { } private String removeBrackets ( String query ) { } protected SolrQuery getRulesQuery ( SolrParams requestParams , RuleManagerComponent . PageType pageType ) throws IOException { } private String getTargetFilter ( StringBuilder reusableStringBuilder , RuleManagerComponent . PageType pageType , String q ) throws IOException { StringBuilder targetFilter = reuseStringBuilder ( reusableStringBuilder ) ; if ( pageType == ( RuleManagerComponent . PageType . search ) ) { if ( StringUtils . isEmpty ( q ) ) { throw new IOException ( "Cannot<seq2seq4repair_space>process<seq2seq4repair_space>search<seq2seq4repair_space>request<seq2seq4repair_space>because<seq2seq4repair_space>the<seq2seq4repair_space>'q'<seq2seq4repair_space>param<seq2seq4repair_space>is<seq2seq4repair_space>empty." ) ; } targetFilter . append ( "(target:allpages<seq2seq4repair_space>OR<seq2seq4repair_space>target:searchpages)<seq2seq4repair_space>AND<seq2seq4repair_space>((" ) ; <START_BUG> targetFilter . append ( ClientUtils . escapeQueryChars ( q ) ) ; <END_BUG> targetFilter . append ( ")^2<seq2seq4repair_space>OR<seq2seq4repair_space>query:__all__)" ) ; } else { targetFilter . append ( "target:allpages<seq2seq4repair_space>OR<seq2seq4repair_space>target:categorypages" ) ; } return targetFilter . toString ( ) ; } private String getCategoryFilter ( StringBuilder reusableStringBuilder , String categoryToken ) { } private String getSiteFilter ( StringBuilder reusableStringBuilder , String [ ] sites ) { } private String getBrandFilter ( StringBuilder reusableStringBuilder , String brandId ) { } private String getSubTargetFilter ( StringBuilder reusableStringBuilder , boolean isOutletPage ) { } private StringBuilder reuseStringBuilder ( StringBuilder stringBuilder ) { } private boolean isOutletRequest ( String [ ] filterQueries ) { } SolrCore getFacetsCore ( ) { } private void addRuleToMap ( Map < RuleManagerComponent . RuleType , List < Document > > rulesMap , RuleManagerComponent . RuleType ruleType , Document ruleDoc ) { } private void setFilterQueries ( Map < String , NamedList > facets , SolrParams requestParams , MergedSolrParams ruleParams ) { } private Map < String , Object > getDebugInfo ( Map < RuleManagerComponent . RuleType , List < Document > > rulesMap , SolrParams ruleParams ) { } Function < Document , Map < String , String > > docToMapWithId = new Function < Document , Map < String , String > > ( ) { @ Override public Map < String , String > apply ( Document indexableFields ) { } } ; public enum RuleType { facetRule ( ) { void setParams ( RuleManagerComponent component , MergedSolrParams ruleParams , List < Document > rules , FacetHandler facetHandler ) throws IOException { } private void searchFacets ( RuleManagerComponent component , String facetsQueryString , FacetHandler facetHandler ) throws IOException { } private String getQueryString ( Document rule ) { } } , boostRule ( ) { void setParams ( RuleManagerComponent component , MergedSolrParams query , List < Document > rules , FacetHandler facetHandler ) { } } , blockRule ( ) { void setParams ( RuleManagerComponent component , MergedSolrParams query , List < Document > rules , FacetHandler facetHandler ) { } } , redirectRule ( ) { @ Override void setParams ( RuleManagerComponent component , MergedSolrParams query , List < Document > rules , FacetHandler facetHandler ) { } } , rankingRule ( ) { @ Override void setParams ( RuleManagerComponent component , MergedSolrParams query , List < Document > rules , FacetHandler facetHandler ) { } } ; boolean filterRule ( MergedSolrParams query , Document doc ) { } abstract void setParams ( RuleManagerComponent component , MergedSolrParams query , List < Document > rules , FacetHandler facetHandler ) throws IOException { } } }

Fix:
targetFilter . append ( q ) ;