Hello - any idea when the next release of the `wir...
# general
e
Hello - any idea when the next release of the
wiremock-grpc-extension
might be? There have been lots of enhancements since the last release (November 2023) that I would like to use.
t
I was going to try to release it this week, after releasing core today. Unfortunately I’m stuck fighting a Gradle classpath issue that’s appeared from nowhere so it’ll be shortly after whenever I can sort that out.
👍 1
e
Thanks for the update!
t
If you happen to know why Gradle would suddently have started using asm 9.6 internally, despite me explicitly pinning it to 9.4 in the buildscript deps, that would speed things up enormously.
e
i dont know off the top of my head, but can help play with it if you’d like
t
That would be much appreciated at this point. Please can you try running
./gradlew shadowJar
with JDK11 against the current HEAD/master?
e
from the
wiremock-grpc-extension
repo?
t
No sorry, from
wiremock
e
gotta install java 11 😄
t
OId skool, I know
e
is asm the problem? or is there another dependency that asm is trying to read?
i got asm downgraded to 9.4 but still see the same error
t
I’m pretty sure it’s asm. It’s not actually downgrading it for me, even though it’s reporting that it is. When I set a breakpoint and debug the shadowJar task it still takes me to the 9.6 JAR
e
I added this to the build file:
Copy code
configurations.all {
  resolutionStrategy.eachDependency { details ->
    if ((details.requested.group == 'org.ow2.asm') && (details.requested.name == 'asm')) {
      details.useVersion '9.4'
      details.because 'we need to use Java 11 as a baseline'
    }
  }
}
t
Does that work against the buildscript classpath?
e
aha no it doesn’t
but you can put that
configurations.all
stanza into the
buildscript
block
Copy code
buildscript {
  repositories {
    maven {
      url "<https://oss.sonatype.org>"
    }
    mavenCentral()
  }

  configurations.all {
    resolutionStrategy.eachDependency { details ->
      if ((details.requested.group == 'org.ow2.asm') && (details.requested.name == 'asm')) {
        details.useVersion '9.4'
        details.because 'we need to use Java 11 as a baseline'
      }
    }
  }
}
and when running
./gradlew buildEnvironment
I can see that asm is now downgraded…
t
I’m still getting the same exception when I add that 😬
e
looks like 9.4 is whats there even before that
Copy code
classpath
+--- com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:6.25.0
|    \--- com.diffplug.spotless:spotless-plugin-gradle:6.25.0
|         +--- com.diffplug.durian:durian-core:1.2.0
|         +--- com.diffplug.durian:durian-io:1.2.0
|         |    +--- com.diffplug.durian:durian-core:1.2.0
|         |    \--- com.diffplug.durian:durian-collect:1.2.0
|         |         \--- com.diffplug.durian:durian-core:1.2.0
|         +--- com.diffplug.durian:durian-collect:1.2.0 (*)
|         +--- org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r
|         |    +--- com.googlecode.javaewah:JavaEWAH:1.2.3
|         |    +--- org.slf4j:slf4j-api:1.7.36
|         |    \--- commons-codec:commons-codec:1.16.0
|         +--- com.diffplug.spotless:spotless-lib:2.45.0
|         \--- com.diffplug.spotless:spotless-lib-extra:2.45.0
|              +--- com.diffplug.durian:durian-core:1.2.0
|              +--- com.diffplug.durian:durian-collect:1.2.0 (*)
|              +--- org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r (*)
|              +--- com.googlecode.concurrent-trees:concurrent-trees:2.6.1
|              +--- dev.equo.ide:solstice:1.7.5
|              |    +--- org.tukaani:xz:1.9
|              |    +--- com.squareup.okhttp3:okhttp:4.12.0
|              |    |    +--- com.squareup.okio:okio:3.6.0
|              |    |    |    \--- com.squareup.okio:okio-jvm:3.6.0
|              |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
|              |    |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10
|              |    |    |         |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10
|              |    |    |         |    |    \--- org.jetbrains:annotations:13.0
|              |    |    |         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10
|              |    |    |         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 (*)
|              |    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10
|              |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21 -> 1.9.10 (*)
|              |    +--- org.slf4j:slf4j-api:1.7.36
|              |    +--- com.diffplug.durian:durian-swt.os:4.2.2
|              |    \--- org.eclipse.platform:org.eclipse.osgi:3.18.300
|              \--- com.diffplug.spotless:spotless-lib:2.45.0
+--- com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:8.1.0
|    \--- com.github.johnrengelman:shadow:8.1.0
|         +--- org.jdom:jdom2:2.0.6.1
|         +--- org.ow2.asm:asm:9.4
|         +--- org.ow2.asm:asm-commons:9.4
|         |    +--- org.ow2.asm:asm:9.4
|         |    \--- org.ow2.asm:asm-tree:9.4
|         |         \--- org.ow2.asm:asm:9.4
|         +--- commons-io:commons-io:2.11.0
|         +--- org.apache.ant:ant:1.10.13
|         |    \--- org.apache.ant:ant-launcher:1.10.13
|         +--- org.codehaus.plexus:plexus-utils:3.5.0
|         +--- org.apache.logging.log4j:log4j-core:2.20.0
|         |    \--- org.apache.logging.log4j:log4j-api:2.20.0
|         \--- org.vafer:jdependency:2.8.0
+--- org.sonarqube:org.sonarqube.gradle.plugin:4.4.1.3373
|    \--- org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373
|         \--- org.sonarsource.scanner.api:sonar-scanner-api:2.16.2.588
\--- org.apache.logging.log4j:log4j-core:{require 2.17.1; reject [2.0, 2.17.1)} -> 2.20.0 (c)
t
I’m seeing that too, but then it’s throwing an exception that can only be thrown from 9.6. Seems it’s straight-up lying about which version it’s using.
I’ve also tried downgrading to Gradle 7.2 and shadow 7.1.1, which are pretty old now, and it’s still happening
e
i have everything downgraded to 9.4 and its still getting that
the build file has an
api
dependency directly to 9.6
t
Commented that out and it’s still the same
Not that it should matter, since that’s the project’s classpath rather than the build’s
e
i think there is some other dependency that is built with 21 thats causing it
i went back to gradle 6/shadowjar 6.1.0 and still get the same error
t
Yeah, seems that way. I have to drop for a bit, but thanks for your help so far.
e
you’re welcome
i’ll keep digging for a bit
i built something which prints the manifests for all dependencies in the
runtimeClasspath
and
standaloneOnly
configurations
Copy code
tasks.register('printManifests') {
  doLast {
    (configurations.runtimeClasspath + configurations.standaloneOnly).each { dep ->
      println '==============================='
      println "Inside dependency: $dep.name"
      println resources.text.fromArchiveEntry(dep, 'META-INF/MANIFEST.MF').asString()
    }
  }
}
i built this
Copy code
tasks.register('unzipDeps') {
  doLast {
    (configurations.runtimeClasspath + configurations.standaloneOnly).asFileTree.each { dep ->
      copy {
        from(zipTree(dep)) {
          include '**/*.class'
          exclude '**/META-INF/**'
          includeEmptyDirs false
        }
        into "$buildDir/deps/$dep.name"
        duplicatesStrategy = DuplicatesStrategy.WARN
      }
    }
  }
}

tasks.register('findClassVersion') {
  dependsOn 'unzipDeps'

  doLast {
    file("$buildDir/deps").eachFileRecurse(groovy.io.FileType.FILES) {file ->
      println '============================='
      println "file: $file"
      exec {
        ignoreExitValue true
        workingDir file.parent
        commandLine 'bash', '-c', "javap -verbose $file.name | grep major"
      }
    }
  }
}
and then I ran
./gradlew findClassVersion > classVersions.txt
still waiting for it to finish
but this should tell us if any of the classes are class level 65
none of them 😞
classVersions.txt
t
This is starting to look like a bug, but in which layer I'm really not sure
e
i’m trying to figure out how to do the same with the buildscript classpath
thats a little more tricky
going thru the buildscript classpath dependencies now
there aren’t many, so i created a new configuration and just added them to that configuration
Copy code
dependencies {
  sample 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
  sample 'com.github.johnrengelman:shadow:8.1.1'
  sample 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373'
  sample 'org.apache.logging.log4j:log4j-core:2.20.0'
}
and also had to add
gradlePluginPortal()
to the
repositories
still running
i have to head out but will post what I find when its done
nothing in the buildscript classpath either
t
Thanks for all your efforts! I think this is one to post on the Gradle Slack at this point maybe?
e
Either there or the shadowJar issue tracker
t
Think I've fixed the issue. Will ping you the commit when it's pushed if you're interested.
e
yeah i’m definitely interested in what the problem was
t
It turned out that we were using the correct version of asm, but the latest Jackson JAR had class files only compatible with 17 and 21 in its META-INF, which our version of asm couldn’t parse.
e
ahhh i originally saw that but discarded it because they were in META-INF
there were 2 or 3 classes in the jackson-core jar
t
Yep, there for optimisation purposes I guess
e
i disregarded them because they were in META-INF (my tasks above filtered out META-INF)
t
I only found out they were still being parsed by setting a breakpoint. Seems the shadow plugin will just check whether a filename ends with
.class
rather than limiting itself to specific roots.
👍 1
I was thinking we should integrate this extension into the Quarkus dev service plugin
And then possibly do some blogging about it
e
that would be nice!
Hey @Tom - I had a question about usage of the Wiremock gRPC extension. I’ve gone into https://github.com/wiremock/wiremock-grpc-demos and changed https://github.com/wiremock/wiremock-grpc-demos/blob/main/java/src/test/java/wiremock/grpc/GrpcTest.java to NOT use the
@RegisterExtension
and instead follow the usage instructions on the extension README (https://github.com/wiremock/wiremock-grpc-extension?tab=readme-ov-file#java-usage) to use the
WireMockServer
Copy code
WireMockServer wm = new WireMockServer(wireMockConfig()
        .dynamicPort()
        .withRootDirectory("src/test/resources/wiremock")
        .extensions(new GrpcExtensionFactory())
));

WireMockGrpcService mockGreetingService =
    new WireMockGrpcService(
        new WireMock(wm.getPort()),
        "com.example.grpc.GreetingService"
    );
But that doesn’t seem to work. When I re-run the tests in
GrpcTest
I get
Copy code
╰─ ./gradlew clean build
Failed to map supported failure 'org.opentest4j.AssertionFailedError: Expected io.grpc.StatusRuntimeException to be thrown, but nothing was thrown.' with mapper 'org.gradle.api.internal.tasks.testing.failure.mappers.OpenTestAssertionFailedMapper@5e26f1ed': Cannot invoke "Object.getClass()" because "obj" is null

> Task :test FAILED

GrpcTest > dynamic_response_via_JSON() PASSED

GrpcTest > request_matching_with_JSON() FAILED
    org.opentest4j.AssertionFailedError: Expected io.grpc.StatusRuntimeException to be thrown, but nothing was thrown.
        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
        at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:73)
        at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35)
        at app//org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3115)
        at app//wiremock.grpc.GrpcTest.request_matching_with_JSON(GrpcTest.java:114)

GrpcTest > non_OK_status() PASSED

GrpcTest > streaming_request_unary_response() PASSED

GrpcTest > unary_request_streaming_response() PASSED

GrpcTest > request_matching_with_message() FAILED
    java.lang.AssertionError: 
    Expected: is "NOT_FOUND: No matching stub mapping found for gRPC request"
         but: was "FAILED_PRECONDITION: Failed some blah prerequisite"
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at wiremock.grpc.GrpcTest.request_matching_with_message(GrpcTest.java:128)

GrpcTest > response_from_message() PASSED

7 tests completed, 2 failed
i’m putting together a reproducer
t
Maybe need to call reset before each test case?