aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src
diff options
context:
space:
mode:
authorylecollen <ylecollen@amdocs.com>2017-01-02 14:18:12 +0100
committerylecollen <ylecollen@amdocs.com>2017-01-02 14:18:12 +0100
commit2a7c191d843e96704202b4804acdc870bf090082 (patch)
tree9d2684cc59432dc496a1cc5192d37884a0a55667 /java/android/OlmLibSdk/olm-sdk/src
parentb2b182161e489ba2db871472ffdb136f56b48054 (diff)
identityKeys / oneTimeKeys : remove useless try/catch blocks
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java36
1 files changed, 8 insertions, 28 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 3f65c97..d229535 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -241,23 +241,13 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
*/
public Map<String, String> identityKeys() {
JSONObject identityKeysJsonObj = null;
- byte identityKeysBuffer[];
+ byte[] identityKeysBuffer = identityKeysJni();
- if( null != (identityKeysBuffer = identityKeysJni())) {
+ if (null != identityKeysBuffer) {
try {
- String identityKeysString;
-
- try {
- identityKeysString = new String(identityKeysBuffer, "UTF-8");
- } catch (Exception e) {
- Log.e(LOG_TAG, "## identityKeys(): Exception : cannot convert with utf-8 charset " + e.getMessage());
- identityKeysString = new String(identityKeysBuffer);
- }
-
- identityKeysJsonObj = new JSONObject(identityKeysString);
+ identityKeysJsonObj = new JSONObject(new String(identityKeysBuffer, "UTF-8"));
//Log.d(LOG_TAG, "## identityKeys(): Identity Json keys=" + identityKeysJsonObj.toString());
- } catch (JSONException e) {
- identityKeysJsonObj = null;
+ } catch (Exception e) {
Log.e(LOG_TAG, "## identityKeys(): Exception - Msg=" + e.getMessage());
}
} else {
@@ -311,24 +301,14 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
* @return one time keys in string dictionary if operation succeed, null otherwise
*/
public Map<String, Map<String, String>> oneTimeKeys() {
- byte oneTimeKeysBuffer[];
JSONObject oneTimeKeysJsonObj = null;
+ byte[] oneTimeKeysBuffer = oneTimeKeysJni();
- if( null != (oneTimeKeysBuffer = oneTimeKeysJni())) {
+ if( null != oneTimeKeysBuffer) {
try {
- String oneTimeKeysString;
-
- try {
- oneTimeKeysString = new String(oneTimeKeysBuffer, "UTF-8");
- } catch (Exception e) {
- Log.e(LOG_TAG, "## oneTimeKeys(): Exception : cannot convert with utf-8 charset " + e.getMessage());
- oneTimeKeysString = new String(oneTimeKeysBuffer);
- }
-
- oneTimeKeysJsonObj = new JSONObject(new String(oneTimeKeysString));
+ oneTimeKeysJsonObj = new JSONObject(new String(new String(oneTimeKeysBuffer, "UTF-8")));
//Log.d(LOG_TAG, "## oneTimeKeys(): OneTime Json keys=" + oneTimeKeysJsonObj.toString());
- } catch (JSONException e) {
- oneTimeKeysJsonObj = null;
+ } catch (Exception e) {
Log.e(LOG_TAG, "## oneTimeKeys(): Exception - Msg=" + e.getMessage());
}
} else {