Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8933

Caching Abstraction ignores method name?

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Won't Fix
    • Affects Version/s: 3.1 GA
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When I read the reference documentation I thought the caching abstraction is on method level, but it seems it is only on the parameter value of the methods.

      If I have several methods with the same parameter type it get always the same return value:

      @Component
      public class CacheTestImpl implements CacheTest {
      @Cacheable("databaseCache")
      public Long test1()

      { return 1L; }

      @Cacheable("databaseCache")
      public Long test2()

      { return 2L; }

      @Cacheable("databaseCache")
      public Long test3()

      { return 3L; }

      @Cacheable("databaseCache")
      public String test4()

      { return "4"; }

      }

      Calling now:

      System.out.println(test.test1());
      System.out.println(test.test2());
      System.out.println(test.test3());
      System.out.println(test.test4());

      results in:

      1
      1
      1
      ClassCastException: java.lang.Long cannot be cast to java.lang.String

      Is this the desired behaviour? I would expect:

      1
      2
      3
      4

      If I use different caches it works.

      I can't access github from my place (firewall) so I have added a tar with a small maven project showing this problem.

      Greets Alex

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pwebb Phil Webb
                Reporter:
                derenbacha Alexander Derenbach
                Last updater:
                chris marx
              • Votes:
                5 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 51 weeks ago