pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Unexpected character 'EOI(null)' at position '3', expecting '[DOT]' #1563

Open achawla-Branch opened 2 years ago

achawla-Branch commented 2 years ago

Not sure if it's a bug.

Parsing against V4 version is failing as below because it's expecting minor version as well.


    return when (this) {
      V1 -> "1.0.0"
      V1_1 -> "1.1.0"
      V2 -> "2.0.0"
      V3 -> "3.0.0"
      V4 -> "4.0" <---
      else -> "3.0.0"
    }
  }

 private NormalVersion parseVersionCore() {
        int major = Integer.parseInt(numericIdentifier());
        consumeNextCharacter(DOT);
        int minor = Integer.parseInt(numericIdentifier());
        consumeNextCharacter(DOT); <--- Resulting in null pointer execption
        int patch = Integer.parseInt(numericIdentifier());
        return new NormalVersion(major, minor, patch);
    }

Unexpected character 'EOI(null)' at position '3', expecting '[DOT]'
    at app//com.github.zafarkhaja.semver.VersionParser.consumeNextCharacter(VersionParser.java:516)
    at app//com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:288)
    at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255)
    at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195)
    at app//com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)
    at app//au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:180)```
rholshausen commented 2 years ago

What version are you using? This has been fixed in 4.2.x+

BorealFeast commented 2 years ago

I confirm this is happening on 4.3.9 and 4.3.14 see the snippet from the generated pact :

"metadata": {
    "pact-jvm": {
      "version": "4.3.14"
    },
    "pactSpecification": {
      "version": "4.0"
    }
  }
ocridlig commented 1 year ago

I have the same problem with the versions 4.5.5 and 4.5.6.

pact

When do you think this problem will be solved? Is there a workaround to avoid the error?

Thanks

rholshausen commented 1 year ago

The Unexpected character 'EOI(null)' at position '3', expecting '[DOT]' exception was fixed in 4.2.x, and com.github.zafarkhaja.semver.VersionParser is no longer used since then.

sachinsonu commented 1 year ago

Can this issue be also fixed in 4.1.x release ?

rholshausen commented 1 year ago

4.1.42 has been released with the fix