You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/05/19 08:19:59 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14549865#comment-14549865 ]
ASF GitHub Bot commented on GROOVY-7338:
----------------------------------------
GitHub user eginez opened a pull request:
https://github.com/apache/incubator-groovy/pull/19
GROOVY-7338: URL getText(requestProperties) Map now accepts a GString
What do you guys think about this change for http://jira.codehaus.org/browse/GROOVY-7338, is in a similar location as my previous PR
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/eginez/incubator-groovy master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-groovy/pull/19.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #19
----
commit d1f1e120c95d69faecb058267bee2fea206d0eff
Author: Esteban <eg...@gmail.com>
Date: 2015-05-19T06:15:49Z
GROOVY-7338: URL getText(requestProperties) Map now accepts a GString
----
> 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
>
> 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)