jax.random.poisson hangs if lam is NaN
The following causes Python to hang:

```python
import jax
import numpy as np

key = jax.random.PRNGKey(0)
jax.random.poisson(key=key, lam=jnp.array([np.nan]), shape=(1,))
# hangs
```

My expectation is that when lam=np.nan, the output will be np.nan.

diff --git a/jax/_src/random.py b/jax/_src/random.py
index 6b51fb208..a9d894a3f 100644
--- a/jax/_src/random.py
+++ b/jax/_src/random.py
@@ -53,6 +53,9 @@ UINT_DTYPES = prng.UINT_DTYPES
 
 ### utilities
 
+def _isnan(x):
+  return lax.ne(x, x)
+
 def _check_prng_key(key):
   # TODO(frostig): remove once we always enable_custom_prng
   if type(key) is prng.PRNGKeyArray:
@@ -1096,7 +1099,7 @@ def _poisson(key, lam, shape, dtype):
   # https://github.com/numpy/numpy/blob/v1.18.3/numpy/random/src/distributions/distributions.c#L574
   # For lambda < 10, we use the Knuth algorithm; otherwise, we use transformed
   # rejection sampling.
-  use_knuth = lam < 10
+  use_knuth = _isnan(lam) | (lam < 10)
   lam_knuth = lax.select(use_knuth, lam, lax.full_like(lam, 0.0))
   # The acceptance probability for rejection sampling maxes out at 89% as
   # λ -> ∞, so pick some arbitrary large value.
diff --git a/tests/random_test.py b/tests/random_test.py
index c58589624..bbf7a9e3c 100644
--- a/tests/random_test.py
+++ b/tests/random_test.py
@@ -791,6 +791,12 @@ class LaxRandomTest(jtu.JaxTestCase):
     samples = random.poisson(key, lam, shape=(2, 20))
     self.assertArraysEqual(samples[:, :10], jnp.zeros_like(samples[:, :10]))
 
+  def testPoissonCornerCases(self):
+    key = self.seed_prng(0)
+    lam = jnp.array([-1, 0, jnp.nan])
+    samples = random.poisson(key, lam, shape=(3,))
+    self.assertArraysEqual(samples, jnp.array([-1, 0, -1]))
+
   @parameterized.named_parameters(jtu.cases_from_list(
       {"testcase_name": "_dtype={}".format(np.dtype(dtype).name), "dtype": dtype}
       for dtype in jtu.dtypes.floating))
['jax/_src/random.py', 'tests/random_test.py']