Sitelet https://github.com/JavaJens/libtextsecure-java/commit/978c2d81edddd63fe5002d313eee4c3f257df32b
Skip to content

Commit 978c2d8

Browse files
committed
Merge pull request #1 from f41c0r/fix/maven_local
Update from upstream to 1.62(2.62)
2 parents 69bea48 + 3a136e4 commit 978c2d8

3 files changed

Lines changed: 42 additions & 29 deletions

File tree

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
subprojects {
2-
ext.version_number = "2.6.0"
2+
ext.version_number = "2.6.2"
33
ext.group_info = "org.whispersystems"
44
ext.axolotl_version = "1.3.1"
55

‎java/src/main/java/org/whispersystems/textsecure/internal/push/PushServiceSocket.java‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.whispersystems.textsecure.internal.push;
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.core.JsonProcessingException;
2021

2122
import org.apache.http.conn.ssl.StrictHostnameVerifier;
2223
import org.whispersystems.libaxolotl.IdentityKey;
@@ -259,8 +260,6 @@ public List<PreKeyBundle> getPreKeys(TextSecureAddress destination, int deviceId
259260
}
260261

261262
return bundles;
262-
} catch (JsonUtil.JsonParseException e) {
263-
throw new IOException(e);
264263
} catch (NotFoundException nfe) {
265264
throw new UnregisteredUserException(destination.getNumber(), nfe);
266265
}
@@ -301,8 +300,6 @@ public PreKeyBundle getPreKey(TextSecureAddress destination, int deviceId) throw
301300

302301
return new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId, preKey,
303302
signedPreKeyId, signedPreKey, signedPreKeySignature, response.getIdentityKey());
304-
} catch (JsonUtil.JsonParseException e) {
305-
throw new IOException(e);
306303
} catch (NotFoundException nfe) {
307304
throw new UnregisteredUserException(destination.getNumber(), nfe);
308305
}
@@ -359,11 +356,16 @@ public void retrieveAttachment(String relay, long attachmentId, File destination
359356
public List<ContactTokenDetails> retrieveDirectory(Set<String> contactTokens)
360357
throws NonSuccessfulResponseCodeException, PushNetworkException
361358
{
362-
ContactTokenList contactTokenList = new ContactTokenList(new LinkedList<>(contactTokens));
363-
String response = makeRequest(DIRECTORY_TOKENS_PATH, "PUT", JsonUtil.toJson(contactTokenList));
364-
ContactTokenDetailsList activeTokens = JsonUtil.fromJson(response, ContactTokenDetailsList.class);
359+
try {
360+
ContactTokenList contactTokenList = new ContactTokenList(new LinkedList<>(contactTokens));
361+
String response = makeRequest(DIRECTORY_TOKENS_PATH, "PUT", JsonUtil.toJson(contactTokenList));
362+
ContactTokenDetailsList activeTokens = JsonUtil.fromJson(response, ContactTokenDetailsList.class);
365363

366-
return activeTokens.getContacts();
364+
return activeTokens.getContacts();
365+
} catch (IOException e) {
366+
Log.w(TAG, e);
367+
throw new NonSuccessfulResponseCodeException("Unable to parse entity");
368+
}
367369
}
368370

369371
public ContactTokenDetails getContactTokenDetails(String contactToken) throws IOException {
@@ -501,26 +503,45 @@ private HttpURLConnection makeBaseRequest(String urlFragment, String method, Str
501503
connection.disconnect();
502504
throw new NotFoundException("Not found");
503505
case 409:
506+
MismatchedDevices mismatchedDevices;
507+
504508
try {
505-
response = Util.readFully(connection.getErrorStream());
509+
response = Util.readFully(connection.getErrorStream());
510+
mismatchedDevices = JsonUtil.fromJson(response, MismatchedDevices.class);
511+
} catch (JsonProcessingException e) {
512+
Log.w(TAG, e);
513+
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
506514
} catch (IOException e) {
507515
throw new PushNetworkException(e);
508516
}
509-
throw new MismatchedDevicesException(JsonUtil.fromJson(response, MismatchedDevices.class));
517+
518+
throw new MismatchedDevicesException(mismatchedDevices);
510519
case 410:
520+
StaleDevices staleDevices;
521+
511522
try {
512-
response = Util.readFully(connection.getErrorStream());
523+
response = Util.readFully(connection.getErrorStream());
524+
staleDevices = JsonUtil.fromJson(response, StaleDevices.class);
525+
} catch (JsonProcessingException e) {
526+
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
513527
} catch (IOException e) {
514528
throw new PushNetworkException(e);
515529
}
516-
throw new StaleDevicesException(JsonUtil.fromJson(response, StaleDevices.class));
530+
531+
throw new StaleDevicesException(staleDevices);
517532
case 411:
533+
DeviceLimit deviceLimit;
534+
518535
try {
519-
response = Util.readFully(connection.getErrorStream());
536+
response = Util.readFully(connection.getErrorStream());
537+
deviceLimit = JsonUtil.fromJson(response, DeviceLimit.class);
538+
} catch (JsonProcessingException e) {
539+
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
520540
} catch (IOException e) {
521541
throw new PushNetworkException(e);
522542
}
523-
throw new DeviceLimitExceededException(JsonUtil.fromJson(response, DeviceLimit.class));
543+
544+
throw new DeviceLimitExceededException(deviceLimit);
524545
case 417:
525546
throw new ExpectationFailedException();
526547
}

‎java/src/main/java/org/whispersystems/textsecure/internal/util/JsonUtil.java‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import com.fasterxml.jackson.core.JsonGenerator;
5+
import com.fasterxml.jackson.core.JsonParseException;
56
import com.fasterxml.jackson.core.JsonParser;
67
import com.fasterxml.jackson.core.JsonProcessingException;
78
import com.fasterxml.jackson.databind.DeserializationContext;
@@ -36,21 +37,12 @@ public static String toJson(Object object) {
3637
}
3738
}
3839

39-
public static <T> T fromJson(String json, Class<T> clazz) {
40-
try {
41-
return objectMapper.readValue(json, clazz);
42-
} catch (IOException e) {
43-
Log.w(TAG, e);
44-
throw new JsonParseException(e);
45-
}
40+
public static <T> T fromJson(String json, Class<T> clazz)
41+
throws IOException
42+
{
43+
return objectMapper.readValue(json, clazz);
4644
}
47-
48-
public static class JsonParseException extends RuntimeException {
49-
public JsonParseException(Exception e) {
50-
super(e);
51-
}
52-
}
53-
45+
5446
public static class IdentityKeySerializer extends JsonSerializer<IdentityKey> {
5547
@Override
5648
public void serialize(IdentityKey value, JsonGenerator gen, SerializerProvider serializers)

0 commit comments

Comments
 (0)