Skip to content
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

(chores) camel-core: more cleanups #13917

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class TokenizerExpressionReifier extends SingleInputTypedExpressionReifier<TokenizerExpression> {

public TokenizerExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) {
super(camelContext, (TokenizerExpression) definition);
super(camelContext, definition);
}

protected Object[] createProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class XMLTokenizerExpressionReifier extends SingleInputTypedExpressionReifier<XMLTokenizerExpression> {

public XMLTokenizerExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) {
super(camelContext, (XMLTokenizerExpression) definition);
super(camelContext, definition);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class XPathExpressionReifier extends SingleInputTypedExpressionReifier<XPathExpression> {

public XPathExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) {
super(camelContext, (XPathExpression) definition);
super(camelContext, definition);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class XQueryExpressionReifier extends SingleInputTypedExpressionReifier<XQueryExpression> {

public XQueryExpressionReifier(CamelContext camelContext, ExpressionDefinition definition) {
super(camelContext, (XQueryExpression) definition);
super(camelContext, definition);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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('\'', '"');
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,11 @@ private static Iterable<String> 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<String>) () -> 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<String>) () -> StringHelper.splitOnCharacterAsIterator(s, DEFAULT_DELIMITER_CHAR,
return () -> StringHelper.splitOnCharacterAsIterator(s, DEFAULT_DELIMITER_CHAR,
count);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<SAXParseException> emptyList(),
Collections.<SAXParseException> emptyList());
exchange, schema, Collections.singletonList(e), Collections.emptyList(),
Collections.emptyList());
}
}
} finally {
Expand Down
Loading