Fix a potential NPE in test_utils WebServerDispatcher

PiperOrigin-RevId: 429338648
This commit is contained in:
olly 2022-02-17 18:11:38 +00:00 committed by Ian Baker
parent a2337adbb8
commit a55219fbf1

View File

@ -28,6 +28,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Util;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
@ -239,7 +240,7 @@ public class WebServerDispatcher extends Dispatcher {
/** Returns the path for a given {@link RecordedRequest}, stripping any query parameters. */
public static String getRequestPath(RecordedRequest request) {
return Util.splitAtFirst(request.getPath(), "\\?")[0];
return Util.splitAtFirst(Strings.nullToEmpty(request.getPath()), "\\?")[0];
}
/**