Rob,
I've tried to investigate the remote testing.
No conclusion I'm afraid.
I made two changes locally:
* removed the Thread.sleep(250)'s
* put ServerTest.freeServer(); / server.stop after closing the
connection in each @AfterClass
The test pass fast on java7 but lock up on java6.
For java6, there are 506 sockets (253 TCP connections) in state
ESTABLISHED.
506 is the critical number.
Putting the Thread.sleep's does not make any difference (excpet it's
slower :-) -- freezes with 506 sockets ESTABLISHED.
For java7, it climbs but I did see it over 400 and it was always
changing - tests making progress.
I tried tracing TCP connections by using "netstat -n" with debug
breakpoints.
In TestRemoteEndpointResults
** public void results_select_numeric_01()
# netstat : Zero connections at this point
ResultSet rset = this.createResults(ds, ..)
# netstat : a pair of sockets (one TCP connection)
rset.close()
# netstat : no sockets ESTABLISHED
# sometimes in TIME_WAIT but that delay is quite short before they go.
ServerTest.resetServer();
afterwards two connections ESTABLISHED : this is bad!
** public void results_select_numeric_02()
# netstat : Two sockets / 1 TCP conenction
ResultSet rset = this.createResults(
# netstat : Six sockets / 3 TCP connections (this is odd! why not 4?)
rset.close()
# netstat : Four sockets / 2 TCP connections
ServerTest.resetServer();
now 3 TCP conenctions: this is bad^2!
So I tried to the sequence of actions in a standalone program:
String service = "http://localhost:3535/dataset/data" ;
ServerTest.allocServer();
DatasetAccessor dacc = DatasetAccessorFactory.createHTTP(service) ;
Model m = RDFDataMgr.loadModel("file:D.ttl") ;
dacc.add(m);
ServerTest.resetServer();
dacc = DatasetAccessorFactory.createHTTP(service) ;
dacc.add(m);
ServerTest.resetServer();
ServerTest.freeServer();
but at no point did I see any ESTABLISHED connections remaining.
Other::
I noticed that SelectResults does not close the innerResults object -
it's a ResultSetPeekable which is not closeable.
Adding debugging code to exhaust the stream:
public void closeStreamInternal() throws SQLException {
if (this.innerResults != null) {
int i = 0 ;
try {
for ( ; innerResults.hasNext() ; ) {
innerResults.next();
i++ ;
}
} catch (Exception ex) {
System.err.println(ex) ;
}
System.err.println("i = "+i) ;
if (this.innerResults instanceof Closeable) {
((Closeable) this.innerResults).close();
}
this.innerResults = null;
}
}
Sometimes "i" is not zero (it's 12).
And when it isn't zero, there is an exception : somewhere in XML
processing via XMLInputStAX.
It looks like the stream is getting closed early, maybe aynchronously
(or far end?). The XMLInputStAX code has seen a tag and is reading the
content so it's an incomplete result set.
Andy