Skip to content

Commit 8fe650c

Browse files
thscthsc
authored andcommitted
connections are no longer closed within asp3 but from caller
1 parent 31d8994 commit 8fe650c

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

src/net/sharksystem/asp3/ASP3ChunkSerialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void readChunks(String sender, ASP3ChunkStorage chunkStorage,
9393
//<<<<<<<<<<<<<<<<<<debug
9494
b = new StringBuilder();
9595
b.append(logStart);
96-
b.append("read chunkURI / #messages / sender");
96+
b.append("read chunkURI / #messages / sender: ");
9797
b.append(uri);
9898
b.append(" / ");
9999
b.append(number);

src/net/sharksystem/asp3/ASP3Engine.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -267,28 +267,29 @@ public void handleConnection(InputStream is, OutputStream os,
267267
System.out.println(b.toString());
268268
//>>>>>>>>>>>>>>>>>>>debug
269269
}
270-
finally {
271-
try {
272-
// remember that we drop conversation with that peer
273-
this.activePeers.remove(peer);
274-
275-
//<<<<<<<<<<<<<<<<<<debug
276-
StringBuilder b = new StringBuilder();
277-
b.append(this.getLogStart());
278-
b.append("about closing output stream");
279-
System.out.println(b.toString());
280-
//>>>>>>>>>>>>>>>>>>>debug
281-
try {
282-
Thread.sleep(sleepBeforeConnectionClosed);
283-
} catch (InterruptedException ex) {
284-
// ignore
285-
}
286-
//dis.close();
287-
dos.close();
288-
} catch (IOException ex) {
289-
// ignore
290-
}
291-
}
270+
// connections are NOT close within that module but from caller!
271+
// finally {
272+
// try {
273+
// // remember that we drop conversation with that peer
274+
// this.activePeers.remove(peer);
275+
//
276+
// //<<<<<<<<<<<<<<<<<<debug
277+
// StringBuilder b = new StringBuilder();
278+
// b.append(this.getLogStart());
279+
// b.append("about closing output stream");
280+
// System.out.println(b.toString());
281+
// //>>>>>>>>>>>>>>>>>>>debug
282+
// try {
283+
// Thread.sleep(sleepBeforeConnectionClosed);
284+
// } catch (InterruptedException ex) {
285+
// // ignore
286+
// }
287+
// //dis.close();
288+
// dos.close();
289+
// } catch (IOException ex) {
290+
// // ignore
291+
// }
292+
// }
292293
}
293294

294295
@Override

test/BasicTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,16 @@ public void androidUsage() throws IOException, ASP3Exception, InterruptedExcepti
100100
bobEngine.handleConnection(bobChannel.getInputStream(),
101101
bobChannel.getOutputStream(), bobListener);
102102

103-
// wait until communication end
103+
// wait until communication probably ends
104104
Thread.sleep(10000);
105105

106+
// close connections: note ASP3Engine does NOT close any connection!!
107+
aliceChannel.close();
108+
bobChannel.close();
109+
Thread.sleep(1000);
110+
111+
// check results
112+
106113
// listener must have been informed about new messages
107114
Assert.assertTrue(aliceListener.chunkReceived());
108115
Assert.assertTrue(bobListener.chunkReceived());

0 commit comments

Comments
 (0)