diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/TokenizerExpressionReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/TokenizerExpressionReifier.java index e8171f4220ccd..e25056e1bc2fa 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/TokenizerExpressionReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/TokenizerExpressionReifier.java @@ -23,7 +23,7 @@ public class TokenizerExpressionReifier extends SingleInputTypedExpressionReifier { public TokenizerExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) { - super(camelContext, (TokenizerExpression) definition); + super(camelContext, definition); } protected Object[] createProperties() { diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java index 8c33ac4390772..8de85bfb6ffe9 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java @@ -26,7 +26,7 @@ public class XMLTokenizerExpressionReifier extends SingleInputTypedExpressionReifier { public XMLTokenizerExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) { - super(camelContext, (XMLTokenizerExpression) definition); + super(camelContext, definition); } @Override diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java index f3e56a1507797..6507fdca67e83 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java @@ -31,7 +31,7 @@ public class XPathExpressionReifier extends SingleInputTypedExpressionReifier { public XPathExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) { - super(camelContext, (XPathExpression) definition); + super(camelContext, definition); } @Override diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java index cc13d1248ed55..5f9554f526fab 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java @@ -27,7 +27,7 @@ public class XQueryExpressionReifier extends SingleInputTypedExpressionReifier { public XQueryExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) { - super(camelContext, (XQueryExpression) definition); + super(camelContext, definition); } @Override diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanNoTypeConvertionPossibleWhenHeaderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanNoTypeConvertionPossibleWhenHeaderTest.java index 33fc0b995785f..4908f98d4dc6a 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanNoTypeConvertionPossibleWhenHeaderTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanNoTypeConvertionPossibleWhenHeaderTest.java @@ -75,7 +75,7 @@ public void testBeanHeaderNoTypeConvertionPossibleOKNullHeader() throws Exceptio mock.expectedBodiesReceived("Hello World"); mock.message(0).header("foo").isNull(); - template.requestBodyAndHeader("direct:start", "Hello World", "foo", (Object) null); + template.requestBodyAndHeader("direct:start", "Hello World", "foo", null); assertMockEndpointsSatisfied(); } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java index 6fc97636c2781..83db991c6168b 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java @@ -86,7 +86,7 @@ public boolean moveExistingFile(GenericFileEndpoint endpoint, GenericFileOper String to = endpoint.getMoveExisting().evaluate(dummy, String.class); counter++; String fileNameWithoutExtension = to.substring(0, to.lastIndexOf('.')) + counter; - to = fileNameWithoutExtension + to.substring(to.lastIndexOf('.'), to.length()); + to = fileNameWithoutExtension + to.substring(to.lastIndexOf('.')); // we must normalize it (to avoid having both \ and / in the name // which confuses java.io.File) to = FileUtil.normalizePath(to); diff --git a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterNaNTest.java b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterNaNTest.java index 2520225787855..5b8dd6123ff0f 100644 --- a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterNaNTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterNaNTest.java @@ -88,14 +88,14 @@ public void testFloatToByteWithNaN() { @Test public void testDoubleToFloatWithNaN() { assertEquals(Float.valueOf("4"), context.getTypeConverter().convertTo(Float.class, Double.valueOf("4"))); - assertEquals((Object) (Float) Float.NaN, context.getTypeConverter().convertTo(Float.class, Double.NaN)); + assertEquals((Object) Float.NaN, context.getTypeConverter().convertTo(Float.class, Double.NaN)); assertEquals(Float.valueOf("3"), context.getTypeConverter().convertTo(Float.class, Double.valueOf("3"))); } @Test public void testFloatToDoubleWithNaN() { assertEquals(Double.valueOf("4"), context.getTypeConverter().convertTo(Double.class, Float.valueOf("4"))); - assertEquals((Object) (Double) Double.NaN, context.getTypeConverter().convertTo(Double.class, Float.NaN)); + assertEquals((Object) Double.NaN, context.getTypeConverter().convertTo(Double.class, Float.NaN)); assertEquals(Double.valueOf("3"), context.getTypeConverter().convertTo(Double.class, Float.valueOf("3"))); } } diff --git a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java index c96686db8bab4..7d76d07a217e0 100644 --- a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java @@ -152,8 +152,8 @@ public void testToBigInteger() { public void testToString() { assertEquals("ABC", ObjectConverter.toString(new StringBuffer("ABC"))); assertEquals("ABC", ObjectConverter.toString(new StringBuilder("ABC"))); - assertEquals("", ObjectConverter.toString(new StringBuffer(""))); - assertEquals("", ObjectConverter.toString(new StringBuilder(""))); + assertEquals("", ObjectConverter.toString(new StringBuffer())); + assertEquals("", ObjectConverter.toString(new StringBuilder())); } @Test diff --git a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StAX2SAXSourceTest.java b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StAX2SAXSourceTest.java index c9168ea506a06..04ccb702e645f 100644 --- a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StAX2SAXSourceTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StAX2SAXSourceTest.java @@ -62,7 +62,7 @@ public void testDefaultPrefixInRootElementWithCopyTransformer() throws Exception transformer.transform(staxSource, new StreamResult(baos)); writer.flush(); baos.flush(); - MatcherAssert.assertThat(new String(baos.toByteArray()), equalTo(TEST_XML)); + MatcherAssert.assertThat(baos.toString(), equalTo(TEST_XML)); } } diff --git a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java index 573b76c4bed49..852bcbfd2dac4 100644 --- a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java @@ -110,7 +110,7 @@ public void testEncodingXmlEventReader() throws Exception { } assertNotNull(output); - String result = new String(output.toByteArray(), UTF_8); + String result = output.toString(UTF_8); // normalize the auotation mark if (result.indexOf('\'') > 0) { result = result.replace('\'', '"'); @@ -169,7 +169,7 @@ public void testEncodingXmlStreamReader() throws Exception { } assertNotNull(output); - String result = new String(output.toByteArray(), UTF_8); + String result = output.toString(UTF_8); assertEquals(TEST_XML, result); } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java index d91830331cfd3..9963b3c87df36 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java @@ -155,7 +155,7 @@ public void process(Exchange exchange) { Message out = result.getMessage(); assertMessageHeader(out, "foo", "bar"); - assertEquals((Object) (Integer) 5, result.getProperty("aggregated", Integer.class)); + assertEquals((Object) 5, result.getProperty("aggregated", Integer.class)); } @Test @@ -176,7 +176,7 @@ public void process(Exchange exchange) { Message out = result.getMessage(); assertMessageHeader(out, "foo", "bar"); - assertEquals((Object) (Integer) 5, result.getProperty("aggregated", Integer.class)); + assertEquals((Object) 5, result.getProperty("aggregated", Integer.class)); } @Test diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/WireTapOnExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapOnExceptionTest.java index f308719715b87..7a868c40682c0 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/WireTapOnExceptionTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapOnExceptionTest.java @@ -17,7 +17,6 @@ package org.apache.camel.processor; import org.apache.camel.CamelContext; -import org.apache.camel.Component; import org.apache.camel.Consumer; import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; @@ -60,7 +59,7 @@ public void configure() throws Exception { public static final class MyProducerFailEndpoint extends DefaultEndpoint { private MyProducerFailEndpoint(String endpointUri, CamelContext camelContext) { - super(endpointUri, (Component) null); + super(endpointUri, null); setCamelContext(camelContext); } diff --git a/core/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java b/core/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java index 2e73b7b7c86ba..e3616372254cf 100644 --- a/core/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java @@ -103,7 +103,7 @@ public void testDefaultTimeoutMapGetRemove() { Object old = map.remove("A"); assertEquals(123, old); - assertNull((Object) map.get("A")); + assertNull(map.get("A")); assertEquals(0, map.size()); map.stop(); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java index 60fe181a8e347..d8e9826c1b89d 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java @@ -893,11 +893,11 @@ private static Iterable createDelimitedStringIterator(String s) { // -> bean=foo?method=killer(a,b) // -> bean=bar?method=great(a,b) // http://stackoverflow.com/questions/1516090/splitting-a-title-into-separate-parts - return (Iterable) () -> new Scanner(s, PARENTHESIS_PATTERN); + return () -> new Scanner(s, PARENTHESIS_PATTERN); } else { // optimized split string on default delimiter int count = StringHelper.countChar(s, DEFAULT_DELIMITER_CHAR) + 1; - return (Iterable) () -> StringHelper.splitOnCharacterAsIterator(s, DEFAULT_DELIMITER_CHAR, + return () -> StringHelper.splitOnCharacterAsIterator(s, DEFAULT_DELIMITER_CHAR, count); } } diff --git a/core/camel-util/src/test/java/org/apache/camel/util/SkipLastNewlineInputStreamTest.java b/core/camel-util/src/test/java/org/apache/camel/util/SkipLastNewlineInputStreamTest.java index 94e3f1a306bb1..9cda6a2e09f8c 100644 --- a/core/camel-util/src/test/java/org/apache/camel/util/SkipLastNewlineInputStreamTest.java +++ b/core/camel-util/src/test/java/org/apache/camel/util/SkipLastNewlineInputStreamTest.java @@ -53,7 +53,7 @@ private void assertRead(String input, String expected) throws IOException { while ((c = in.read()) >= 0) { out.write(c); } - Assertions.assertEquals(expected, new String(out.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(expected, out.toString(StandardCharsets.UTF_8)); } try (InputStream in @@ -64,7 +64,7 @@ private void assertRead(String input, String expected) throws IOException { while ((len = in.read(buf)) >= 0) { out.write(buf, 0, len); } - Assertions.assertEquals(expected, new String(out.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(expected, out.toString(StandardCharsets.UTF_8)); } } diff --git a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ParserTest.java b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ParserTest.java index a04990748af24..00ded5053c1b9 100644 --- a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ParserTest.java +++ b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ParserTest.java @@ -76,7 +76,7 @@ public void justParse() throws XmlPullParserException, IOException { assertEquals("value-1", xpp.getAttributeValue(null, "a")); assertEquals("value-2", xpp.getAttributeValue("uri:b", "a")); // check with non-interned String - assertEquals("value-2", xpp.getAttributeValue(new String("uri:b"), "a")); + assertEquals("value-2", xpp.getAttributeValue("uri:b", "a")); } } case MXParser.END_TAG -> { diff --git a/core/camel-xml-jaxp/src/main/java/org/apache/camel/support/processor/validation/ValidatingProcessor.java b/core/camel-xml-jaxp/src/main/java/org/apache/camel/support/processor/validation/ValidatingProcessor.java index 042342a3ae707..fcf23af454883 100644 --- a/core/camel-xml-jaxp/src/main/java/org/apache/camel/support/processor/validation/ValidatingProcessor.java +++ b/core/camel-xml-jaxp/src/main/java/org/apache/camel/support/processor/validation/ValidatingProcessor.java @@ -166,8 +166,8 @@ protected void doProcess(Exchange exchange) throws Exception { } catch (SAXParseException e) { // can be thrown for non-well-formed XML throw new SchemaValidationException( - exchange, schema, Collections.singletonList(e), Collections. emptyList(), - Collections. emptyList()); + exchange, schema, Collections.singletonList(e), Collections.emptyList(), + Collections.emptyList()); } } } finally {