You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/05/19 15:35:01 UTC
[jira] [Resolved] (GROOVY-7338) URL getText(requestProperties) Map
doesn't accept a GString
[ https://issues.apache.org/jira/browse/GROOVY-7338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-7338.
-------------------------------
Resolution: Fixed
Fix Version/s: 2.4.4
Assignee: Paul King
Applied, thanks!
> URL getText(requestProperties) Map doesn't accept a GString
> ------------------------------------------------------------
>
> Key: GROOVY-7338
> URL: https://issues.apache.org/jira/browse/GROOVY-7338
> Project: Groovy
> Issue Type: Bug
> Reporter: Eric Helgeson
> Assignee: Paul King
> Fix For: 2.4.4
>
>
> Many times you construct a header with multiple values then pass it to requestProperties map. It would be more groovy if it accepted a GString instead of having to cast it to a String
> {code}
> # Less Groovy -
> url.getText(requestProperties:[Authentication:"Basic $auth".toString()]) == 'Groovy a:b'
> # More Groovy -
> url.getText(requestProperties:[Authentication:"Basic $auth"]) == 'Groovy a:b'
> {code}
> Exception -
> {code}
> :test
> org.codehaus.groovy.runtime.URLGetTextTest > testGetTextFromURLWithParameters FAILED
> java.lang.ClassCastException: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String
> at org.codehaus.groovy.runtime.ResourceGroovyMethods.configuredInputStream(ResourceGroovyMethods.java:2026)
> at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:2132)
> at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:665)
> at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:633)
> at org.codehaus.groovy.runtime.dgm$965.invoke(Unknown Source)
> at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
> at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
> at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
> at org.codehaus.groovy.runtime.URLGetTextTest.testGetTextFromURLWithParameters(URLGetTextTest.groovy:57)
> 1 test completed, 1 failed
> :test FAILED
> {code}
> Test -
> {code}
> diff --git a/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy b/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy
> index 8a037e5..29a5f59 100644
> --- a/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy
> +++ b/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy
> @@ -53,6 +53,9 @@ class URLGetTextTest extends GroovyTestCase {
>
> assert url.getText(requestProperties:[a:'b']) == 'Groovy a:b'
>
> + def b = "b"
> + assert url.getText(requestProperties:[a:"$b"]) == 'Groovy a:b'
> +
> assert url.getText(useCaches:true, requestProperties:[a:'b']) == 'Groovy cached a:b'
>
> assert url.getText() == url.getText()
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)