public int join() throws InterruptedException, IOException { try { return p.join(); } finally { // make sure I/O is delivered to the remote before we return Channel taskChannel = null; try { // Sync IO will fail automatically if the channel is being closed, no need to use getOpenChannelOrFail() // TODOL Replace by Channel#currentOrFail() when Remoting version allows taskChannel = Channel.current(); if (taskChannel == null) { throw new IOException("No Remoting channel associated with this thread"); } taskChannel.syncIO(); } catch (Throwable t) { // this includes a failure to sync, agent.jar too old, etc LOGGER.log(Level.INFO, "Failed to synchronize IO streams on the channel " + taskChannel, t); } } }
public int join() throws InterruptedException, IOException { try { return p.join(); } finally { // make sure I/O is delivered to the remote before we return try { Channel.current().syncIO(); } catch (Throwable t) { // this includes a failure to sync, agent.jar too old, etc } } }
/** * If {@link ProxyWriter} gets garbage collected, it should unexport the entry but shouldn't try to close the stream. */ @Bug(20769) public void testRemoteGC() throws InterruptedException, IOException { // in the legacy mode ProxyWriter will try to close the stream, so can't run this test if (channelRunner.getName().equals("local-compatibility")) return; StringWriter sw = new StringWriter() { @Override public void close() throws IOException { streamClosed = true; } }; final RemoteWriter w = new RemoteWriter(sw); channel.call(new WeakReferenceCallable(w)); // induce a GC. There's no good reliable way to do this, // and if GC doesn't happen within this loop, the test can pass // even when the underlying problem exists. for (int i=0; i<30; i++) { assertTrue("There shouldn't be any errors: " + log.toString(), log.size() == 0); Thread.sleep(100); if (channel.call(new GcCallable())) break; } channel.syncIO(); assertFalse(streamClosed); }