This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7be2ac6ad457 chore(components): various minor compilation warnings
7be2ac6ad457 is described below
commit 7be2ac6ad457d748d501ff08b91b9732bc155eb0
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Wed Dec 10 11:32:33 2025 +0100
chore(components): various minor compilation warnings
---
.../cxf/common/CxfOperationException.java | 3 +-
.../component/cxf/converter/CxfConverter.java | 1 -
.../cxf/feature/RAWDataFormatFeature.java | 3 +-
.../camel/component/cxf/jaxws/CxfConsumer.java | 5 +-
.../camel/component/cxf/jaxws/CxfEndpoint.java | 3 +-
.../converter/CxfPayLoadStreamCacheRouterTest.java | 2 +-
.../cxf/jaxws/CxfConsumerPayloadXPathTest.java | 12 ++---
.../cxf/jaxws/CxfConsumerStartTwiceTest.java | 52 ++++++++++-----------
.../cxf/jaxws/CxfSchemaValidationTest.java | 6 +--
.../component/cxf/util/CxfEndpointUtilsTest.java | 53 ++++++++++++----------
10 files changed, 73 insertions(+), 67 deletions(-)
diff --git
a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/CxfOperationException.java
b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/CxfOperationException.java
index eaf166311172..5b7496925847 100644
---
a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/CxfOperationException.java
+++
b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/CxfOperationException.java
@@ -16,12 +16,11 @@
*/
package org.apache.camel.component.cxf.common;
-import java.io.Serializable;
import java.util.Map;
import org.apache.camel.CamelException;
-public class CxfOperationException extends CamelException implements
Serializable {
+public class CxfOperationException extends CamelException {
private static final long serialVersionUID = 803109169584916327L;
private final String uri;
diff --git
a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
index e837f53d4f91..ced53432b39e 100644
---
a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
+++
b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
@@ -123,7 +123,6 @@ public final class CxfConverter {
* @param registry type converter registry
* @return the converted value of the desired type or null if no
suitable converter found
*/
- @SuppressWarnings("unchecked")
@Converter(fallback = true)
public static <T> T convertTo(
Class<T> type, Exchange exchange, Object value,
diff --git
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/feature/RAWDataFormatFeature.java
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/feature/RAWDataFormatFeature.java
index 573eacffaa1a..cfe4d1f003aa 100644
---
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/feature/RAWDataFormatFeature.java
+++
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/feature/RAWDataFormatFeature.java
@@ -25,6 +25,7 @@ import org.apache.cxf.endpoint.Server;
import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.interceptor.OneWayProcessorInterceptor;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.Phase;
import org.slf4j.Logger;
@@ -104,7 +105,7 @@ public class RAWDataFormatFeature extends
AbstractDataFormatFeature {
if (isOneway()) {
Interceptor<? extends Message> toRemove = null;
for (Interceptor<? extends Message> i :
server.getEndpoint().getService().getInInterceptors()) {
- if
(i.getClass().getName().equals("org.apache.cxf.interceptor.OutgoingChainInterceptor"))
{
+ if (i instanceof OutgoingChainInterceptor) {
toRemove = i;
}
}
diff --git
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java
index 347f3d68e42a..e6e7a82c69f5 100644
---
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java
+++
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java
@@ -230,9 +230,10 @@ public class CxfConsumer extends DefaultConsumer
implements Suspendable {
= (ContinuationProvider)
cxfExchange.getInMessage().get(ContinuationProvider.class.getName());
Continuation continuation = provider == null ? null :
provider.getContinuation();
// Make sure we don't return the JMSContinuation, as it doesn't
support the Continuation we wants
- // Don't want to introduce the dependency of cxf-rt-transprot-jms
here
+ // Don't want to introduce the dependency of cxf-rt-transprot-jms
here.
+ // NOTE: The class dependency has to be included at compilation
time by the user, so, we cannot use instanceof operator.
if (continuation != null
- &&
continuation.getClass().getName().equals("org.apache.cxf.transport.jms.continuations.JMSContinuation"))
{
+ &&
continuation.getClass().getName().equals("org.apache.cxf.transport.jms.continuations.JMSContinuation"))
{ // NOSONAR
return null;
} else {
return continuation;
diff --git
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
index c8cb74bd785d..9fdb55a2b6a6 100644
---
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
+++
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
@@ -56,7 +56,6 @@ import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.Service;
import org.apache.camel.component.cxf.common.CxfBinding;
import org.apache.camel.component.cxf.common.CxfPayload;
import org.apache.camel.component.cxf.common.DataFormat;
@@ -133,7 +132,7 @@ import static
org.apache.camel.component.cxf.common.message.CxfConstants.SCHEME_
@Metadata(annotations = {
"protocol=http",
})
-public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint,
HeaderFilterStrategyAware, Service, Cloneable {
+public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint,
HeaderFilterStrategyAware, Cloneable {
private static final Logger LOG =
LoggerFactory.getLogger(CxfEndpoint.class);
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/converter/CxfPayLoadStreamCacheRouterTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/converter/CxfPayLoadStreamCacheRouterTest.java
index 9da137e0980c..2daf1e1636bb 100644
---
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/converter/CxfPayLoadStreamCacheRouterTest.java
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/converter/CxfPayLoadStreamCacheRouterTest.java
@@ -37,7 +37,7 @@ public class CxfPayLoadStreamCacheRouterTest extends
CxfSimpleRouterTest {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: payload
- from(routerEndpointURI).streamCaching().process(new
Processor() {
+ from(routerEndpointURI).streamCache(true).process(new
Processor() {
public void process(Exchange exchange) throws Exception {
Object payload = exchange.getIn().getBody();
assertTrue(payload instanceof StreamCache, "payload is
not a StreamCache");
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerPayloadXPathTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerPayloadXPathTest.java
index 26de86cca239..8c590b6483c6 100644
---
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerPayloadXPathTest.java
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerPayloadXPathTest.java
@@ -95,7 +95,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
@Override
public void configure() {
from("cxf://" + testAddress + "?dataFormat=PAYLOAD")
- .streamCaching()
+ .streamCache(true)
.process(new XPathProcessor())
.process(new ResponseProcessor());
}
@@ -105,7 +105,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
@Override
public void configure() {
from("cxf://" + testAddress + "?dataFormat=PAYLOAD")
- .streamCaching()
+ .streamCache(true)
.process(new XPathStringResultProcessor())
.process(new ResponseProcessor());
}
@@ -115,7 +115,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
@Override
public void configure() {
from("cxf://" + testAddress + "?dataFormat=PAYLOAD")
- .streamCaching()
+ .streamCache(true)
.process(new DomFirstOneOnlyProcessor())
.process(new ResponseProcessor());
}
@@ -125,7 +125,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
@Override
public void configure() {
from("cxf://" + testAddress + "?dataFormat=PAYLOAD")
- .streamCaching()
+ .streamCache(true)
.process(new DomProcessor())
.process(new ResponseProcessor());
}
@@ -208,7 +208,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
private void simpleTest(int repeat, BaseRouteBuilder builder) throws
Exception {
testConfiguration().withUseRouteBuilder(false);
context.addRoutes(builder);
- startCamelContext();
+ context.start();
String content = StringUtils.repeat("x", repeat);
String msgIn = constructSoapMessage(content);
@@ -230,7 +230,7 @@ public class CxfConsumerPayloadXPathTest extends
CamelTestSupport {
assertTrue(result.length() > repeat, "dataloss in output occurred");
- stopCamelContext();
+ context.stop();
}
private abstract class BaseRouteBuilder extends RouteBuilder {
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerStartTwiceTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerStartTwiceTest.java
index 99815a543f65..592476188afd 100644
---
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerStartTwiceTest.java
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerStartTwiceTest.java
@@ -30,38 +30,38 @@ public class CxfConsumerStartTwiceTest {
@Test
public void startServiceTwice() throws Exception {
- CamelContext context = new DefaultCamelContext();
+ try (CamelContext context = new DefaultCamelContext()) {
+ final String fromStr = "cxf:http://localhost:" + PORT + "/"
+ + this.getClass().getSimpleName()
+ +
"/test?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService";
- final String fromStr = "cxf:http://localhost:" + PORT + "/"
- + this.getClass().getSimpleName()
- +
"/test?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService";
+ //add the same route twice...
+ context.addRoutes(new RouteBuilder() {
+ public void configure() {
+ from(fromStr)
+ .to("log:POJO");
+ }
+ });
- //add the same route twice...
- context.addRoutes(new RouteBuilder() {
- public void configure() {
- from(fromStr)
- .to("log:POJO");
- }
- });
+ context.addRoutes(new RouteBuilder() {
+ public void configure() {
+ from(fromStr)
+ .to("log:POJO");
+ }
+ });
- context.addRoutes(new RouteBuilder() {
- public void configure() {
- from(fromStr)
- .to("log:POJO");
+ try {
+ context.start();
+ fail("Expect to catch an exception here");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().endsWith(
+ "Multiple consumers for the same endpoint is not
allowed: cxf://http://localhost:" + PORT
+ + "/" +
getClass().getSimpleName()
+ +
"/test?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService"));
}
- });
- try {
- context.start();
- fail("Expect to catch an exception here");
- } catch (Exception ex) {
- assertTrue(ex.getMessage().endsWith(
- "Multiple consumers for the same endpoint is not allowed:
cxf://http://localhost:" + PORT
- + "/" +
getClass().getSimpleName()
- +
"/test?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService"));
+ context.stop();
}
-
- context.stop();
}
}
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfSchemaValidationTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfSchemaValidationTest.java
index 26f285a900da..99aa9326a6a2 100644
---
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfSchemaValidationTest.java
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfSchemaValidationTest.java
@@ -108,7 +108,7 @@ public class CxfSchemaValidationTest extends
CamelTestSupport {
public void schemaValidationDisabledServerTest() throws Exception {
// invoke the service with a non-valid message
try {
- invokeService(serviceAddressValidationDisabled,
RandomStringUtils.random(40, true, true));
+ invokeService(serviceAddressValidationDisabled,
RandomStringUtils.secure().next(40, true, true));
} catch (SOAPFaultException e) {
fail("Do not expect an exception here");
}
@@ -117,7 +117,7 @@ public class CxfSchemaValidationTest extends
CamelTestSupport {
@Test
public void schemaValidationEnabledServerTest() throws Exception {
//first, invoke service with valid message. No exception should be
thrown
- invokeService(serviceAddressValidationEnabled,
RandomStringUtils.random(10, true, true));
+ invokeService(serviceAddressValidationEnabled,
RandomStringUtils.secure().next(10, true, true));
// then invoke the service with a non-valid message
@@ -134,7 +134,7 @@ public class CxfSchemaValidationTest extends
CamelTestSupport {
*/
try {
- invokeService(serviceAddressValidationEnabled,
RandomStringUtils.random(40, true, true));
+ invokeService(serviceAddressValidationEnabled,
RandomStringUtils.secure().next(40, true, true));
fail("expect a Validation exception here");
} catch (SOAPFaultException e) {
assertEquals("the length of the value is 40, but the required
maximum is 30.", e.getMessage(), "");
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
index 8116cbaf6ed7..20c0579ac17d 100644
---
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
@@ -61,6 +61,8 @@ public class CxfEndpointUtilsTest {
return new DefaultCamelContext();
}
+ @SuppressWarnings("resource")
+ // NOTE: method client must close the resource.
protected CxfEndpoint createEndpoint(String uri) throws Exception {
CamelContext context = getCamelContext();
return (CxfEndpoint) new CxfComponent(context).createEndpoint(uri);
@@ -68,9 +70,10 @@ public class CxfEndpointUtilsTest {
@Test
public void testGetProperties() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getEndpointURI());
- QName service = endpoint.getServiceNameAsQName();
- assertEquals(SERVICE_NAME, service, "We should get the right service
name");
+ try (CxfEndpoint endpoint = createEndpoint(getEndpointURI())) {
+ QName service = endpoint.getServiceNameAsQName();
+ assertEquals(SERVICE_NAME, service, "We should get the right
service name");
+ }
}
public char sepChar() {
@@ -79,42 +82,46 @@ public class CxfEndpointUtilsTest {
@Test
public void testGetDataFormatCXF() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() +
"dataFormat=CXF_MESSAGE");
- assertEquals(DataFormat.CXF_MESSAGE, endpoint.getDataFormat(), "We
should get the Message DataFormat");
+ try (CxfEndpoint endpoint = createEndpoint(getEndpointURI() +
sepChar() + "dataFormat=CXF_MESSAGE")) {
+ assertEquals(DataFormat.CXF_MESSAGE, endpoint.getDataFormat(), "We
should get the Message DataFormat");
+ }
}
@Test
public void testGetDataFormatRAW() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() +
"dataFormat=RAW");
- assertEquals(DataFormat.RAW, endpoint.getDataFormat(), "We should get
the Message DataFormat");
+ try (CxfEndpoint endpoint = createEndpoint(getEndpointURI() +
sepChar() + "dataFormat=RAW")) {
+ assertEquals(DataFormat.RAW, endpoint.getDataFormat(), "We should
get the Message DataFormat");
+ }
}
@Test
public void testCheckServiceClassWithTheEndpoint() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
- assertNull(endpoint.getServiceClass());
+ try (CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI())) {
+ assertNull(endpoint.getServiceClass());
+ }
}
@Test
public void testCheckServiceClassProcedure() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
- assertNotNull(endpoint.createProducer());
+ try (CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI())) {
+ assertNotNull(endpoint.createProducer());
+ }
}
@Test
public void testCheckServiceClassConsumer() throws Exception {
- CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI());
-
- Consumer cxfConsumer = endpoint.createConsumer(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- // noop
- }
- });
-
- Exception ex = assertThrows(IllegalArgumentException.class, () ->
cxfConsumer.start());
- assertNotNull(ex, "Should get a CamelException here");
- assertTrue(ex.getMessage().startsWith("serviceClass must be
specified"));
+ try (CxfEndpoint endpoint = createEndpoint(getNoServiceClassURI())) {
+ Consumer cxfConsumer = endpoint.createConsumer(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ // noop
+ }
+ });
+
+ Exception ex = assertThrows(IllegalArgumentException.class, () ->
cxfConsumer.start());
+ assertNotNull(ex, "Should get a CamelException here");
+ assertTrue(ex.getMessage().startsWith("serviceClass must be
specified"));
+ }
}
}