HBASE-5955 Fix NoSuchMethodException in 0.92 when running on local filesystem

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1302207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-03-18 19:40:24 +00:00
parent 101e6f08ba
commit 047d209cee
1 changed files with 10 additions and 10 deletions

View File

@ -454,26 +454,26 @@ public class HLog implements Syncable {
*/ */
private Method getGetNumCurrentReplicas(final FSDataOutputStream os) { private Method getGetNumCurrentReplicas(final FSDataOutputStream os) {
Method m = null; Method m = null;
Exception exception = null;
if (os != null) { if (os != null) {
Class<? extends OutputStream> wrappedStreamClass = os.getWrappedStream()
.getClass();
try { try {
m = os.getWrappedStream().getClass(). m = wrappedStreamClass.getDeclaredMethod("getNumCurrentReplicas",
getDeclaredMethod("getNumCurrentReplicas", new Class<?> []{}); new Class<?>[] {});
m.setAccessible(true); m.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
// Thrown if getNumCurrentReplicas() function isn't available LOG.info("FileSystem's output stream doesn't support"
exception = e; + " getNumCurrentReplicas; --HDFS-826 not available; fsOut="
+ wrappedStreamClass.getName());
} catch (SecurityException e) { } catch (SecurityException e) {
// Thrown if we can't get access to getNumCurrentReplicas() LOG.info("Doesn't have access to getNumCurrentReplicas on "
exception = e; + "FileSystems's output stream --HDFS-826 not available; fsOut="
+ wrappedStreamClass.getName(), e);
m = null; // could happen on setAccessible() m = null; // could happen on setAccessible()
} }
} }
if (m != null) { if (m != null) {
LOG.info("Using getNumCurrentReplicas--HDFS-826"); LOG.info("Using getNumCurrentReplicas--HDFS-826");
} else {
LOG.info("getNumCurrentReplicas--HDFS-826 not available; hdfs_out=" +
os, exception);
} }
return m; return m;
} }