Spring Framework
  1. Spring Framework
  2. SPR-9273

HttpStatusCodeException cannot be serialized

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.2 M1
    • Component/s: Web
    • Labels:
    • Last commented by a User:
      false

      Description

      Being a Throwable, org.springframework.web.client.HttpStatusCodeException should be serializable.
      However, it references a java.nio.charset.Charset, which is not java.io.Serializable, causing an NotSerializableException.

        Issue Links

          Activity

          Hide
          Chris Beams added a comment -

          @Arjen, here is the commit that introduced the dependency on Charset:

          https://github.com/SpringSource/spring-framework/commit/70cb81b4b5d9633d6eeb8967b7289fb9394734cd

          @Ronald, could you explain your use case a bit? It would help us in evaluating this to understand why you're needing to serialize HttpStatusCodeException in the first place.

          Thanks.

          Show
          Chris Beams added a comment - @Arjen, here is the commit that introduced the dependency on Charset : https://github.com/SpringSource/spring-framework/commit/70cb81b4b5d9633d6eeb8967b7289fb9394734cd @Ronald, could you explain your use case a bit? It would help us in evaluating this to understand why you're needing to serialize HttpStatusCodeException in the first place. Thanks.
          Hide
          Ronald Dauster added a comment -

          The obvious use case are all RPC frameworks that use serialization to marshal arguments, return values, and exceptions.
          I encountered the problem using haszelcast's distributed executor service, but it should be no different with RMI.

          Show
          Ronald Dauster added a comment - The obvious use case are all RPC frameworks that use serialization to marshal arguments, return values, and exceptions. I encountered the problem using haszelcast's distributed executor service, but it should be no different with RMI.
          Hide
          Chris Beams added a comment -

          Thanks, Ronald

          commit 2ff43726be693f32b7bf2a6d237ab65f8ce84ba6
          Author: Chris Beams <cbeams@vmware.com>
          Date:   Mon May 14 14:47:11 2012 +0300
          
              Restore serializability of HttpStatusCodeException
              
              SPR-7591 introduced a java.nio.charset.Charset field within
              HttpStatusCodeException. The former is non-serializable, thus by
              extension the latter also became non-serializable.
              
              Because the Charset field is only used for outputting the charset name
              in HttpStatusCodeException#getResponseBodyAsString, it is reasonable to
              store the value returned by Charset#name() instead of the actual Charset
              object itself.
              
              This commit refactors HttpStatusCodeException's responseCharset field to
              be of type String instead of Charset and adds tests to prove that
              HttpStatusCodeException objects are once again serializable as expected.
              
              Issue: SPR-9273, SPR-7591
          
          Show
          Chris Beams added a comment - Thanks, Ronald commit 2ff43726be693f32b7bf2a6d237ab65f8ce84ba6 Author: Chris Beams <cbeams@vmware.com> Date: Mon May 14 14:47:11 2012 +0300 Restore serializability of HttpStatusCodeException SPR-7591 introduced a java.nio.charset.Charset field within HttpStatusCodeException. The former is non-serializable, thus by extension the latter also became non-serializable. Because the Charset field is only used for outputting the charset name in HttpStatusCodeException#getResponseBodyAsString, it is reasonable to store the value returned by Charset#name() instead of the actual Charset object itself. This commit refactors HttpStatusCodeException's responseCharset field to be of type String instead of Charset and adds tests to prove that HttpStatusCodeException objects are once again serializable as expected. Issue: SPR-9273, SPR-7591

            People

            • Assignee:
              Chris Beams
              Reporter:
              Ronald Dauster
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 49 weeks ago