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

ben-manes / caffeine / #5612

11 Jul 2026 03:47PM UTC coverage: 71.292% (-28.7%) from 100.0%
#5612

push

github

ben-manes
Preserve timestamps on a raced same-instance refresh

The automatic refreshIfNeeded path checked for an equal-value reload
before the ABA/ownership check and returned without preserving the
timestamps, so a reload completing after a concurrent put(k,
sameInstance) did a full update — shifting the entry's expiration
forward by the reload's in-flight duration and stomping the write.
Mirror the explicit-refresh fix: check ownership first. An owned
reload installs the value (refreshing metadata even for a same
instance), while a raced reload preserves the write's timestamps and
only notifies REPLACED when the value differs.

2957 of 4134 branches covered (71.53%)

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

2408 existing lines in 53 files now uncovered.

5980 of 8388 relevant lines covered (71.29%)

0.71 hits per line

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

0.0
/jcache/src/main/java/com/github/benmanes/caffeine/jcache/copy/Copier.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.jcache.copy;
17

18
import org.jspecify.annotations.NullMarked;
19

20
/**
21
 * An object is copied when the cache is configured with <code>storeByValue</code> to guard against
22
 * mutations of the key or value.
23
 *
24
 * @author ben.manes@gmail.com (Ben Manes)
25
 */
26
@NullMarked
27
@FunctionalInterface
28
public interface Copier {
29

30
  /**
31
   * Returns a deep copy of the object.
32
   *
33
   * @param object the object to copy
34
   * @param classLoader the classloader to instantiate with
35
   * @param <T> the type of object being copied
36
   * @return a copy of the object
37
   */
38
  <T> T copy(T object, ClassLoader classLoader);
39

40
  /** Return a copy strategy that performs an identity function, for use by store-by-reference. */
41
  static Copier identity() {
UNCOV
42
    return IdentityCopier.INSTANCE;
×
43
  }
44
}
45

UNCOV
46
enum IdentityCopier implements Copier {
×
UNCOV
47
  INSTANCE;
×
48

49
  @Override
50
  public <T> T copy(T object, ClassLoader classLoader) {
UNCOV
51
    return object;
×
52
  }
53
}
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