public void testRPCInterrupted() throws IOException, InterruptedException { final MiniDFSCluster cluster; Configuration conf = new Configuration(); cluster = new MiniDFSCluster(conf, 3, true, null); final AtomicBoolean passed = new AtomicBoolean(false); try { cluster.waitActive(); Thread rpcThread = new Thread( new Runnable() { @Override public void run() { FileSystem fs = null; try { fs = cluster.getUniqueFileSystem(); int i = 0; while (true) { fs.create(new Path(String.format("/file-%09d", i++))); fs.listStatus(new Path("/")); } } catch (IOException e) { if (e.getCause() instanceof InterruptedException) { // the underlying InterruptedException should be wrapped to an // IOException and end up here passed.set(true); } else { passed.set(false); fail(e.getMessage()); } } finally { if (fs != null) { try { fs.close(); } catch (IOException e) { passed.set(false); LOG.error(e); fail(e.toString()); } } } } }); FileSystem fs2 = cluster.getUniqueFileSystem(); rpcThread.start(); Thread.sleep(1000); rpcThread.interrupt(); rpcThread.join(); FileStatus[] statuses = fs2.listStatus(new Path("/")); assertTrue("expect at least 1 file created", statuses.length > 0); assertTrue("error in writing thread, see above", passed.get()); } finally { cluster.shutdown(); } }