• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / ehcache-cache / 619

09 Mar 2026 12:48AM UTC coverage: 74.444% (-2.4%) from 76.812%
619

Pull #282

github

hazendaz
Fix maxBytesLocalDisk support in Ehcache 2 (resolves #62)

Co-Authored-By: hazendaz <975267+hazendaz@users.noreply.github.com>
Pull Request #282: Add maxBytesLocalDisk support for Ehcache 2

13 of 14 branches covered (92.86%)

14 of 21 new or added lines in 2 files covered. (66.67%)

67 of 90 relevant lines covered (74.44%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.82
/src/main/java/org/mybatis/caches/ehcache/EhBlockingCache.java
1
/*
2
 *    Copyright 2010-2026 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.caches.ehcache;
17

18
import net.sf.ehcache.Ehcache;
19
import net.sf.ehcache.Element;
20
import net.sf.ehcache.constructs.blocking.BlockingCache;
21

22
/**
23
 * The Class EhBlockingCache.
24
 *
25
 * @author Iwao AVE!
26
 */
27
public class EhBlockingCache extends AbstractEhcacheCache {
28

29
  /**
30
   * Instantiates a new eh blocking cache.
31
   *
32
   * @param id
33
   *          the id
34
   */
35
  public EhBlockingCache(final String id) {
36
    super(id);
1✔
37
    if (!CACHE_MANAGER.cacheExists(id)) {
1✔
38
      CACHE_MANAGER.addCache(this.id);
1✔
39
      Ehcache ehcache = CACHE_MANAGER.getEhcache(this.id);
1✔
40
      BlockingCache blockingCache = new BlockingCache(ehcache);
1✔
41
      CACHE_MANAGER.replaceCacheWithDecoratedCache(ehcache, blockingCache);
1✔
42
    }
43
    this.cache = CACHE_MANAGER.getEhcache(id);
1✔
44
  }
1✔
45

46
  @Override
47
  public Object removeObject(Object key) {
48
    // this method is called during a rollback just to
49
    // release any previous lock
50
    cache.put(new Element(key, null));
1✔
51
    return null;
1✔
52
  }
53

54
  /**
55
   * {@inheritDoc}
56
   * <p>
57
   * Re-wraps the rebuilt cache in a {@link BlockingCache} after replacing it.
58
   * </p>
59
   */
60
  @Override
61
  protected void rebuildCacheWith(net.sf.ehcache.config.CacheConfiguration newConfig) {
NEW
62
    CACHE_MANAGER.removeCache(id);
×
NEW
63
    CACHE_MANAGER.addCache(new net.sf.ehcache.Cache(newConfig));
×
NEW
64
    Ehcache ehcache = CACHE_MANAGER.getEhcache(id);
×
NEW
65
    BlockingCache blockingCache = new BlockingCache(ehcache);
×
NEW
66
    CACHE_MANAGER.replaceCacheWithDecoratedCache(ehcache, blockingCache);
×
NEW
67
    this.cache = CACHE_MANAGER.getEhcache(id);
×
NEW
68
  }
×
69

70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc