Skip to content

Commit

Permalink
Introduces an ExecutorServices implementation to Helidon's repackaged…
Browse files Browse the repository at this point in the history
… Weld implementation to ensure context classloaders are never null (#2269)

* Introduces an ExecutorServices implementation to Helidon's repackaged Weld implementation to ensure context classloaders are never null.
Signed-off-by: Laird Nelson <laird.nelson@oracle.com>
  • Loading branch information
ljnelson authored Sep 1, 2020
1 parent 0c2dd6a commit 8b58ec5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
*
* Licensed 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 io.helidon.microprofile.cdi;

import java.util.Collection;
import java.util.concurrent.Callable;

import org.jboss.weld.executor.CommonForkJoinPoolExecutorServices;

/**
* A {@link CommonForkJoinPoolExecutorServices} whose {@link
* #wrap(Collection)} method simply returns the supplied {@link
* Collection} of {@link Callable}s unchanged.
*
* <p>This class exists to work around <a
* href="https://issues.redhat.com/browse/WELD-2494"
* target="_parent">WELD-2494</a>, which, in turn, was working around
* <a href="https://bugs.openjdk.java.net/browse/JDK-8184335"
* target="_parent">JDK-8184335</a>.</p>
*
* @see #wrap(Collection)
*/
public final class ExecutorServices extends CommonForkJoinPoolExecutorServices {

/**
* Creates a new {@link ExecutorServices}.
*
* <p>There is no reason for users to call this constructor.</p>
*/
public ExecutorServices() {
super();
}

/**
* Returns the supplied {@code tasks} argument unchanged when invoked.
*
* @param tasks a {@link Collection} of {@link Callable}s
* representing tasks that Weld needs to do; may be {@code null}
*
* @return the supplied {@code tasks} argument
*
* @see <a href="https://issues.redhat.com/browse/WELD-2494"
* target="_parent">WELD-2494</a>
*/
@Override
public <T> Collection<? extends Callable<T>> wrap(Collection<? extends Callable<T>> tasks) {
return tasks;
}

}
4 changes: 3 additions & 1 deletion microprofile/cdi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

import javax.enterprise.inject.se.SeContainerInitializer;

import io.helidon.microprofile.cdi.ExecutorServices;
import io.helidon.microprofile.cdi.HelidonContainerInitializer;

/**
Expand Down Expand Up @@ -44,4 +45,5 @@
uses javax.enterprise.inject.spi.Extension;

provides SeContainerInitializer with HelidonContainerInitializer;
provides org.jboss.weld.bootstrap.api.Service with ExecutorServices;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2020 Oracle and/or its affiliates.
#
# Licensed 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.
#

io.helidon.microprofile.weld.ExecutorServices

0 comments on commit 8b58ec5

Please sign in to comment.