Buggy code:
abstract class ContextLoaderUtils { private static final Log logger = LogFactory . getLog ( ContextLoaderUtils . class ) ; private static final String STANDARD_DEFAULT_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.support.GenericXmlContextLoader" ; private static final ContextLoaderUtils . ResourcePathLocationsResolver resourcePathLocationsResolver = new ContextLoaderUtils . ResourcePathLocationsResolver ( ) ; private static final ContextLoaderUtils . ClassNameLocationsResolver classNameLocationsResolver = new ContextLoaderUtils . ClassNameLocationsResolver ( ) ; static ContextLoader resolveContextLoader ( Class < ? > testClass , String defaultContextLoaderClassName ) { } @ SuppressWarnings ( "unchecked" ) static Class < ? extends ContextLoader > resolveContextLoaderClass ( Class < ? > clazz , String defaultContextLoaderClassName ) { } static String [ ] resolveContextLocations ( ContextLoader contextLoader , Class < ? > clazz ) { } static String [ ] resolveActiveProfiles ( Class < ? > clazz ) { Assert . notNull ( clazz , "Class<seq2seq4repair_space>must<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null" ) ; Class < ActiveProfiles > annotationType = ActiveProfiles . class ; Class < ? > declaringClass = AnnotationUtils . findAnnotationDeclaringClass ( annotationType , clazz ) ; if ( ( declaringClass == null ) && ( ContextLoaderUtils . logger . isDebugEnabled ( ) ) ) { ContextLoaderUtils . logger . debug ( String . format ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>find<seq2seq4repair_space>an<seq2seq4repair_space>'annotation<seq2seq4repair_space>declaring<seq2seq4repair_space>class'<seq2seq4repair_space>for<seq2seq4repair_space>annotation<seq2seq4repair_space>type<seq2seq4repair_space>[%s]<seq2seq4repair_space>and<seq2seq4repair_space>class<seq2seq4repair_space>[%s]" , annotationType , clazz ) ) ; } final Set < String > activeProfiles = new LinkedHashSet < String > ( ) ; while ( declaringClass != null ) { ActiveProfiles annotation = declaringClass . getAnnotation ( annotationType ) ; if ( ContextLoaderUtils . logger . isTraceEnabled ( ) ) { ContextLoaderUtils . logger . trace ( String . format ( "Retrieved<seq2seq4repair_space>@ActiveProfiles<seq2seq4repair_space>[%s]<seq2seq4repair_space>for<seq2seq4repair_space>declaring<seq2seq4repair_space>class<seq2seq4repair_space>[%s]." , activeProfiles , declaringClass ) ) ; } String [ ] profiles = annotation . profiles ( ) ; String [ ] valueProfiles = annotation . value ( ) ; if ( ( ! ( ObjectUtils . isEmpty ( valueProfiles ) ) ) && ( ! ( ObjectUtils . isEmpty ( profiles ) ) ) ) { String msg = String . format ( ( "Test<seq2seq4repair_space>class<seq2seq4repair_space>[%s]<seq2seq4repair_space>has<seq2seq4repair_space>been<seq2seq4repair_space>configured<seq2seq4repair_space>with<seq2seq4repair_space>@ActiveProfiles'<seq2seq4repair_space>'value'<seq2seq4repair_space>[%s]<seq2seq4repair_space>" + ( "and<seq2seq4repair_space>'profiles'<seq2seq4repair_space>[%s]<seq2seq4repair_space>attributes.<seq2seq4repair_space>Only<seq2seq4repair_space>one<seq2seq4repair_space>declaration<seq2seq4repair_space>of<seq2seq4repair_space>active<seq2seq4repair_space>bean<seq2seq4repair_space>" + "definition<seq2seq4repair_space>profiles<seq2seq4repair_space>is<seq2seq4repair_space>permitted<seq2seq4repair_space>per<seq2seq4repair_space>@ActiveProfiles<seq2seq4repair_space>annotation." ) ) , declaringClass , ObjectUtils . nullSafeToString ( valueProfiles ) , ObjectUtils . nullSafeToString ( profiles ) ) ; ContextLoaderUtils . logger . error ( msg ) ; throw new IllegalStateException ( msg ) ; } else if ( ! ( ObjectUtils . isEmpty ( valueProfiles ) ) ) { profiles = valueProfiles ; } for ( String profile : profiles ) { if ( StringUtils . hasText ( profile ) ) { <START_BUG> activeProfiles . add ( profile ) ; <END_BUG> } } declaringClass = ( annotation . inheritProfiles ( ) ) ? AnnotationUtils . findAnnotationDeclaringClass ( annotationType , declaringClass . getSuperclass ( ) ) : null ; } return StringUtils . toStringArray ( activeProfiles ) ; } private static interface LocationsResolver { String [ ] resolveLocations ( ContextConfiguration contextConfiguration , Class < ? > declaringClass ) { } } private static final class ResourcePathLocationsResolver implements ContextLoaderUtils . LocationsResolver { public String [ ] resolveLocations ( ContextConfiguration contextConfiguration , Class < ? > declaringClass ) { } } private static final class ClassNameLocationsResolver implements ContextLoaderUtils . LocationsResolver { public String [ ] resolveLocations ( ContextConfiguration contextConfiguration , Class < ? > declaringClass ) { } } }

Fix:
activeProfiles . add ( profile . trim ( ) ) ;