assertj: `NullPointerException` in `isEqualTo` assertion

Summary

see https://github.com/Turbo87/intellij-emberjs/pull/246

java.lang.NullPointerException
        at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
        at java.util.regex.Matcher.reset(Matcher.java:309)
        at java.util.regex.Matcher.<init>(Matcher.java:229)
        at java.util.regex.Pattern.matcher(Pattern.java:1093)
        at java.util.Formatter.parse(Formatter.java:2547)
        at java.util.Formatter.format(Formatter.java:2501)
        at java.util.Formatter.format(Formatter.java:2455)
        at java.lang.String.format(String.java:2940)
        at org.assertj.core.api.AbstractStringAssert.isEqualTo(AbstractStringAssert.java:310)
        at org.assertj.core.api.StringAssert$ByteBuddy$gUBfusQU.isEqualTo$accessor$e5ipmL7L(Unknown Source)
        at org.assertj.core.api.StringAssert$ByteBuddy$gUBfusQU$AssertJ$SoftProxies$xRrT7HuB.call(Unknown Source)
        at org.assertj.core.api.ErrorCollector.intercept(ErrorCollector.java:58)
        at org.assertj.core.api.StringAssert$ByteBuddy$gUBfusQU.isEqualTo(Unknown Source)
        at org.assertj.core.api.StringAssert$ByteBuddy$gUBfusQU.isEqualTo(Unknown Source)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I just had a look at this one and it looks like this one only happens if assertj is used from Kotlin. A simple example which reproduces this one:

    @Test
    fun `test`() {
        assertThat("test").isEqualTo(null)
    }

As shown in the provided stacktrace we end up in:

https://github.com/joel-costigliola/assertj-core/blob/2c57b2b4e470a0a7ff50ee64cbc7d27c02303893/src/main/java/org/assertj/core/api/AbstractStringAssert.java#L309-L311

We are heading into the nullpointer since expectedStringTemplate is null.