Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GStringImpl ClassCastException issue in version 3 #76

Closed
henrik242 opened this issue Feb 26, 2020 · 5 comments
Closed

GStringImpl ClassCastException issue in version 3 #76

henrik242 opened this issue Feb 26, 2020 · 5 comments
Labels
help wanted Extra attention is needed workaround exists There is a workaround for this already
Milestone

Comments

@henrik242
Copy link

henrik242 commented Feb 26, 2020

The following works in 2.2.1, but fails in 2.2.2:

tasks.withType(YarnTask) { task ->
    task.dependsOn(":someTask")
    addPathToYarnFor(task)
}

def addPathToYarnFor(task) {
    task.configure {
        String yarnPath = "${rootDir}/build/yarn/bin"
        environment = ["PATH": "${yarnPath}:${System.env.PATH}"]
    }
}

A workaround is to use toString():

environment = ["PATH": "${yarnPath}:${System.env.PATH}".toString()]

Here's the exception:

Caused by: java.lang.ClassCastException: class org.codehaus.groovy.runtime.GStringImpl cannot be cast to class java.lang.String (org.codehaus.groovy.runtime.GStringImpl is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @5d6f64b1; java.lang.String is in module java.base of loader 'bootstrap')
        at com.moowork.gradle.node.exec.ExecRunner.computeExecEnvironment(ExecRunner.kt:66)
        at com.moowork.gradle.node.exec.ExecRunner.access$computeExecEnvironment(ExecRunner.kt:16)
        at com.moowork.gradle.node.exec.ExecRunner$run$1.execute(ExecRunner.kt:44)
        at com.moowork.gradle.node.exec.ExecRunner$run$1.execute(ExecRunner.kt:16)
        at org.gradle.process.internal.DefaultExecActionFactory.exec(DefaultExecActionFactory.java:151)
        at org.gradle.api.internal.project.DefaultProject.exec(DefaultProject.java:1139)
        at com.moowork.gradle.node.exec.ExecRunner.run(ExecRunner.kt:41)
        at com.moowork.gradle.node.yarn.YarnExecRunner.doExecute(YarnExecRunner.kt:11)
        at com.moowork.gradle.node.exec.ExecRunner.execute(ExecRunner.kt:37)
        at com.moowork.gradle.node.yarn.YarnTask.exec(YarnTask.kt:43)

Should I just use the toString() or do you plan to support GString?

@deepy
Copy link
Member

deepy commented Feb 27, 2020

Hmm, this is tricky, from how I understood GString is that groovy should automatically convert it to a String if necessary, so toString() shouldn't be necessary, although obviously something is going wrong here.

Go with toString() for now while we work on a fix, sorry about the inconvenience

@deepy deepy added help wanted Extra attention is needed workaround exists There is a workaround for this already labels Feb 27, 2020
@henrik242
Copy link
Author

@deepy I've seen this a lot with Groovy. No easy fix, I think, other than replacing Map<String, String> with a Map<String, Any> and do a mapValues { it.toString() } on it.

@deepy
Copy link
Member

deepy commented Feb 27, 2020

Aargh, maybe we can add a setter for Map<String, Any> and get partial support, I'll have to look into this

@bsautel
Copy link
Contributor

bsautel commented Feb 28, 2020

This regression is due to an error in the release process. The 2.2.2 release should be a fix-only release and it integrated all the changes applied to the master branch, including the Kotlin rewrite that breaks backward compatibility (see #80).

We are going to release a new 2.2.3 version which won't include this issue. But this issue is still valid for the development branch and is probably due to the Kotlin rewrite.

@bsautel bsautel added this to the 3.0 milestone Apr 4, 2020
@bsautel bsautel changed the title gradle-node-plugin 2.2.2 GStringImpl ClassCastException issue GStringImpl ClassCastException issue in version 3 Apr 4, 2020
bsautel added a commit that referenced this issue Apr 5, 2020
@bsautel
Copy link
Contributor

bsautel commented Apr 5, 2020

I added some GStrings in the integration tests in bb4941c to ensure GStrings work as expected and I could not reproduce the issue. Did I forget anything?

@bsautel bsautel closed this as completed Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed workaround exists There is a workaround for this already
Projects
None yet
Development

No branches or pull requests

3 participants