Buggy code:
public class StratosApiV41Utils { public static final String IS_VOLUME_REQUIRED = "volume.required" ; public static final String SHOULD_DELETE_VOLUME = "volume.delete.on.unsubscription" ; public static final String VOLUME_SIZE = "volume.size.gb" ; public static final String DEVICE_NAME = "volume.device.name" ; public static final String VOLUME_ID = "volume.id" ; public static final String TENANT_RANGE_ALL = "*" ; public static final String APPLICATION_STATUS_DEPLOYED = "Deployed" ; private static Log log = LogFactory . getLog ( StratosApiV41Utils . class ) ; public static void addCartridge ( CartridgeBean cartridgeDefinition ) throws RestAPIException { } public static void removeCartridge ( String cartridgeType ) throws RestAPIException { } public static List < CartridgeBean > getCartridgesByFilter ( String filter , String criteria , ConfigurationContext configurationContext ) throws RestAPIException { } public static CartridgeBean getCartridgeByFilter ( String filter , String cartridgeType , ConfigurationContext configurationContext ) throws RestAPIException { } private static List < CartridgeBean > getAvailableLbCartridges ( Boolean multiTenant , ConfigurationContext configurationContext ) throws RestAPIException { } private static List < CartridgeBean > getAvailableCartridgesByProvider ( String provider , ConfigurationContext configurationContext ) throws RestAPIException { } public static List < CartridgeBean > getAvailableCartridges ( String cartridgeSearchString , Boolean multiTenant , ConfigurationContext configurationContext ) throws RestAPIException { } public static CartridgeBean getCartridge ( String cartridgeType ) throws RestAPIException { } private static CartridgeBean convertCartridgeToCartridgeDefinitionBean ( CartridgeInfo cartridgeInfo ) { } private static PersistenceBean convertPersistenceToPersistenceBean ( Persistence persistence ) { } private static List < VolumeBean > convertVolumesToVolumeBeans ( Volume [ ] volumes ) { } private static boolean isAlreadySubscribed ( String cartridgeType , int tenantId ) { } private static Pattern getSearchStringPattern ( String searchString ) { } private static boolean cartridgeMatches ( CartridgeInfo cartridgeInfo , Pattern pattern ) { } private static CloudControllerServiceClient getCloudControllerServiceClient ( ) throws RestAPIException { } private static AutoscalerServiceClient getAutoscalerServiceClient ( ) throws RestAPIException { } public static void addAutoscalingPolicy ( AutoscalePolicyBean autoscalePolicyBean ) throws RestAPIException { } public static void updateAutoscalingPolicy ( AutoscalePolicyBean autoscalePolicyBean ) throws RestAPIException { } public static AutoscalePolicyBean [ ] getAutoScalePolicies ( ) throws RestAPIException { } public static AutoscalePolicyBean getAutoScalePolicy ( String autoscalePolicyId ) throws RestAPIException { } public static DeploymentPolicyBean getDeploymentPolicy ( String applicationId ) throws RestAPIException { } public static ApplicationLevelNetworkPartitionBean [ ] getPartitionGroups ( String deploymentPolicyId ) throws RestAPIException { } public static void notifyArtifactUpdatedEvent ( GitNotificationPayloadBean payload ) throws RestAPIException { } public static void addServiceGroup ( GroupBean serviceGroupDefinition ) throws RestAPIException { } private static Set < String > findDuplicates ( List < String > checkedList ) { } public static GroupBean getServiceGroupDefinition ( String name ) throws RestAPIException { } public static GroupBean [ ] getServiceGroupDefinitions ( ) throws RestAPIException { } public static void removeServiceGroup ( String name ) throws RestAPIException { } public static void addApplication ( ApplicationBean appDefinition , ConfigurationContext ctxt , String userName , String tenantDomain ) throws RestAPIException { try { if ( ( AutoscalerServiceClient . getInstance ( ) . getApplication ( appDefinition . getApplicationId ( ) ) ) != null ) { String msg = "Application<seq2seq4repair_space>already<seq2seq4repair_space>exists:<seq2seq4repair_space>[application-id]<seq2seq4repair_space>" + ( appDefinition . getApplicationId ( ) ) ; throw new RestAPIException ( msg ) ; } } catch ( RemoteException e ) { throw new RestAPIException ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>read<seq2seq4repair_space>application" , e ) ; } ApplicationContext applicationContext = ObjectConverter . convertApplicationDefinitionToStubApplicationContext ( appDefinition ) ; applicationContext . setTenantId ( ApplicationManagementUtil . getTenantId ( ctxt ) ) ; applicationContext . setTenantDomain ( tenantDomain ) ; <START_BUG> applicationContext . setTeantAdminUsername ( userName ) ; <END_BUG> if ( ( appDefinition . getProperty ( ) ) != null ) { Properties properties = new Properties ( ) ; for ( PropertyBean propertyBean : appDefinition . getProperty ( ) ) { Property property = new Property ( ) ; property . setName ( propertyBean . getName ( ) ) ; property . setValue ( propertyBean . getValue ( ) ) ; properties . addProperties ( property ) ; } applicationContext . setProperties ( properties ) ; } try { AutoscalerServiceClient . getInstance ( ) . addApplication ( applicationContext ) ; } catch ( AutoScalerServiceApplicationDefinitionExceptionException e ) { throw new RestAPIException ( e ) ; } catch ( RemoteException e ) { throw new RestAPIException ( e ) ; } } public static void deployApplication ( String applicationId , DeploymentPolicyBean deploymentPolicy ) throws RestAPIException { } public static void removeApplication ( String applicationId ) throws RestAPIException { } public static ApplicationBean getApplication ( String applicationId ) throws RestAPIException { } public static List < ApplicationBean > getApplications ( ) throws RestAPIException { } public static void undeployApplication ( String applicationId ) throws RestAPIException { } public static ApplicationInfoBean [ ] getApplicationRuntimes ( ) { } public static ApplicationInfoBean getApplicationInstanceRuntime ( String applicationId ) { } private static void addGroupsInstancesToApplicationInstanceBean ( ApplicationInstanceBean applicationInstanceBean , Application application ) { } private static void addClustersInstancesToApplicationInstanceBean ( ApplicationInstanceBean applicationInstanceBean , Application application ) { } private static void addClustersInstancesToGroupInstanceBean ( GroupInstanceBean groupInstanceBean , Group group ) { } private static void setSubGroupInstances ( Group group , GroupInstanceBean groupInstanceBean ) { } public static boolean addKubernetesCluster ( KubernetesClusterBean kubernetesClusterBean ) throws RestAPIException { } public static boolean addKubernetesHost ( String kubernetesClusterId , KubernetesHostBean kubernetesHostBean ) throws RestAPIException { } public static boolean updateKubernetesMaster ( KubernetesMasterBean kubernetesMasterBean ) throws RestAPIException { } public static KubernetesClusterBean [ ] getAvailableKubernetesClusters ( ) throws RestAPIException { } public static KubernetesClusterBean getKubernetesCluster ( String kubernetesClusterId ) throws RestAPIException { } public static boolean removeKubernetesCluster ( String kubernetesClusterId ) throws RestAPIException { } public static boolean removeKubernetesHost ( String kubernetesHostId ) throws RestAPIException { } public static KubernetesHostBean [ ] getKubernetesHosts ( String kubernetesClusterId ) throws RestAPIException { } public static KubernetesMasterBean getKubernetesMaster ( String kubernetesClusterId ) throws RestAPIException { } public static boolean updateKubernetesHost ( KubernetesHostBean kubernetesHostBean ) throws RestAPIException { } public static void addApplicationSignUp ( String applicationId , ApplicationSignUpBean applicationSignUpBean ) throws RestAPIException { } private static void encryptRepositoryPasswords ( ApplicationSignUp applicationSignUp , String applicationKey ) { } public static ApplicationSignUpBean getApplicationSignUp ( String applicationId ) throws RestAPIException { }

Fix:
applicationContext . setTenantAdminUsername ( userName ) ;