Index: hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java (revision 1361549) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java (working copy) @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Method; import java.net.ConnectException; import java.net.InetSocketAddress; import java.net.Socket; @@ -674,6 +675,33 @@ } }); } + + // boolean variable telling us whether cast to InputStream is needed + private boolean needToCast = false; + InputStream getInputStream(Socket socket) throws IOException { + if (!needToCast) { + try { + return NetUtils.getInputStream(socket); + } catch (NoSuchMethodError nsme) { + needToCast = true; + } + } + Method m = null; + String methodName = "getInputStream"; + Class cls = NetUtils.class; + try { + m = cls.getMethod(methodName, new Class[] { Socket.class }); + } catch (NoSuchMethodException e) { + LOG.error("NetUtils doesn't support " + methodName); + } catch (SecurityException e) { + LOG.error("NetUtils doesn't support " + methodName); + } + try { + return (InputStream) m.invoke(null, socket); + } catch (Exception e) { + throw new IOException(e); + } + } protected synchronized void setupIOstreams() throws IOException, InterruptedException { @@ -690,7 +718,7 @@ Random rand = null; while (true) { setupConnection(); - InputStream inStream = NetUtils.getInputStream(socket); + InputStream inStream = getInputStream(socket); OutputStream outStream = NetUtils.getOutputStream(socket); writeRpcHeader(outStream); if (useSasl) {