public void showStateHint(int state) { try { Snackbar.make(fab, "State changed callback: " + state, Snackbar.LENGTH_SHORT).show(); } catch (NullPointerException e) { Log.d("showStateHint", e.toString()); } } }
@Override public void close() throws IOException { if (this.output != null) { try { if (!trailerWritten) { writeWALTrailer(); } this.output.close(); } catch (NullPointerException npe) { // Can get a NPE coming up from down in DFSClient$DFSOutputStream#close LOG.warn(npe.toString(), npe); } this.output = null; } }
/** * Throws a ConfigurationException with an NullPointerExceptions as the cause if the given * reference is {@code null}. */ static <T> T checkNotNull(T reference, String name) { if (reference != null) { return reference; } NullPointerException npe = new NullPointerException(name); throw new ConfigurationException(ImmutableSet.of(new Message(npe.toString(), npe))); }
@Override public void run() { try { LOG.info("Hook closing fs=" + this.fs); this.fs.close(); } catch (NullPointerException npe) { LOG.debug("Need to fix these: " + npe.toString()); } catch (IOException e) { LOG.warn("Running hook", e); } } }
@Test public void subscribeThrows() { try { new Single<Integer>() { @Override protected void subscribeActual(SingleObserver<? super Integer> observer) { throw new IllegalArgumentException(); } }.test(); } catch (NullPointerException ex) { if (!(ex.getCause() instanceof IllegalArgumentException)) { fail(ex.toString() + ": should have thrown NPE(IAE)"); } } }
@Test public void callbackCrash() { try { Observable.just(1) .lift(new ObservableOperator<Object, Integer>() { @Override public Observer<? super Integer> apply(Observer<? super Object> o) throws Exception { throw new TestException(); } }) .test(); fail("Should have thrown"); } catch (NullPointerException ex) { assertTrue(ex.toString(), ex.getCause() instanceof TestException); } } }
@Test public void sourceThrowsIAE() { try { Maybe.unsafeCreate(new MaybeSource<Object>() { @Override public void subscribe(MaybeObserver<? super Object> observer) { throw new IllegalArgumentException("Forced failure"); } }).test(); fail("Should have thrown!"); } catch (NullPointerException ex) { assertTrue(ex.toString(), ex.getCause() instanceof IllegalArgumentException); assertEquals("Forced failure", ex.getCause().getMessage()); } }
index = spec.indexOf(':'); } catch (NullPointerException e) { throw new TMalformedURLException(e.toString());
@Test public void subscribeActualThrows() { List<Throwable> list = TestHelper.trackPluginErrors(); try { try { new BadObservable().test(); fail("Should have thrown!"); } catch (NullPointerException ex) { if (!(ex.getCause() instanceof IllegalArgumentException)) { fail(ex.toString() + ": Should be NPE(IAE)"); } } TestHelper.assertError(list, 0, IllegalArgumentException.class); } finally { RxJavaPlugins.reset(); } }
@Test public void subscribeActualThrows() { List<Throwable> list = TestHelper.trackPluginErrors(); try { try { new BadFlowable().test(); fail("Should have thrown!"); } catch (NullPointerException ex) { if (!(ex.getCause() instanceof IllegalArgumentException)) { fail(ex.toString() + ": Should be NPE(IAE)"); } } TestHelper.assertError(list, 0, IllegalArgumentException.class); } finally { RxJavaPlugins.reset(); } } }
@Test public void unsafeCreateThrowsIAE() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { Completable.unsafeCreate(new CompletableSource() { @Override public void subscribe(CompletableObserver observer) { throw new IllegalArgumentException(); } }).test(); fail("Should have thrown!"); } catch (NullPointerException ex) { if (!(ex.getCause() instanceof IllegalArgumentException)) { fail(ex.toString() + ": should have thrown NPA(IAE)"); } TestHelper.assertError(errors, 0, IllegalArgumentException.class); } finally { RxJavaPlugins.reset(); } } }
@Test public void callbackCrash() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { Flowable.just(1) .lift(new FlowableOperator<Object, Integer>() { @Override public Subscriber<? super Integer> apply(Subscriber<? super Object> subscriber) throws Exception { throw new TestException(); } }) .test(); fail("Should have thrown"); } catch (NullPointerException ex) { assertTrue(ex.toString(), ex.getCause() instanceof TestException); TestHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaPlugins.reset(); } } }
/** * Throws a ConfigurationException with an NullPointerExceptions as the cause if the given * reference is {@code null}. */ static <T> T checkNotNull(T reference, String name) { if (reference != null) { return reference; } NullPointerException npe = new NullPointerException(name); throw new ConfigurationException(ImmutableSet.of(new Message(npe.toString(), npe))); }
static <T> T checkNotNull(T reference, String name) { if (reference != null) { return reference; } NullPointerException npe = new NullPointerException(name); throw new ConfigurationException(ImmutableSet.of( new Message(npe.toString(), npe))); }
@Override public void run() { try { LOG.info("Hook closing fs=" + this.fs); this.fs.close(); } catch (NullPointerException npe) { LOG.debug("Need to fix these: " + npe.toString()); } catch (IOException e) { LOG.warn("Running hook", e); } } }
private static Date parseString(String dateAsString, DateFormat format) throws ParseException { Date formattedDate = null; try { formattedDate = format.parse(dateAsString); } catch (NullPointerException e) { OpenMRS.getInstance().getOpenMRSLogger().w("Failed to parse date :" + dateAsString + " caused by " + e.toString()); } return formattedDate; }
@Override public String toString() { if(!MockFramework.isEnabled()){ return super.toString(); } return getDelegate().toString(); }
public void testDoNotRetryOnGeneralSftpError() { // http://sourceforge.net/mailarchive/forum.php?thread_name=CAARMrHVhASeku48xoAgWEb-nEpUuYkMA03PoA5TvvFdk%3DjGKMA%40mail.gmail.com&forum_name=jsch-users assert !ssh.shouldRetry(new SftpException(ChannelSftp.SSH_FX_FAILURE, new NullPointerException().toString())); }
public void testCreatePostRequestNullNotOk1() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(TestPost.class, "postNonnull", String.class); try { GeneratedHttpRequest request = processor.apply(Invocation.create(method, Lists.<Object> newArrayList((String) null))); Assert.fail("call should have failed with illegal null parameter, not permitted " + request + " to be created"); } catch (NullPointerException e) { Assert.assertTrue(e.toString().indexOf("postNonnull parameter 1") >= 0, "Error message should have referred to 'parameter 1': " + e); } }
@Test public void subscribeActual2() { try { new Nono() { @Override protected void subscribeActual(Subscriber<? super Void> s) { throw new IllegalArgumentException(); } }.test(false); } catch (NullPointerException ex) { Assert.assertTrue(ex.toString(), ex.getCause() instanceof IllegalArgumentException); } }