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

ben-manes / caffeine / #5590

05 Jul 2026 06:38AM UTC coverage: 99.652% (-0.3%) from 99.904%
#5590

push

github

ben-manes
Resolve substitutions in URI-loaded jcache configs

TypesafeConfigurator's file/jar/classpath branches returned a config
stack built on defaultReferenceUnresolved without calling resolve(),
so any HOCON substitution (${ref}, or ${caffeine.jcache.default}
inheritance) threw ConfigException.NotResolved on the first getter.
The default ConfigFactory.load() branch already resolves; append
.resolve() to the three URI branches to match.

4062 of 4088 branches covered (99.36%)

6 of 6 new or added lines in 1 file covered. (100.0%)

21 existing lines in 3 files now uncovered.

8308 of 8337 relevant lines covered (99.65%)

1.0 hits per line

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

62.86
/caffeine/src/main/java/com/github/benmanes/caffeine/cache/stats/GuardedStatsCounter.java
1
/*
2
 * Copyright 2015 Ben Manes. All Rights Reserved.
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
 *     http://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 com.github.benmanes.caffeine.cache.stats;
17

18
import static java.util.Objects.requireNonNull;
19

20
import java.lang.System.Logger;
21
import java.lang.System.Logger.Level;
22

23
import com.github.benmanes.caffeine.cache.RemovalCause;
24

25
/**
26
 * A {@link StatsCounter} implementation that suppresses and logs any exception thrown by the
27
 * delegate <code>statsCounter</code>.
28
 *
29
 * @author ben.manes@gmail.com (Ben Manes)
30
 */
31
final class GuardedStatsCounter implements StatsCounter {
32
  static final Logger logger = System.getLogger(GuardedStatsCounter.class.getName());
1✔
33

34
  final StatsCounter delegate;
35

36
  GuardedStatsCounter(StatsCounter delegate) {
1✔
37
    this.delegate = requireNonNull(delegate);
1✔
38
  }
1✔
39

40
  @Override
41
  public void recordHits(int count) {
42
    try {
43
      delegate.recordHits(count);
1✔
UNCOV
44
    } catch (Throwable t) {
×
UNCOV
45
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
46
    }
1✔
47
  }
1✔
48

49
  @Override
50
  public void recordMisses(int count) {
51
    try {
52
      delegate.recordMisses(count);
1✔
UNCOV
53
    } catch (Throwable t) {
×
UNCOV
54
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
55
    }
1✔
56
  }
1✔
57

58
  @Override
59
  public void recordLoadSuccess(long loadTime) {
60
    try {
61
      delegate.recordLoadSuccess(loadTime);
1✔
UNCOV
62
    } catch (Throwable t) {
×
UNCOV
63
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
64
    }
1✔
65
  }
1✔
66

67
  @Override
68
  public void recordLoadFailure(long loadTime) {
69
    try {
70
      delegate.recordLoadFailure(loadTime);
1✔
UNCOV
71
    } catch (Throwable t) {
×
UNCOV
72
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
73
    }
1✔
74
  }
1✔
75

76
  @Override
77
  public void recordEviction(int weight, RemovalCause cause) {
78
    requireNonNull(cause);
1✔
79
    try {
80
      delegate.recordEviction(weight, cause);
1✔
UNCOV
81
    } catch (Throwable t) {
×
UNCOV
82
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
83
    }
1✔
84
  }
1✔
85

86
  @Override
87
  public CacheStats snapshot() {
88
    try {
89
      return delegate.snapshot();
1✔
UNCOV
90
    } catch (Throwable t) {
×
UNCOV
91
      logger.log(Level.WARNING, "Exception thrown by stats counter", t);
×
UNCOV
92
      return CacheStats.empty();
×
93
    }
94
  }
95

96
  @Override
97
  public String toString() {
98
    return delegate.toString();
1✔
99
  }
100
}
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