[ 
https://issues.apache.org/jira/browse/ARTEMIS-5340?focusedWorklogId=960435&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-960435
 ]

ASF GitHub Bot logged work on ARTEMIS-5340:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Mar/25 07:39
            Start Date: 06/Mar/25 07:39
    Worklog Time Spent: 10m 
      Work Description: brusdev commented on code in PR #5547:
URL: https://github.com/apache/activemq-artemis/pull/5547#discussion_r1982838917


##########
artemis-core-client/src/test/java/org/apache/activemq/artemis/core/remoting/impl/netty/PEMProviderTest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.artemis.core.remoting.impl.netty;
+
+import java.lang.reflect.Method;
+
+import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class PEMProviderTest {
+
+   @Test
+   public void testPEMProviderNotLoaded() throws Exception {
+      // use a method from SSLSupport to force the JVM to load it as well as 
any hard dependencies it has
+      SSLSupport.parseCommaSeparatedListIntoArray("");
+
+      // verify the actual PEM provider class is not loaded
+      Method findLoadedClassMethod = 
ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
+      findLoadedClassMethod.setAccessible(true);
+      
assertNull(findLoadedClassMethod.invoke(ClassLoader.getSystemClassLoader(), 
SSLSupport.PEM_PROVIDER));

Review Comment:
   An alternative to avoid `--add-opens java.base/java.lang=ALL-UNNAMED` is to 
check for the defined packages, i.e.
   ```suggestion
         
assertNull(ClassLoader.getSystemClassLoader().getDefinedPackage("de.dentrassi.crypto.pem"));
   ```





Issue Time Tracking
-------------------

    Worklog Id:     (was: 960435)
    Time Spent: 20m  (was: 10m)

> PEM provider not actually optional
> ----------------------------------
>
>                 Key: ARTEMIS-5340
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5340
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Work was done via ARTEMIS-4710 to make the dependencies for the PEM security 
> provider optional. However, that work was not complete.
> The provider class still has to be loaded by the JVM the first time any 
> reference to {{SSLSupport}} is made which is done when enabling SSL on any 
> acceptor, e.g.:
> {noformat}
> Caused by: java.lang.NoClassDefFoundError: 
> de/dentrassi/crypto/pem/PemKeyStoreProvider
>       at 
> org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor.<init>(NettyAcceptor.java:294){noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to