Skip to content

Commit

Permalink
Merge pull request #291 from scalecube/update/cosmetics
Browse files Browse the repository at this point in the history
Cosmetic fixes
  • Loading branch information
artem-v authored Jan 16, 2020
2 parents 00a8c84 + ea9f27c commit 0296a76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GossipRequest(Gossip gossip, String from) {
public GossipRequest(List<Gossip> gossips, String from) {
Objects.requireNonNull(gossips);
Objects.requireNonNull(from);
this.gossips = new ArrayList<>(gossips);
this.gossips = Collections.unmodifiableList(new ArrayList<>(gossips));
this.from = from;
}

Expand All @@ -53,11 +53,12 @@ public void writeExternal(ObjectOutput out) throws IOException {
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// gossips
int size = in.readInt();
gossips = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
int gossipsSize = in.readInt();
List<Gossip> gossips = new ArrayList<>(gossipsSize);
for (int i = 0; i < gossipsSize; i++) {
gossips.add((Gossip) in.readObject());
}
this.gossips = Collections.unmodifiableList(gossips);
// from
from = in.readUTF();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
Expand All @@ -31,12 +32,12 @@ public SyncData() {}
public SyncData(Collection<MembershipRecord> membership, String syncGroup) {
Objects.requireNonNull(membership);
Objects.requireNonNull(syncGroup);
this.membership = new ArrayList<>(membership);
this.membership = Collections.unmodifiableList(new ArrayList<>(membership));
this.syncGroup = syncGroup;
}

public Collection<MembershipRecord> getMembership() {
return new ArrayList<>(membership);
return membership;
}

public String getSyncGroup() {
Expand All @@ -57,11 +58,12 @@ public void writeExternal(ObjectOutput out) throws IOException {
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// membership
int size = in.readInt();
membership = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
int membershipSize = in.readInt();
List<MembershipRecord> membership = new ArrayList<>(membershipSize);
for (int i = 0; i < membershipSize; i++) {
membership.add((MembershipRecord) in.readObject());
}
this.membership = Collections.unmodifiableList(membership);
// syncGroup
syncGroup = in.readUTF();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ public void writeExternal(ObjectOutput out) throws IOException {
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// headers
int size = in.readInt();
headers = new HashMap<>(size);
for (int i = 0; i < size; i++) {
int headersSize = in.readInt();
Map<String, String> headers = new HashMap<>(headersSize);
for (int i = 0; i < headersSize; i++) {
String name = in.readUTF();
String value = in.readUTF();
headers.put(name, value);
}
this.headers = Collections.unmodifiableMap(headers);
// data
data = in.readObject();
}
Expand Down

0 comments on commit 0296a76

Please sign in to comment.