This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 9d3bce3d4c Jt400: possible missing resource in the native 9d3bce3d4c is described below commit 9d3bce3d4cd3af1d9e462fe03b0d973aeff59db0 Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Tue Apr 23 13:56:25 2024 +0200 Jt400: possible missing resource in the native --- .../component/jt400/deployment/Jt400Processor.java | 14 ++++++++++++++ .../component/jt400/mocked/it/Jt400MockResource.java | 13 +++++++++++++ .../quarkus/component/jt400/mocked/Jt400MockTest.java | 15 +++++++++++++++ .../camel/quarkus/component/jt400/it/Jt400Resource.java | 17 +++++++++++++---- .../camel/quarkus/component/jt400/it/Jt400Test.java | 15 +++++++++++++++ 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/extensions/jt400/deployment/src/main/java/org/apache/camel/quarkus/component/jt400/deployment/Jt400Processor.java b/extensions/jt400/deployment/src/main/java/org/apache/camel/quarkus/component/jt400/deployment/Jt400Processor.java index 133fbb3a76..a666373483 100644 --- a/extensions/jt400/deployment/src/main/java/org/apache/camel/quarkus/component/jt400/deployment/Jt400Processor.java +++ b/extensions/jt400/deployment/src/main/java/org/apache/camel/quarkus/component/jt400/deployment/Jt400Processor.java @@ -18,6 +18,7 @@ package org.apache.camel.quarkus.component.jt400.deployment; import java.util.ArrayList; import java.util.List; +import java.util.ListResourceBundle; import java.util.regex.Pattern; import com.ibm.as400.access.AS400; @@ -29,6 +30,7 @@ import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.IndexDependencyBuildItem; import io.quarkus.deployment.builditem.NativeImageEnableAllCharsetsBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; @@ -41,6 +43,7 @@ class Jt400Processor { private static final Logger LOG = Logger.getLogger(Jt400Processor.class); private static final String FEATURE = "camel-jt400"; private static final DotName CONV_TABLE_NAME = DotName.createSimple(ConvTable.class.getName()); + private static final DotName LIST_RESOURCE_BUNDLE_NAME = DotName.createSimple(ListResourceBundle.class.getName()); @BuildStep FeatureBuildItem feature() { @@ -86,6 +89,17 @@ class Jt400Processor { } + @BuildStep + void resourceBundles(BuildProducer<NativeImageResourceBundleBuildItem> imageResourceBundles, + CombinedIndexBuildItem combinedIndex) { + IndexView index = combinedIndex.getIndex(); + + index.getAllKnownSubclasses(LIST_RESOURCE_BUNDLE_NAME).stream() + .filter(cl -> cl.name().toString().startsWith("com.ibm.as400")) + .map(c -> new NativeImageResourceBundleBuildItem(c.name().toString())) + .forEach(imageResourceBundles::produce); + } + @BuildStep IndexDependencyBuildItem registerDependencyForIndex() { return new IndexDependencyBuildItem("net.sf.jt400", "jt400", "java11"); diff --git a/integration-tests/jt400-mocked/src/main/java/org/apache/camel/quarkus/component/jt400/mocked/it/Jt400MockResource.java b/integration-tests/jt400-mocked/src/main/java/org/apache/camel/quarkus/component/jt400/mocked/it/Jt400MockResource.java index fa3247e2db..0d47926d2b 100644 --- a/integration-tests/jt400-mocked/src/main/java/org/apache/camel/quarkus/component/jt400/mocked/it/Jt400MockResource.java +++ b/integration-tests/jt400-mocked/src/main/java/org/apache/camel/quarkus/component/jt400/mocked/it/Jt400MockResource.java @@ -41,6 +41,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.ConsumerTemplate; import org.apache.camel.Exchange; import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.jt400.Jt400Component; import org.apache.camel.component.jt400.Jt400Endpoint; import org.jboss.logging.Logger; @@ -157,4 +158,16 @@ public class Jt400MockResource { return Response.ok().build(); } + @Path("/component/stopWrong") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response stopComponent() throws Exception { + Jt400Component comp = context.getComponent("jt400", Jt400Component.class); + comp.close(); + //this second call to close connection won't wprk, because the connection pool is already closing + //the call would need to read from a resource bundle therefore it covers existence of resource bundle in the native + comp.getConnectionPool().close(); + return Response.ok().build(); + } + } diff --git a/integration-tests/jt400-mocked/src/test/java/org/apache/camel/quarkus/component/jt400/mocked/Jt400MockTest.java b/integration-tests/jt400-mocked/src/test/java/org/apache/camel/quarkus/component/jt400/mocked/Jt400MockTest.java index e44c1c6634..49a794338c 100644 --- a/integration-tests/jt400-mocked/src/test/java/org/apache/camel/quarkus/component/jt400/mocked/Jt400MockTest.java +++ b/integration-tests/jt400-mocked/src/test/java/org/apache/camel/quarkus/component/jt400/mocked/Jt400MockTest.java @@ -98,6 +98,21 @@ public class Jt400MockTest { Matchers.containsString("par2"))); } + /** + * Test for existence of resource bundle. + * If the bundle is not loaded properly, the close of connection pool would fail + * (see mor information in the resource method) + * + * @throws Exception + */ + @Test + public void testMissingResourceBundle() throws Exception { + //stop component and then stop connectionPool, which is already stoppingm therefore requires resourceBundle to show the failure reason + RestAssured.get("/jt400/mock/component/stopWrong") + .then() + .statusCode(200); + } + private void prepareMockReply(Jt400MockResource.ReplyType replyType, Integer hashCode, String senderInformation, diff --git a/integration-tests/jt400/src/main/java/org/apache/camel/quarkus/component/jt400/it/Jt400Resource.java b/integration-tests/jt400/src/main/java/org/apache/camel/quarkus/component/jt400/it/Jt400Resource.java index 9fd65df78c..f83cbd58b7 100644 --- a/integration-tests/jt400/src/main/java/org/apache/camel/quarkus/component/jt400/it/Jt400Resource.java +++ b/integration-tests/jt400/src/main/java/org/apache/camel/quarkus/component/jt400/it/Jt400Resource.java @@ -37,6 +37,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.ConsumerTemplate; import org.apache.camel.Exchange; import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.jt400.Jt400Component; import org.apache.camel.component.jt400.Jt400Endpoint; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -169,13 +170,21 @@ public class Jt400Resource { } boolean resp = context.getRouteController().getRouteStatus(routeName).isStopped(); - //stop component to avoid CPF2451 Message queue REPLYMSGQ is allocated to another job. - Jt400Endpoint jt400Endpoint = context.getEndpoint(getUrlForLibrary(jt400MessageReplyToQueue), Jt400Endpoint.class); - jt400Endpoint.close(); - return Response.ok().entity(resp).build(); } + @Path("/component/stopWrong") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response stopComponent() throws Exception { + Jt400Component comp = context.getComponent("jt400", Jt400Component.class); + comp.close(); + //this second call to close connection won't wprk, because the connection pool is already closing + //the call would need to read from a resource bundle therefore it covers existence of resource bundle in the native + comp.getConnectionPool().close(); + return Response.ok().build(); + } + @Path("/inquiryMessageSetExpected") @POST public void inquiryMessageSetExpected(String msg) { diff --git a/integration-tests/jt400/src/test/java/org/apache/camel/quarkus/component/jt400/it/Jt400Test.java b/integration-tests/jt400/src/test/java/org/apache/camel/quarkus/component/jt400/it/Jt400Test.java index 2f9bfd7c69..f138516384 100644 --- a/integration-tests/jt400/src/test/java/org/apache/camel/quarkus/component/jt400/it/Jt400Test.java +++ b/integration-tests/jt400/src/test/java/org/apache/camel/quarkus/component/jt400/it/Jt400Test.java @@ -271,6 +271,21 @@ public class Jt400Test { LOGGER.debug("testInquiryMessageQueue: reply message confirmed by peek: " + replyMsg); } + /** + * Test for existence of resource bundle. + * If the bundle is not loaded properly, the close of connection pool would fail + * (see mor information in the resource method) + * + * @throws Exception + */ + @Test + public void testMissingResourceBundle() throws Exception { + //stop component and then stop connectionPool, which is already stoppingm therefore requires resourceBundle to show the failure reason + RestAssured.get("/jt400/component/stopWrong") + .then() + .statusCode(200); + } + @Test public void testProgramCall() { RestAssured.given()