Buggy code:
public static boolean jsFunction_addAPISubscription ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws APIManagementException { } public static boolean jsFunction_removeSubscriber ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws APIManagementException { } public static NativeArray jsFunction_rateAPI ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } public static NativeArray jsFunction_removeAPIRating ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } public static NativeArray jsFunction_getSubscriptions ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } public static String jsFunction_getSwaggerDiscoveryUrl ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws APIManagementException { } public static NativeObject jsFunction_getSwaggerResource ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } private static APIKey getKey ( SubscribedAPI api , String keyType ) { } private static APIKey getAppKey ( Application app , String keyType ) { } private static APIKey getKeyOfType ( List < APIKey > apiKeys , String keyType ) { } public static NativeObject jsFunction_createApplicationKeys ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } public static NativeArray jsFunction_getAllSubscriptions ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) throws ScriptException , APIManagementException { } private static void addAPIObj ( SubscribedAPI subscribedAPI , NativeArray apisArray , Scriptable thisObj , Application appObject ) throws APIManagementException { NativeObject apiObj = new NativeObject ( ) ; APIConsumer apiConsumer = APIStoreHostObject . getAPIConsumer ( thisObj ) ; ApiMgtDAO apiMgtDAO = new ApiMgtDAO ( ) ; try { API api = apiConsumer . getAPIInfo ( subscribedAPI . getApiId ( ) ) ; apiObj . put ( "name" , apiObj , subscribedAPI . getApiId ( ) . getApiName ( ) ) ; apiObj . put ( "provider" , apiObj , APIUtil . replaceEmailDomainBack ( subscribedAPI . getApiId ( ) . getProviderName ( ) ) ) ; apiObj . put ( "version" , apiObj , subscribedAPI . getApiId ( ) . getVersion ( ) ) ; apiObj . put ( "status" , apiObj , api . getStatus ( ) . toString ( ) ) ; apiObj . put ( "tier" , apiObj , subscribedAPI . getTier ( ) . getDisplayName ( ) ) ; apiObj . put ( "subStatus" , apiObj , subscribedAPI . getSubStatus ( ) ) ; apiObj . put ( "thumburl" , apiObj , APIUtil . prependWebContextRoot ( api . getThumbnailUrl ( ) ) ) ; apiObj . put ( "context" , apiObj , api . getContext ( ) ) ; APIKey prodKey = APIStoreHostObject . getAppKey ( appObject , API_KEY_TYPE_PRODUCTION ) ; if ( prodKey != null ) { apiObj . put ( "prodKey" , apiObj , prodKey . getAccessToken ( ) ) ; apiObj . put ( "prodConsumerKey" , apiObj , prodKey . getConsumerKey ( ) ) ; apiObj . put ( "prodConsumerSecret" , apiObj , prodKey . getConsumerSecret ( ) ) ; apiObj . put ( "prodAuthorizedDomains" , apiObj , prodKey . getAuthorizedDomains ( ) ) ; if ( APIStoreHostObject . isApplicationAccessTokenNeverExpire ( prodKey . getValidityPeriod ( ) ) ) { apiObj . put ( "prodValidityTime" , apiObj , ( - 1 ) ) ; } else { apiObj . put ( "prodValidityTime" , apiObj , prodKey . getValidityPeriod ( ) ) ; } } else { apiObj . put ( "prodKey" , apiObj , null ) ; apiObj . put ( "prodConsumerKey" , apiObj , null ) ; apiObj . put ( "prodConsumerSecret" , apiObj , null ) ; apiObj . put ( "prodAuthorizedDomains" , apiObj , null ) ; if ( APIStoreHostObject . isApplicationAccessTokenNeverExpire ( APIStoreHostObject . getApplicationAccessTokenValidityPeriodInSeconds ( ) ) ) { apiObj . put ( "prodValidityTime" , apiObj , ( - 1 ) ) ; } else { apiObj . put ( "prodValidityTime" , apiObj , ( ( APIStoreHostObject . getApplicationAccessTokenValidityPeriodInSeconds ( ) ) * 1000 ) ) ; } } <START_BUG> APIKey sandboxKey = APIStoreHostObject . getAppKey ( subscribedAPI . getApplication ( ) , API_KEY_TYPE_SANDBOX ) ; <END_BUG> if ( sandboxKey != null ) { apiObj . put ( "sandboxKey" , apiObj , sandboxKey . getAccessToken ( ) ) ; apiObj . put ( "sandboxConsumerKey" , apiObj , sandboxKey . getConsumerKey ( ) ) ; apiObj . put ( "sandboxConsumerSecret" , apiObj , sandboxKey . getConsumerSecret ( ) ) ; apiObj . put ( "sandAuthorizedDomains" , apiObj , sandboxKey . getAuthorizedDomains ( ) ) ; if ( APIStoreHostObject . isApplicationAccessTokenNeverExpire ( sandboxKey . getValidityPeriod ( ) ) ) { apiObj . put ( "sandValidityTime" , apiObj , ( - 1 ) ) ; } else { apiObj . put ( "sandValidityTime" , apiObj , sandboxKey . getValidityPeriod ( ) ) ; } } else { apiObj . put ( "sandboxKey" , apiObj , null ) ; apiObj . put ( "sandboxConsumerKey" , apiObj , null ) ; apiObj . put ( "sandboxConsumerSecret" , apiObj , null ) ; apiObj . put ( "sandAuthorizedDomains" , apiObj , null ) ; if ( ( APIStoreHostObject . getApplicationAccessTokenValidityPeriodInSeconds ( ) ) < 0 ) { apiObj . put ( "sandValidityTime" , apiObj , ( - 1 ) ) ; } else { apiObj . put ( "sandValidityTime" , apiObj , ( ( APIStoreHostObject . getApplicationAccessTokenValidityPeriodInSeconds ( ) ) * 1000 ) ) ; } } apiObj . put ( "hasMultipleEndpoints" , apiObj , String . valueOf ( ( ( api . getSandboxUrl ( ) ) != null ) ) ) ; apisArray . put ( apisArray . getIds ( ) . length , apisArray , apiObj ) ; } catch ( APIManagementException e ) { APIStoreHostObject . handleException ( "Error<seq2seq4repair_space>while<seq2seq4repair_space>obtaining<seq2seq4repair_space>application<seq2seq4repair_space>metadata" , e ) ;

Fix:
APIKey sandboxKey = APIStoreHostObject . getAppKey ( appObject , API_KEY_TYPE_SANDBOX ) ;