Buggy code:
public class VirtualFireAlarmManagerService { private static Log log = LogFactory . getLog ( VirtualFireAlarmManagerService . class ) ; private final String SUPER_TENANT = "carbon.super" ; @ Context private HttpServletResponse response ; @ Path ( "//device//register" ) @ PUT public boolean register ( @ QueryParam ( "deviceId" ) String deviceId , @ QueryParam ( "name" ) String name , @ QueryParam ( "owner" ) String owner ) { } @ Path ( "//device//remove//{device_id}" ) @ DELETE public void removeDevice ( @ PathParam ( "device_id" ) String deviceId , @ Context HttpServletResponse response ) { } @ Path ( "//device//update//{device_id}" ) @ POST public boolean updateDevice ( @ PathParam ( "device_id" ) String deviceId , @ QueryParam ( "name" ) String name , @ Context HttpServletResponse response ) { } @ Path ( "//device//{device_id}" ) @ GET @ Consumes ( "application//json" ) @ Produces ( "application//json" ) public Device getDevice ( @ PathParam ( "device_id" ) String deviceId ) { } @ Path ( "//devices//{username}" ) @ GET @ Consumes ( "application//json" ) @ Produces ( "application//json" ) public Device [ ] getFirealarmDevices ( @ PathParam ( "username" ) String username ) { } @ Path ( "//device//{sketch_type}//download" ) @ GET @ Produces ( "application//octet-stream" ) public Response downloadSketch ( @ QueryParam ( "owner" ) String owner , @ PathParam ( "sketch_type" ) String sketchType ) { } @ Path ( "//device//{sketch_type}//generate_link" ) @ GET public Response generateSketchLink ( @ QueryParam ( "owner" ) String owner , @ PathParam ( "sketch_type" ) String sketchType ) { } private ZipArchive createDownloadFile ( String owner , String sketchType ) throws DeviceManagementException , AccessTokenException , DeviceControllerException { if ( owner == null ) { throw new IllegalArgumentException ( "Error<seq2seq4repair_space>on<seq2seq4repair_space>createDownloadFile()<seq2seq4repair_space>Owner<seq2seq4repair_space>is<seq2seq4repair_space>null!" ) ; } String deviceId = VirtualFireAlarmManagerService . shortUUID ( ) ; <START_BUG> TokenClient accessTokenClient = new TokenClient ( "firealarm" ) ; <END_BUG> AccessTokenInfo accessTokenInfo = null ; accessTokenInfo = accessTokenClient . getAccessToken ( owner , deviceId ) ; String accessToken = accessTokenInfo . getAccess_token ( ) ; String refreshToken = accessTokenInfo . getRefresh_token ( ) ; XmppAccount newXmppAccount = new XmppAccount ( ) ; newXmppAccount . setAccountName ( ( ( owner + "_" ) + deviceId ) ) ; newXmppAccount . setUsername ( deviceId ) ; newXmppAccount . setPassword ( accessToken ) ; String xmppEndPoint = XmppConfig . getInstance ( ) . getXmppControlQueue ( ) . getServerURL ( ) ; int indexOfChar = xmppEndPoint . lastIndexOf ( '//' ) ; if ( indexOfChar != ( - 1 ) ) { xmppEndPoint = xmppEndPoint . substring ( ( indexOfChar + 1 ) , xmppEndPoint . length ( ) ) ; } newXmppAccount . setEmail ( ( deviceId + "@wso2.com" ) ) ; XmppServerClient xmppServerClient = new XmppServerClient ( ) ; xmppServerClient . initControlQueue ( ) ; boolean status ; if ( XmppConfig . getInstance ( ) . isEnabled ( ) ) { status = xmppServerClient . createXMPPAccount ( newXmppAccount ) ; if ( ! status ) { String msg = ( ( ( "XMPP<seq2seq4repair_space>Account<seq2seq4repair_space>was<seq2seq4repair_space>not<seq2seq4repair_space>created<seq2seq4repair_space>for<seq2seq4repair_space>device<seq2seq4repair_space>-<seq2seq4repair_space>" + deviceId ) + "<seq2seq4repair_space>of<seq2seq4repair_space>owner<seq2seq4repair_space>-<seq2seq4repair_space>" ) + owner ) + ".<seq2seq4repair_space>XMPP<seq2seq4repair_space>might<seq2seq4repair_space>have<seq2seq4repair_space>been<seq2seq4repair_space>disabled<seq2seq4repair_space>in<seq2seq4repair_space>org.wso2.carbon.device.mgt.iot.common.config.server.configs" ; VirtualFireAlarmManagerService . log . warn ( msg ) ; throw new DeviceManagementException ( msg ) ; } } status = register ( deviceId , ( ( ( ( owner + "s_" ) + sketchType ) + "_" ) + ( deviceId . substring ( 0 , 3 ) ) ) , owner ) ; if ( ! status ) { String msg = ( ( ( "Error<seq2seq4repair_space>occurred<seq2seq4repair_space>while<seq2seq4repair_space>registering<seq2seq4repair_space>the<seq2seq4repair_space>device<seq2seq4repair_space>with<seq2seq4repair_space>" + "id:<seq2seq4repair_space>" ) + deviceId ) + "<seq2seq4repair_space>owner:" ) + owner ; throw new DeviceManagementException ( msg ) ; } ZipUtil ziputil = new ZipUtil ( ) ; ZipArchive zipFile = null ; zipFile = ziputil . downloadSketch ( owner , SUPER_TENANT , sketchType , deviceId , accessToken , refreshToken ) ; zipFile . setDeviceId ( deviceId ) ; return zipFile ; } private static String shortUUID ( ) { } }

Fix:
TokenClient accessTokenClient = new TokenClient ( VirtualFireAlarmConstants . DEVICE_TYPE ) ;