[Demonstration 1]

[Buggy Method]
public static BasicLTILauncher buildLauncher(Id courseId, Id contentId, Id userId, HttpServletRequest request) {
    String bltiUrl = "";
    String bltiKey = "";
    String bltiSecret = "";
    Content courseDoc = null;
    CourseMembership membership = null;
    Preferences prefs = Preferences.systemRoot();
    bltiUrl = prefs.get(BLTI_URL, "http://54.242.225.150/lti");
    bltiKey = prefs.get(BLTI_KEY, "12345");
    bltiSecret = prefs.get(BLTI_SECRET, "secret");
    try {
        membership = CourseMembershipDbLoader.Default.getInstance().loadByCourseAndUserId(courseId, userId);
        courseDoc = ContentDbLoader.Default.getInstance().loadById(contentId);
    } catch (Exception e) {
    }
    String contentHandler = courseDoc.getContentHandler();
    String contentType = "";
    if (contentHandler == "resource/x-bbap-lti1-sample2")
        contentType = "Assessment";
    else
        contentType = "Content";
    // create a map for storing custom Basic LTI Parameters
    HashMap<String, String> customParamMap = new HashMap<String, String>();
    // Add custom BLTI Parameters
    customParamMap.put("contentType", contentType.toString());
    customParamMap.put("customParameter1", courseDoc.getExtendedData().getValue("customParameter1"));
    customParamMap.put("customParameter2", courseDoc.getExtendedData().getValue("customParameter2"));
    customParamMap.put("customParameter3", courseDoc.getExtendedData().getValue("customParameter3"));
    customParamMap.put("customParameter4", courseDoc.getExtendedData().getValue("customParameter4"));
    //create a map for storing custom presentation parameters
    HashMap<String, String> customPresentationParams = new HashMap<String, String>();
    String strReturnUrl = PlugInUtil.getEditableContentReturnURL(courseDoc.getParentId(), courseId);
    //add custom presentation parameters
    customPresentationParams.put("PARAM_LAUNCH_PRESENTATION_RETURN_URL", strReturnUrl.toString());
    /* 
		 *		Instantiate BasicLTILauncher object
		 *		BasicLTILauncher(String url, String key, String secret, String resourceLinkID)
		 *			.addResourceLinkInformation(String title, String description)
		 *			.addCurrentUserInformation(boolean includeRole, boolean includeName, boolean includeEmail)
		 *			.addCurrentCourseInformation(void)
		 *			.addCustomToolParameters (Map<String, String> params)
		 *			.addLaunchPresentationInformation (Map<String,String> params);
		 */
    BasicLTILauncher launcher = new BasicLTILauncher(bltiUrl, bltiKey, bltiSecret, contentHandler.toString()).addResourceLinkInformation("IMS Global " + contentType, "Basic LTI Connection to the IMS Global " + contentType).addCurrentUserInformation(true, true, true, BasicLTILauncher.IdTypeToSend.UUID).addCurrentCourseInformation(BasicLTILauncher.IdTypeToSend.UUID).addCustomToolParameters(customParamMap).addGradingInformation(request, courseDoc, membership).addLaunchPresentationInformation(customPresentationParams);
    //Launch BLTI connection
    //launch(HttpServletRequest request, HttpServletResponse response, boolean showSplashScreen, FormattedText splashMessage)
    return (launcher);
}

[Buggy Hunk]
Preferences prefs = Preferences.systemRoot();

[Patch]
Preferences prefs = Preferences.systemNodeForPackage(PrefUtil.class);

[Demonstration 2]

[Buggy Method]
public Data getCatalog(Name name) {
    if (!NDNFitCommon.CATALOG_PREFIX.match(name))
        return null;
    String[] columns = { "timepoint", "version", "data", "uploaded" };
    try {
        Cursor cursor;
        if (name.compare(NDNFitCommon.CATALOG_PREFIX) == 0) {
            cursor = mDB.query(CATALOG_TABLE, columns, null, null, null, null, "timepoint ASC");
        } else {
            cursor = mDB.query(CATALOG_TABLE, columns, "timepoint = " + (long) Schedule.fromIsoString(name.get(-1).toEscapedString()) * 1000, null, null, null, null);
        }
        if (cursor.moveToNext()) {
            byte[] raw = cursor.getBlob(2);
            Data data = new Data();
            data.wireDecode(new Blob(raw));
            return data;
        }
    } catch (EncodingException e) {
        e.printStackTrace();
    }
    return null;
}

[Buggy Hunk]
cursor = mDB.query(CATALOG_TABLE, columns, "timepoint = " + (long) Schedule.fromIsoString(name.get(-1).toEscapedString()) * 1000,

[Patch]
cursor = mDB.query(CATALOG_TABLE, columns, "timepoint = " + (long) Schedule.fromIsoString(name.get(8).toEscapedString()) * 1000,

[Demonstration 3]

[Buggy Method]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Hiding title
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_chat);
    //Person name from main activity
    Intent intent = getIntent();
    name = intent.getStringExtra("Name");
    Log.d("Name", name);
    //Initialization of variables
    inputMsg = (EditText) findViewById(R.id.msgInput);
    btnSend = (Button) findViewById(R.id.sendBtn);
    listViewMsg = (ListView) findViewById(R.id.msgListView);
    btnLeave = (Button) findViewById(R.id.leaveBtn);
    sp = this.getSharedPreferences("com.example.myChatApp", 0);
    androidClient = new WebSocketClient(URI.create(WEBSOCKETURL + URLEncoder.encode(name)), new WebSocketClient.Listener() {

        @Override
        public void onMessage(byte[] arg0) {
            // TODO Auto-generated method stub
            Log.d("Calling", "onMessage byte");
        }

        @Override
        public void onMessage(String msg) {
            // TODO Auto-generated method stub
            Log.d("Calling", "onMessage string");
            Log.d("Msg", msg);
            checkmsg(msg);
        }

        @Override
        public void onError(Exception arg0) {
            // TODO Auto-generated method stub
            Log.d("Calling", "onError");
            Log.e(ChatActivity.class.getSimpleName(), "Error! : " + arg0);
        }

        @Override
        public void onDisconnect(int arg0, String arg1) {
            // TODO Auto-generated method stub
            Log.d("Calling", "onDisconnect");
        }

        @Override
        public void onConnect() {
            // TODO Auto-generated method stub
            Log.d("Calling", "onConnect");
        }
    }, null);
    androidClient.connect();
    //Send Button Click Event
    btnSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            androidClient.send(inputMsg.getText().toString());
        }
    });
    //Leave Button Click Event
    btnLeave.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            androidClient.disconnect();
            ChatActivity.this.finish();
        }
    });
}

[Buggy Hunk]
sp = this.getSharedPreferences("com.example.myChatApp", 0);

[Patch]
sp = this.getSharedPreferences("com.example.myChatApp", Context.MODE_PRIVATE);