I have the strangest case which challenges my understanding about the fundamental way Java works.
I have the following code which I step through using the debugger to the "return result == "OK" line, where I expect the execution for this method to finish. But it doesn't! If I continue stepping with the debugger, I see that it steps to the very last line (without throwing an exception) and returns false!
Can anyone shed any light on this?
protected Boolean doInBackground(Void... params) {
try
{
String json = buildJson();
String encryptedData = encrypt(json);
String base64Data = Base64.encode(encryptedData.getBytes(UTF8));
String url = webserviceUrl + "?data=" + base64Data;
String result = readUrl(url);
return (result == "OK"); // Debugger gets to here but doesn't return!
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false; // Debugger gets to here instead, and returns false!
}