Skip to content

getPubliclyAccessibleMethodIfPossible() returns hidden static method #35667

@fibsifan

Description

@fibsifan

Overview

When static methods are used for cache key creation and 2 static methods have the same signature in a class inheritance hierarchy, then only one static method is used for cache key generation. I created a small example project: https://github.com/fibsifan/spring-cache-error

The most relevant part is in the Controller:

    @Cacheable(cacheNames = "cachedController", key = "T(de.jball.spring.caching.keys.ParentCacheKeyGenerator).getCacheKey()")
    @GetMapping("parent")
    public String getResponseWithParentCacheKey() {
        return "ResponseWithParentCacheKey";
    }

    @Cacheable(cacheNames = "cachedController", key = "T(de.jball.spring.caching.keys.ChildCacheKeyGenerator).getCacheKey()")
    @GetMapping("child")
    public String getResponseWithChildCacheKey() {
        return "ResponseWithChildCacheKey";
    }

If GET http://localhost:8080/parent is called first, then calls to /child always return ResponseWithParentCacheKey and vice versa.

Related Issues

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions