Fix minor inspection issues

This commit is contained in:
AsamK 2018-11-19 23:00:32 +01:00
parent 860ec6f5dc
commit 2ab70edc68
6 changed files with 13 additions and 14 deletions

View file

@ -30,8 +30,7 @@ public class JsonGroupStore {
}
public GroupInfo getGroup(byte[] groupId) {
GroupInfo g = groups.get(Base64.encodeBytes(groupId));
return g;
return groups.get(Base64.encodeBytes(groupId));
}
public List<GroupInfo> getGroups() {

View file

@ -94,7 +94,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
@Override
public IdentityKey getIdentity(SignalProtocolAddress address) {
List<Identity> identities = trustedKeys.get(address.getName());
if (identities == null) {
if (identities == null || identities.size() == 0) {
return null;
}
@ -102,7 +102,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
Identity maxIdentity = null;
for (Identity id : identities) {
final long time = id.getDateAdded().getTime();
if (maxDate <= time) {
if (maxIdentity == null || maxDate <= time) {
maxDate = time;
maxIdentity = id;
}
@ -123,7 +123,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
public static class JsonIdentityKeyStoreDeserializer extends JsonDeserializer<JsonIdentityKeyStore> {
@Override
public JsonIdentityKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public JsonIdentityKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
try {
@ -157,7 +157,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
public static class JsonIdentityKeyStoreSerializer extends JsonSerializer<JsonIdentityKeyStore> {
@Override
public void serialize(JsonIdentityKeyStore jsonIdentityKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
public void serialize(JsonIdentityKeyStore jsonIdentityKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
json.writeStartObject();
json.writeNumberField("registrationId", jsonIdentityKeyStore.getLocalRegistrationId());
json.writeStringField("identityKey", Base64.encodeBytes(jsonIdentityKeyStore.getIdentityKeyPair().serialize()));

View file

@ -56,7 +56,7 @@ class JsonPreKeyStore implements PreKeyStore {
public static class JsonPreKeyStoreDeserializer extends JsonDeserializer<JsonPreKeyStore> {
@Override
public JsonPreKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public JsonPreKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<Integer, byte[]> preKeyMap = new HashMap<>();
@ -82,7 +82,7 @@ class JsonPreKeyStore implements PreKeyStore {
public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonPreKeyStore> {
@Override
public void serialize(JsonPreKeyStore jsonPreKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
public void serialize(JsonPreKeyStore jsonPreKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
json.writeStartArray();
for (Map.Entry<Integer, byte[]> preKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject();

View file

@ -78,7 +78,7 @@ class JsonSessionStore implements SessionStore {
public static class JsonSessionStoreDeserializer extends JsonDeserializer<JsonSessionStore> {
@Override
public JsonSessionStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public JsonSessionStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<SignalProtocolAddress, byte[]> sessionMap = new HashMap<>();
@ -104,7 +104,7 @@ class JsonSessionStore implements SessionStore {
public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonSessionStore> {
@Override
public void serialize(JsonSessionStore jsonSessionStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
public void serialize(JsonSessionStore jsonSessionStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
json.writeStartArray();
for (Map.Entry<SignalProtocolAddress, byte[]> preKey : jsonSessionStore.sessions.entrySet()) {
json.writeStartObject();

View file

@ -73,7 +73,7 @@ class JsonSignedPreKeyStore implements SignedPreKeyStore {
public static class JsonSignedPreKeyStoreDeserializer extends JsonDeserializer<JsonSignedPreKeyStore> {
@Override
public JsonSignedPreKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public JsonSignedPreKeyStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<Integer, byte[]> preKeyMap = new HashMap<>();
@ -99,7 +99,7 @@ class JsonSignedPreKeyStore implements SignedPreKeyStore {
public static class JsonSignedPreKeyStoreSerializer extends JsonSerializer<JsonSignedPreKeyStore> {
@Override
public void serialize(JsonSignedPreKeyStore jsonPreKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
public void serialize(JsonSignedPreKeyStore jsonPreKeyStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
json.writeStartArray();
for (Map.Entry<Integer, byte[]> signedPreKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject();

View file

@ -11,8 +11,8 @@ public class Hex {
public static String toStringCondensed(byte[] bytes) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
appendHexChar(buf, bytes[i]);
for (final byte aByte : bytes) {
appendHexChar(buf, aByte);
}
return buf.toString();
}