Skip to content

Commit 372cba1

Browse files
egoebelbeckermaibin
authored andcommitted
BAEL-1486 - small changes to JGroups (eugenp#3590)
* BAEL-1486 - sample code for JGroups. Fixed a typo in InfluxDB. * BAEL-1486 - updates for JGroups.
1 parent d75f6fc commit 372cba1

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

‎jgroups/src/main/java/com/baeldung/jgroups/JGroupsMessenger.java‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,24 @@ public void viewAccepted(View newView) {
100100
System.out.println("Received initial view:");
101101
newView.forEach(System.out::println);
102102
} else {
103-
104103
// Compare to last view
105104
System.out.println("Received new view.");
106105

107106
List<Address> newMembers = View.newMembers(lastView, newView);
108-
if (newMembers.size() > 0) {
109-
System.out.println("New members: ");
110-
newMembers.forEach(System.out::println);
111-
}
107+
System.out.println("New members: ");
108+
newMembers.forEach(System.out::println);
112109

113110
List<Address> exMembers = View.leftMembers(lastView, newView);
114-
if (exMembers.size() > 0) {
115-
System.out.println("Exited members:");
116-
exMembers.forEach(System.out::println);
117-
}
111+
System.out.println("Exited members:");
112+
exMembers.forEach(System.out::println);
118113
}
119114
lastView = newView;
120115
}
121116

122117
/**
123118
* Loop on console input until we see 'x' to exit
124119
*/
125-
private void processInput() {
120+
private void processInput() throws Exception {
126121

127122
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
128123
while (running) {
@@ -138,13 +133,8 @@ private void processInput() {
138133
running = false;
139134
continue;
140135
} else if (!destinationName.isEmpty()) {
141-
Optional<Address> optDestination = getAddress(destinationName);
142-
if (optDestination.isPresent()) {
143-
destination = optDestination.get();
144-
} else {
145-
System.out.println("Destination not found, try again.");
146-
continue;
147-
}
136+
destination = getAddress(destinationName)
137+
. orElseThrow(() -> new Exception("Destination not found"));
148138
}
149139

150140
// Accept a string to send

0 commit comments

Comments
 (0)