From 56d450abac39f9ad34eb317191bc971c1a4bf3ec Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 06:07:41 +0000 Subject: [PATCH 1/3] Bump version.mockito from 3.1.0 to 3.2.0 Bumps `version.mockito` from 3.1.0 to 3.2.0. Updates `mockito-core` from 3.1.0 to 3.2.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.1.0...v3.2.0) Updates `mockito-junit-jupiter` from 3.1.0 to 3.2.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.1.0...v3.2.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 31cdb195..3eb6ac18 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 5.5.2 1.5.2 - 3.1.0 + 3.2.0 PADLA for Java From 41973d21ac9857a2e860f52fb24aa0142415c662 Mon Sep 17 00:00:00 2001 From: PROgrm_JARvis Date: Mon, 9 Dec 2019 19:58:24 +0300 Subject: [PATCH 2/3] Create README.md --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..7fb4385e --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# PADLA + +###### Plain And Direct Language Additions for Java + +[![License](https://img.shields.io/github/license/JarvisCraft/padla)](/LICENSE) +[![CodeFactor](https://www.codefactor.io/repository/github/jarviscraft/padla/badge)](https://www.codefactor.io/repository/github/jarviscraft/padla) + +## What is it? + +PADLA is a collection of useful general-purpose utilities for Java aimed at fulfilling common needs. +It uses functional approach intensively and attempts to follow OOP-approach as right as possible. +In addition to common tools, it does also provide more specific ones aimed at maximal productivity. + +## Dependencies + +As its dependencies PADLA uses: +- Compiletime: + - [Lombok](https://github.com/rzwitserloot/lombok) for generating boilerplate stuff + - [Jetbrains Annotations](https://github.com/JetBrains/java-annotations) and []() for documenting code logic +- Runtime: + - [Guava](https://github.com/google/guava) for some general-purpose needs + - [GSON](https://github.com/google/gson) for manipulating JSON +- Testing: + - [Junit5](https://github.com/junit-team/junit5/) with related sub-tools for testing + - [Hamcrest](https://github.com/hamcrest/JavaHamcrest) for more creating more readable tests + - [Mockito](https://github.com/mockito/mockito) for mocking in tests +- Additional (these are not inherited by default and are required only if using specific classes): + - [ASM](https://gitlab.ow2.org/asm/asm) for runtime class generation (if using classes annotated with `BytecodeLibrary(ASM)`) + - [Javassist](https://github.com/jboss-javassist/javassist) for runtime class generation (if using classes annotated with `BytecodeLibrary(JAVASSIST)`) From 3ad43b5ab36468abdfa698f4faca36421197ff85 Mon Sep 17 00:00:00 2001 From: JarvisStark Date: Mon, 9 Dec 2019 21:53:14 +0300 Subject: [PATCH 3/3] Refactor `Lazy` to fix nullability inspection and utilize field access --- .../ru/progrm_jarvis/javacommons/lazy/Lazy.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/lazy/Lazy.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/lazy/Lazy.java index 44ea7667..bc9ea521 100644 --- a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/lazy/Lazy.java +++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/lazy/Lazy.java @@ -72,7 +72,7 @@ static Lazy createThreadSafe(@NonNull final Supplier valueSupplier) { * @apiNote weak lazy stores the value wrapped in weak reference and so it may be GCed * and so the new one might be recomputed using the value supplier */ - static Lazy createWeak(@NonNull final Supplier valueSupplier) { + static Lazy createWeak(@NonNull final Supplier<@NotNull T> valueSupplier) { return new SimpleWeakLazy<>(valueSupplier); } @@ -104,7 +104,7 @@ class SimpleLazy implements Lazy { */ @Nullable Supplier valueSupplier; - protected SimpleLazy(@NonNull final Supplier valueSupplier) { + protected SimpleLazy(@SuppressWarnings("NullableProblems") @NonNull final Supplier valueSupplier) { this.valueSupplier = valueSupplier; } @@ -115,9 +115,10 @@ protected SimpleLazy(@NonNull final Supplier valueSupplier) { @Override public T get() { + val valueSupplier = this.valueSupplier; if (valueSupplier != null) { value = valueSupplier.get(); - valueSupplier = null; + this.valueSupplier = null; } return value; @@ -153,7 +154,7 @@ class DoubleCheckedLazy implements Lazy { */ volatile T value; - protected DoubleCheckedLazy(@NonNull final Supplier valueSupplier) { + protected DoubleCheckedLazy(@SuppressWarnings("NullableProblems") @NonNull final Supplier valueSupplier) { mutex = new Object[0]; this.valueSupplier = valueSupplier; } @@ -161,9 +162,13 @@ protected DoubleCheckedLazy(@NonNull final Supplier valueSupplier) { @Override public T get() { if (valueSupplier != null) synchronized (mutex) { + val valueSupplier = this.valueSupplier; if (valueSupplier != null) { - value = valueSupplier.get(); - valueSupplier = null; + val value = this.value = valueSupplier.get(); + this.valueSupplier = null; + + // make sure no race is possible in theory + return value; } }