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

creek-service / creek-base / #1054

01 Mar 2025 09:01AM UTC coverage: 98.222% (-0.4%) from 98.667%
#1054

push

github

web-flow
Bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#382)

Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/62b2cac7e...f49aabe0b)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

221 of 225 relevant lines covered (98.22%)

0.98 hits per line

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

94.12
/type/src/main/java/org/creekservice/api/base/type/Suppliers.java
1
/*
2
 * Copyright 2022-2024 Creek Contributors (https://github.com/creek-service)
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

17
package org.creekservice.api.base.type;
18

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

21
import java.util.function.Supplier;
22

23
/** Factory methods for creating {@link Supplier suppliers} */
24
public final class Suppliers {
25

26
    private Suppliers() {}
27

28
    /**
29
     * Create a Supplier that will cache the value returned from the {@code delegate} on first use.
30
     *
31
     * @param delegate the delegate that will be called once on first use.
32
     * @param <T> the type of the supplier
33
     * @return a caching Supplier.
34
     */
35
    public static <T> Supplier<T> memoize(final Supplier<T> delegate) {
36
        return (delegate instanceof MemorizingSupplier)
1✔
37
                ? delegate
1✔
38
                : new MemorizingSupplier<>(delegate);
1✔
39
    }
40

41
    private static final class MemorizingSupplier<T> implements Supplier<T> {
42

43
        private final Supplier<T> delegate;
44
        private final Object lock = new Object();
1✔
45
        private transient volatile boolean initialized;
46
        private transient T value;
47

48
        private MemorizingSupplier(final Supplier<T> delegate) {
1✔
49
            this.delegate = requireNonNull(delegate, "delegate");
1✔
50
        }
1✔
51

52
        @Override
53
        public T get() {
54
            if (!initialized) {
1✔
55
                synchronized (lock) {
1✔
56
                    if (!initialized) {
1✔
57
                        final T t = delegate.get();
1✔
58
                        value = t;
1✔
59
                        initialized = true;
1✔
60
                        return t;
1✔
61
                    }
62
                }
×
63
            }
64
            return value;
1✔
65
        }
66

67
        @Override
68
        public String toString() {
69
            return "Suppliers.memoize(" + delegate + ")";
1✔
70
        }
71
    }
72
}
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