-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ActiveMQ on Java 25 #1563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveMQ on Java 25 #1563
Changes from all commits
b43b882
e0d9c41
c8261e8
184c64c
15c6f7f
51ccb58
11b6fa3
9b5e101
a17b795
1de8b1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** | ||
| * 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.activemq.broker.jmx; | ||
|
|
||
| import javax.security.auth.Subject; | ||
| import java.security.AccessController; | ||
|
|
||
| /** | ||
| * [AMQ-9563] JDK JAAS API conversion assistance | ||
| * | ||
| * This instance of the class is for JDK [17, 24) | ||
| * | ||
| */ | ||
| public class SubjectShim { | ||
|
|
||
| private SubjectShim() {} | ||
|
|
||
| public static Subject lookupSubject() { | ||
| return Subject.getSubject(AccessController.getContext()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * 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.activemq.broker.jmx; | ||
|
|
||
| import javax.security.auth.Subject; | ||
|
|
||
| /** | ||
| * [AMQ-9563] JDK JAAS API conversion assistance | ||
| * | ||
| * This instance of the class is for JDK 24+ | ||
| * | ||
| */ | ||
| public class SubjectShim { | ||
|
|
||
| private SubjectShim() {} | ||
|
|
||
| public static Subject lookupSubject() { | ||
| return Subject.current(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,10 +240,7 @@ public void uncaughtException(final Thread t, final Throwable e) { | |
| } | ||
|
|
||
| protected ExecutorService createVirtualThreadExecutor() { | ||
| if(!(Runtime.version().feature() >= 21)) { | ||
| LOG.error("Virtual Thread support requires JDK 21 or higher"); | ||
| throw new IllegalStateException("Virtual Thread support requires JDK 21 or higher"); | ||
| } | ||
| assertJDK21VirtualThreadSupport(); | ||
|
|
||
| try { | ||
| Class<?> virtualThreadExecutorClass = Class.forName("org.apache.activemq.thread.VirtualThreadExecutor", false, threadClassLoader); | ||
|
|
@@ -253,18 +250,15 @@ protected ExecutorService createVirtualThreadExecutor() { | |
| throw new IllegalStateException("VirtualThreadExecutor not returned"); | ||
| } | ||
| LOG.info("VirtualThreadExecutor initialized name:{}", name); | ||
| return ExecutorService.class.cast(result); | ||
| return (ExecutorService) result; | ||
| } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) { | ||
| LOG.error("VirtualThreadExecutor class failed to load", e); | ||
| throw new IllegalStateException(e); | ||
| } | ||
| } | ||
|
|
||
| protected TaskRunner createVirtualThreadTaskRunner(Executor executor, Task task, int maxIterations) { | ||
| if(!(Runtime.version().feature() >= 21)) { | ||
| LOG.error("Virtual Thread support requires JDK 21 or higher"); | ||
| throw new IllegalStateException("Virtual Thread support requires JDK 21 or higher"); | ||
| } | ||
| assertJDK21VirtualThreadSupport(); | ||
|
|
||
| try { | ||
| Class<?> virtualThreadTaskRunnerClass = Class.forName("org.apache.activemq.thread.VirtualThreadTaskRunner", false, threadClassLoader); | ||
|
|
@@ -273,13 +267,20 @@ protected TaskRunner createVirtualThreadTaskRunner(Executor executor, Task task, | |
| if(!TaskRunner.class.isAssignableFrom(result.getClass())) { | ||
| throw new IllegalStateException("VirtualThreadTaskRunner not returned"); | ||
| } | ||
| return TaskRunner.class.cast(result); | ||
| return (TaskRunner) result; | ||
| } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException | InstantiationException | IllegalArgumentException e) { | ||
| LOG.error("VirtualThreadTaskRunner class failed to load", e); | ||
| throw new IllegalStateException(e); | ||
| } | ||
| } | ||
|
|
||
| private void assertJDK21VirtualThreadSupport() { | ||
| if(!(Runtime.version().feature() >= 21)) { | ||
| LOG.error("Virtual Thread support requires JDK 21 or higher"); | ||
| throw new IllegalStateException("Virtual Thread support requires JDK 21 or higher"); | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+277
to
+283
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cleanup seems fine, but a thought for later would be....is there any need for all the reflection above and this runtime version checking, when the client jar is already a multi-release jar requiring Java 21 (and soon 24[/25]) to release it? Could maybe have a [couple variants of] trivial delegate class.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a refactoring of @mattrpav 's code. So I'd let him reply. |
||
|
|
||
| public ExecutorService getExecutor() { | ||
| return executorRef.get(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * 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.activemq.store.kahadb.disk.journal; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| public interface DataFileFactory { | ||
| DataFile create(File file, int number); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason to use
verifyhere more thantest? I'm just curious.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was mostly due to the introduction of failsafe to delay the execution of tests using the MRJAR because the jar is created only after the test phase. So tests using MRJAR were postponed to run only during the integration test phase. So if you use test and not verify you won't run them.
In the end, I could have reverted this because Robbie requested instead to change the phase of the JAR plugin so the MRJAR is built in the process classes phase and therefor it's visible to the test plugin. Does not hurt. Could have been removed