groovy

Serializable GString?

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-1
  • Fix Version/s: 1.5.2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Number of attachments :
    0

Description

Would it be better if the GString class be made Serializable? When I'm trying to assign a GString expression to a Map object, i.e.

m = ... a map ...

str = "hello"
str += " world!!!"
m["mykey"] = str

When I try to serialize "m", it fails to do so because m["mykey"] is a GString, which is not serializable.

Issue Links

Activity

Hide
blackdrag blackdrag added a comment -

and how should the serialization look like? I think what you really want is a normal String here, right?

Show
blackdrag blackdrag added a comment - and how should the serialization look like? I think what you really want is a normal String here, right?
Hide
William Lee added a comment -

Yes, just serialized as java.lang.String. At the moment, I have to force it by doing a m["mykey"] = str.toString().

Show
William Lee added a comment - Yes, just serialized as java.lang.String. At the moment, I have to force it by doing a m["mykey"] = str.toString().
Hide
Wang Bin added a comment -

Below is the define of String
public final class String
extends Object
implements Serializable, Comparable, CharSequence

In fact, GString also should implment part or all these interfaces. I think, Serializable is necessary.

Show
Wang Bin added a comment - Below is the define of String public final class String extends Object implements Serializable, Comparable, CharSequence In fact, GString also should implment part or all these interfaces. I think, Serializable is necessary.
Hide
Guillaume Laforge added a comment -

Please reopen if it's still a problem.

Show
Guillaume Laforge added a comment - Please reopen if it's still a problem.
Hide
David Smiley added a comment -

I'd like it to be re-openned. GString isn't serializable so I can't put in in a session in a grails app if I need it to be serialized to disk or network (like in clustered scenario). Why not implement all that String implements?

Show
David Smiley added a comment - I'd like it to be re-openned. GString isn't serializable so I can't put in in a session in a grails app if I need it to be serialized to disk or network (like in clustered scenario). Why not implement all that String implements?
Hide
Brad Whitaker added a comment -

Tomcat is configured by default to serialize session data. A user that inserts a GString into a session in Grails is going to be happy in devel mode with Jetty, but rudely surprised with a serialization error if they deploy their Grails WAR to Tomcat. (I'm speaking from personal experience. It is possible to configure Tomcat differently, but this may not be desirable.)

Show
Brad Whitaker added a comment - Tomcat is configured by default to serialize session data. A user that inserts a GString into a session in Grails is going to be happy in devel mode with Jetty, but rudely surprised with a serialization error if they deploy their Grails WAR to Tomcat. (I'm speaking from personal experience. It is possible to configure Tomcat differently, but this may not be desirable.)
Hide
Paul King added a comment - - edited

Possibly now resolved due to: GROOVY-2534 but the fix seemed to break the build. Hopefully once fixed we can close this issue too.

Show
Paul King added a comment - - edited Possibly now resolved due to: GROOVY-2534 but the fix seemed to break the build. Hopefully once fixed we can close this issue too.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: