本文整理了Java中java.lang.NullPointerException.toString()
方法的一些代码示例,展示了NullPointerException.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NullPointerException.toString()
方法的具体详情如下:
包路径:java.lang.NullPointerException
类名称:NullPointerException
方法名:toString
暂无
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
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());
}
}
}
代码示例来源:origin: apache/hbase
@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;
}
}
代码示例来源:origin: com.google.inject/guice
/**
* 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)));
}
代码示例来源:origin: apache/hbase
@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);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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)");
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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());
}
}
代码示例来源:origin: konsoletyper/teavm
index = spec.indexOf(':');
} catch (NullPointerException e) {
throw new TMalformedURLException(e.toString());
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@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();
}
}
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
/**
* 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)));
}
代码示例来源:origin: org.xbib/guice
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)));
}
代码示例来源:origin: org.apache.hbase/hbase-server
@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);
}
}
}
代码示例来源:origin: openmrs/openmrs-contrib-android-client
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;
}
代码示例来源:origin: EvoSuite/evosuite
@Override
public String toString() {
if(!MockFramework.isEnabled()){
return super.toString();
}
return getDelegate().toString();
}
代码示例来源:origin: jclouds/legacy-jclouds
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()));
}
代码示例来源:origin: jclouds/legacy-jclouds
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);
}
}
代码示例来源:origin: akarnokd/RxJava2Extensions
@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);
}
}
内容来源于网络,如有侵权,请联系作者删除!