Skip to content

Commit d283fac

Browse files
committed
bug fix. environment change is now also propagated when no remaining connection exists
1 parent cfcc1ef commit d283fac

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/main/java/net/sharksystem/asap/ASAPEnvironmentChangesListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public interface ASAPEnvironmentChangesListener {
66
/**
77
* ASAP peers establish connections on their own and usually if possible. This
88
* message is called if one or more connections could be established or got lost.
9-
* @param peerList current list of peer we have a connection to
9+
* @param peerList current list of peer we have a connection to (can be empty)
1010
*/
1111
void onlinePeersChanged(Set<CharSequence> peerList);
1212
}

src/main/java/net/sharksystem/asap/engine/ASAPInternalPeerFS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private void notifyOnlinePeersChangedListener() {
439439
Log.writeLog(this, "no (more) peers: ");
440440
}
441441

442-
if(this.onlinePeersChangedListeners != null) {
442+
if(this.onlinePeersChangedListeners != null && !this.onlinePeersChangedListeners.isEmpty()) {
443443
for(ASAPInternalOnlinePeersChangedListener listener: this.onlinePeersChangedListeners) {
444444
listener.notifyOnlinePeersChanged(this);
445445
}
@@ -505,7 +505,7 @@ public synchronized void asapConnectionTerminated(Exception terminatingException
505505

506506
StringBuilder sb = new StringBuilder();
507507
sb.append(this.getLogStart());
508-
sb.append("asapConnection terminated connected to: ");
508+
sb.append("asapConnection terminated; was connected to: ");
509509

510510
if(peerName != null) {
511511
sb.append(peerName);

src/main/java/net/sharksystem/asap/listenermanager/ASAPEnvironmentChangesListenerManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public void removeASAPEnvironmentChangesListener(ASAPEnvironmentChangesListener
2222
}
2323

2424
public void notifyListeners(Set<CharSequence> peerList) {
25-
if(peerList == null || peerList.isEmpty()) return;
25+
if(peerList == null) peerList = new HashSet<>();
26+
2627
if(this.listenerList == null || this.listenerList.isEmpty()) return;
28+
2729
// make a copy of that list
2830
for(ASAPEnvironmentChangesListener listener : this.listenerList) {
2931
if(listener != null) listener.onlinePeersChanged(new HashSet<>(peerList));

0 commit comments

Comments
 (0)