HDFS-9187. Fix null pointer error in Globber when FS was not constructed via FileSystem#createFileSystem (cmccabe)
This commit is contained in:
parent
da8441d0fe
commit
d286032b71
|
@ -129,12 +129,6 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
|
|
||||||
boolean resolveSymlinks;
|
boolean resolveSymlinks;
|
||||||
|
|
||||||
private Tracer tracer;
|
|
||||||
|
|
||||||
protected final Tracer getTracer() {
|
|
||||||
return tracer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method adds a file system for testing so that we can find it later. It
|
* This method adds a file system for testing so that we can find it later. It
|
||||||
* is only for testing.
|
* is only for testing.
|
||||||
|
@ -2712,7 +2706,6 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf);
|
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf);
|
||||||
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
|
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
|
||||||
fs.tracer = tracer;
|
|
||||||
fs.initialize(uri, conf);
|
fs.initialize(uri, conf);
|
||||||
return fs;
|
return fs;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Globber {
|
||||||
this.fc = null;
|
this.fc = null;
|
||||||
this.pathPattern = pathPattern;
|
this.pathPattern = pathPattern;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.tracer = fs.getTracer();
|
this.tracer = FsTracer.get(fs.getConf());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Globber(FileContext fc, Path pathPattern, PathFilter filter) {
|
public Globber(FileContext fc, Path pathPattern, PathFilter filter) {
|
||||||
|
|
|
@ -18,8 +18,13 @@
|
||||||
package org.apache.hadoop.tracing;
|
package org.apache.hadoop.tracing;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
import org.apache.hadoop.fs.LocalFileSystem;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair;
|
import org.apache.hadoop.tracing.SpanReceiverInfo.ConfigurationPair;
|
||||||
import org.apache.htrace.core.HTraceConfiguration;
|
import org.apache.htrace.core.HTraceConfiguration;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -50,4 +55,17 @@ public class TestTraceUtils {
|
||||||
HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf, extraConfig);
|
HTraceConfiguration wrapped = TraceUtils.wrapHadoopConf(TEST_PREFIX, conf, extraConfig);
|
||||||
assertEquals(newValue, wrapped.get(key));
|
assertEquals(newValue, wrapped.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test tracing the globber. This is a regression test for HDFS-9187.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testTracingGlobber() throws Exception {
|
||||||
|
// Bypass the normal FileSystem object creation path by just creating an
|
||||||
|
// instance of a subclass.
|
||||||
|
FileSystem fs = new LocalFileSystem();
|
||||||
|
fs.initialize(new URI("file:///"), new Configuration());
|
||||||
|
fs.globStatus(new Path("/"));
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue