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) { public GroupInfo getGroup(byte[] groupId) {
GroupInfo g = groups.get(Base64.encodeBytes(groupId)); return groups.get(Base64.encodeBytes(groupId));
return g;
} }
public List<GroupInfo> getGroups() { public List<GroupInfo> getGroups() {

View file

@ -94,7 +94,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
@Override @Override
public IdentityKey getIdentity(SignalProtocolAddress address) { public IdentityKey getIdentity(SignalProtocolAddress address) {
List<Identity> identities = trustedKeys.get(address.getName()); List<Identity> identities = trustedKeys.get(address.getName());
if (identities == null) { if (identities == null || identities.size() == 0) {
return null; return null;
} }
@ -102,7 +102,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
Identity maxIdentity = null; Identity maxIdentity = null;
for (Identity id : identities) { for (Identity id : identities) {
final long time = id.getDateAdded().getTime(); final long time = id.getDateAdded().getTime();
if (maxDate <= time) { if (maxIdentity == null || maxDate <= time) {
maxDate = time; maxDate = time;
maxIdentity = id; maxIdentity = id;
} }
@ -123,7 +123,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
public static class JsonIdentityKeyStoreDeserializer extends JsonDeserializer<JsonIdentityKeyStore> { public static class JsonIdentityKeyStoreDeserializer extends JsonDeserializer<JsonIdentityKeyStore> {
@Override @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); JsonNode node = jsonParser.getCodec().readTree(jsonParser);
try { try {
@ -157,7 +157,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
public static class JsonIdentityKeyStoreSerializer extends JsonSerializer<JsonIdentityKeyStore> { public static class JsonIdentityKeyStoreSerializer extends JsonSerializer<JsonIdentityKeyStore> {
@Override @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.writeStartObject();
json.writeNumberField("registrationId", jsonIdentityKeyStore.getLocalRegistrationId()); json.writeNumberField("registrationId", jsonIdentityKeyStore.getLocalRegistrationId());
json.writeStringField("identityKey", Base64.encodeBytes(jsonIdentityKeyStore.getIdentityKeyPair().serialize())); 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> { public static class JsonPreKeyStoreDeserializer extends JsonDeserializer<JsonPreKeyStore> {
@Override @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); JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<Integer, byte[]> preKeyMap = new HashMap<>(); Map<Integer, byte[]> preKeyMap = new HashMap<>();
@ -82,7 +82,7 @@ class JsonPreKeyStore implements PreKeyStore {
public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonPreKeyStore> { public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonPreKeyStore> {
@Override @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(); json.writeStartArray();
for (Map.Entry<Integer, byte[]> preKey : jsonPreKeyStore.store.entrySet()) { for (Map.Entry<Integer, byte[]> preKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject(); json.writeStartObject();

View file

@ -78,7 +78,7 @@ class JsonSessionStore implements SessionStore {
public static class JsonSessionStoreDeserializer extends JsonDeserializer<JsonSessionStore> { public static class JsonSessionStoreDeserializer extends JsonDeserializer<JsonSessionStore> {
@Override @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); JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<SignalProtocolAddress, byte[]> sessionMap = new HashMap<>(); Map<SignalProtocolAddress, byte[]> sessionMap = new HashMap<>();
@ -104,7 +104,7 @@ class JsonSessionStore implements SessionStore {
public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonSessionStore> { public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonSessionStore> {
@Override @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(); json.writeStartArray();
for (Map.Entry<SignalProtocolAddress, byte[]> preKey : jsonSessionStore.sessions.entrySet()) { for (Map.Entry<SignalProtocolAddress, byte[]> preKey : jsonSessionStore.sessions.entrySet()) {
json.writeStartObject(); json.writeStartObject();

View file

@ -73,7 +73,7 @@ class JsonSignedPreKeyStore implements SignedPreKeyStore {
public static class JsonSignedPreKeyStoreDeserializer extends JsonDeserializer<JsonSignedPreKeyStore> { public static class JsonSignedPreKeyStoreDeserializer extends JsonDeserializer<JsonSignedPreKeyStore> {
@Override @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); JsonNode node = jsonParser.getCodec().readTree(jsonParser);
Map<Integer, byte[]> preKeyMap = new HashMap<>(); Map<Integer, byte[]> preKeyMap = new HashMap<>();
@ -99,7 +99,7 @@ class JsonSignedPreKeyStore implements SignedPreKeyStore {
public static class JsonSignedPreKeyStoreSerializer extends JsonSerializer<JsonSignedPreKeyStore> { public static class JsonSignedPreKeyStoreSerializer extends JsonSerializer<JsonSignedPreKeyStore> {
@Override @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(); json.writeStartArray();
for (Map.Entry<Integer, byte[]> signedPreKey : jsonPreKeyStore.store.entrySet()) { for (Map.Entry<Integer, byte[]> signedPreKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject(); json.writeStartObject();

View file

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