You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2018/12/10 14:47:36 UTC

[33/38] tomee git commit: Revert Lazy load of key. This was an attempt to load the key after the application start, but from the spec if the key is not present we need to fail with a Deployment Exception, so the key needs to be loaded eagerly.

Revert Lazy load of key. This was an attempt to load the key after the application start, but from the spec if the key is not present we need to fail with a Deployment Exception, so the key needs to be loaded eagerly.


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2cdfe225
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2cdfe225
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2cdfe225

Branch: refs/heads/master
Commit: 2cdfe2250e72a7dff64c635f279798e31f1f8d76
Parents: 3455fc7
Author: Roberto Cortez <ra...@yahoo.com>
Authored: Tue Dec 4 12:12:54 2018 +0000
Committer: Roberto Cortez <ra...@yahoo.com>
Committed: Fri Dec 7 18:13:05 2018 +0000

----------------------------------------------------------------------
 .../config/ConfigurableJWTAuthContextInfo.java  |  7 ++-
 .../tomee/microprofile/jwt/config/Lazy.java     | 54 --------------------
 2 files changed, 3 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2cdfe225/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
----------------------------------------------------------------------
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
index 59decad..5d41b5e 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
@@ -71,15 +71,14 @@ public class ConfigurableJWTAuthContextInfo {
     @Inject
     private Config config;
 
-    private Supplier<JWTAuthContextInfo> jwtAuthContextInfo;
+    private JWTAuthContextInfo jwtAuthContextInfo;
 
     public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext context) {
-        // load the key set once, lazily
-        this.jwtAuthContextInfo = new Lazy<>(() -> createJWTAuthContextInfo());
+        this.jwtAuthContextInfo = createJWTAuthContextInfo();
     }
 
     public Optional<JWTAuthContextInfo> getJWTAuthContextInfo() {
-        return Optional.ofNullable(jwtAuthContextInfo.get());
+        return Optional.ofNullable(jwtAuthContextInfo);
     }
 
     private Optional<String> getVerifierPublicKey() {

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cdfe225/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/Lazy.java
----------------------------------------------------------------------
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/Lazy.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/Lazy.java
deleted file mode 100644
index 2267fe8..0000000
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/Lazy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tomee.microprofile.jwt.config;
-
-import org.apache.bval.util.Validate;
-
-import java.util.function.Supplier;
-
-public class Lazy<T> implements Supplier<T> {
-    private T value;
-    private volatile Supplier<T> init;
-
-    public Lazy(Supplier<T> init) {
-        reset(init);
-    }
-
-    public Lazy<T> reset(Supplier<T> init) {
-        this.init = Validate.notNull(init);
-        return this;
-    }
-
-    public synchronized Lazy<T> reset(T value) {
-        this.value = value;
-        this.init = null;
-        return this;
-    }
-
-    @Override
-    public T get() {
-        if (init != null) {
-            synchronized (this) {
-                if (init != null) {
-                    value = init.get();
-                    init = null;
-                }
-            }
-        }
-        return value;
-    }
-}