Skip to content
Open
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 @@ -90,10 +90,10 @@ private void startIngestionJob(BedrockAgentClient bedrockAgentClient, Exchange e
throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof StartIngestionJobRequest) {
if (payload instanceof StartIngestionJobRequest startIngestionJobRequest) {
StartIngestionJobResponse result;
try {
result = bedrockAgentClient.startIngestionJob((StartIngestionJobRequest) payload);
result = bedrockAgentClient.startIngestionJob(startIngestionJobRequest);
} catch (AwsServiceException ase) {
LOG.trace("Start Ingestion Job command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down Expand Up @@ -135,10 +135,10 @@ private void listIngestionJobs(BedrockAgentClient bedrockAgentClient, Exchange e
throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof ListIngestionJobsRequest) {
if (payload instanceof ListIngestionJobsRequest listIngestionJobsRequest) {
ListIngestionJobsResponse result;
try {
result = bedrockAgentClient.listIngestionJobs((ListIngestionJobsRequest) payload);
result = bedrockAgentClient.listIngestionJobs(listIngestionJobsRequest);
} catch (AwsServiceException ase) {
LOG.trace("Start Ingestion Job command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down Expand Up @@ -180,10 +180,10 @@ private void getIngestionJob(BedrockAgentClient bedrockAgentClient, Exchange exc
throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof GetIngestionJobRequest) {
if (payload instanceof GetIngestionJobRequest getIngestionJobRequest) {
GetIngestionJobResponse result;
try {
result = bedrockAgentClient.getIngestionJob((GetIngestionJobRequest) payload);
result = bedrockAgentClient.getIngestionJob(getIngestionJobRequest);
} catch (AwsServiceException ase) {
LOG.trace("Get Ingestion Job command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ private void retrieveAndGenerate(BedrockAgentRuntimeClient bedrockAgentRuntimeCl
throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof RetrieveAndGenerateRequest) {
if (payload instanceof RetrieveAndGenerateRequest retrieveAndGenerateRequest) {
RetrieveAndGenerateResponse result;
try {
result = bedrockAgentRuntimeClient.retrieveAndGenerate((RetrieveAndGenerateRequest) payload);
result = bedrockAgentRuntimeClient.retrieveAndGenerate(retrieveAndGenerateRequest);
} catch (AwsServiceException ase) {
LOG.trace("Retrieve and Generate command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public BedrockEndpoint getEndpoint() {
private void invokeTextModel(BedrockRuntimeClient bedrockRuntimeClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof InvokeModelRequest) {
if (payload instanceof InvokeModelRequest invokeModelRequest) {
InvokeModelResponse result;
try {
result = bedrockRuntimeClient.invokeModel((InvokeModelRequest) payload);
result = bedrockRuntimeClient.invokeModel(invokeModelRequest);
} catch (AwsServiceException ase) {
LOG.trace("Invoke Model command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down Expand Up @@ -166,10 +166,10 @@ private void invokeTextModel(BedrockRuntimeClient bedrockRuntimeClient, Exchange
private void invokeImageModel(BedrockRuntimeClient bedrockRuntimeClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof InvokeModelRequest) {
if (payload instanceof InvokeModelRequest invokeModelRequest) {
InvokeModelResponse result;
try {
result = bedrockRuntimeClient.invokeModel((InvokeModelRequest) payload);
result = bedrockRuntimeClient.invokeModel(invokeModelRequest);
} catch (AwsServiceException ase) {
LOG.trace("Invoke Image Model command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down Expand Up @@ -215,10 +215,10 @@ private void invokeEmbeddingsModel(BedrockRuntimeClient bedrockRuntimeClient, Ex
throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getMessage().getMandatoryBody();
if (payload instanceof InvokeModelRequest) {
if (payload instanceof InvokeModelRequest invokeModelRequest) {
InvokeModelResponse result;
try {
result = bedrockRuntimeClient.invokeModel((InvokeModelRequest) payload);
result = bedrockRuntimeClient.invokeModel(invokeModelRequest);
} catch (AwsServiceException ase) {
LOG.trace("Invoke Image Model command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ public AWSConfigEndpoint getEndpoint() {
private void putConfigRule(ConfigClient configClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof PutConfigRuleRequest) {
if (payload instanceof PutConfigRuleRequest request) {
PutConfigRuleResponse result;
try {
PutConfigRuleRequest request = (PutConfigRuleRequest) payload;
result = configClient.putConfigRule(request);
} catch (AwsServiceException ase) {
LOG.trace("Put Config rule command returned the error code {}", ase.awsErrorDetails().errorCode());
Expand Down Expand Up @@ -146,10 +145,9 @@ private void putConfigRule(ConfigClient configClient, Exchange exchange) throws
private void removeConfigRule(ConfigClient configClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof DeleteConfigRuleRequest) {
if (payload instanceof DeleteConfigRuleRequest request) {
DeleteConfigRuleResponse result;
try {
DeleteConfigRuleRequest request = (DeleteConfigRuleRequest) payload;
result = configClient.deleteConfigRule(request);
} catch (AwsServiceException ase) {
LOG.trace("Delete Config rule command returned the error code {}", ase.awsErrorDetails().errorCode());
Expand Down Expand Up @@ -182,10 +180,9 @@ private void removeConfigRule(ConfigClient configClient, Exchange exchange) thro
private void describeRuleCompliance(ConfigClient configClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof DescribeComplianceByConfigRuleRequest) {
if (payload instanceof DescribeComplianceByConfigRuleRequest request) {
DescribeComplianceByConfigRuleResponse result;
try {
DescribeComplianceByConfigRuleRequest request = (DescribeComplianceByConfigRuleRequest) payload;
result = configClient.describeComplianceByConfigRule(request);
} catch (AwsServiceException ase) {
LOG.trace("Describe Compliance by Config rule command returned the error code {}",
Expand Down Expand Up @@ -218,10 +215,9 @@ private void describeRuleCompliance(ConfigClient configClient, Exchange exchange
private void putConformancePack(ConfigClient configClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof PutConformancePackRequest) {
if (payload instanceof PutConformancePackRequest request) {
PutConformancePackResponse result;
try {
PutConformancePackRequest request = (PutConformancePackRequest) payload;
result = configClient.putConformancePack(request);
} catch (AwsServiceException ase) {
LOG.trace("Put Conformance Pack command returned the error code {}", ase.awsErrorDetails().errorCode());
Expand Down Expand Up @@ -269,10 +265,9 @@ private void putConformancePack(ConfigClient configClient, Exchange exchange) th
private void removeConformancePack(ConfigClient configClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof DeleteConformancePackRequest) {
if (payload instanceof DeleteConformancePackRequest request) {
DeleteConformancePackResponse result;
try {
DeleteConformancePackRequest request = (DeleteConformancePackRequest) payload;
result = configClient.deleteConformancePack(request);
} catch (AwsServiceException ase) {
LOG.trace("Remove Conformance Pack rule command returned the error code {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected void doStart() throws Exception {

if (getCamelContext().getPropertiesComponent().hasPropertiesFunction("aws")) {
PropertiesFunction pf = getCamelContext().getPropertiesComponent().getPropertiesFunction("aws");
if (pf instanceof SecretsManagerPropertiesFunction) {
propertiesFunction = (SecretsManagerPropertiesFunction) pf;
if (pf instanceof SecretsManagerPropertiesFunction secretsManagerPropertiesFunction) {
propertiesFunction = secretsManagerPropertiesFunction;
}
}
AwsVaultConfiguration aws = getCamelContext().getVaultConfiguration().getAwsVaultConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ protected void doStart() throws Exception {
// auto-detect secrets in-use
PropertiesComponent pc = camelContext.getPropertiesComponent();
PropertiesFunction pf = pc.getPropertiesFunction("aws");
if (pf instanceof SecretsManagerPropertiesFunction) {
propertiesFunction = (SecretsManagerPropertiesFunction) pf;
if (pf instanceof SecretsManagerPropertiesFunction secretsManagerPropertiesFunction) {
propertiesFunction = secretsManagerPropertiesFunction;
LOG.debug("Auto-detecting secrets from properties-function: {}", pf.getName());
}
// specific secrets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ private final class XRayEventNotifier extends EventNotifierSupport {
@Override
public void notify(CamelEvent event) throws Exception {

if (event instanceof ExchangeSendingEvent) {
ExchangeSendingEvent ese = (ExchangeSendingEvent) event;
if (event instanceof ExchangeSendingEvent ese) {
if (LOG.isTraceEnabled()) {
LOG.trace("-> {} - target: {} (routeId: {})",
event.getClass().getSimpleName(), ese.getEndpoint(),
Expand Down Expand Up @@ -304,19 +303,17 @@ public void notify(CamelEvent event) throws Exception {
LOG.trace("Ignoring creation of XRay subsegment as no segment exists in the current thread");
}

} else if (event instanceof ExchangeSentEvent) {
ExchangeSentEvent ese = (ExchangeSentEvent) event;
} else if (event instanceof ExchangeSentEvent ese) {
if (LOG.isTraceEnabled()) {
LOG.trace("-> {} - target: {} (routeId: {})",
event.getClass().getSimpleName(), ese.getEndpoint(), ese.getExchange().getFromRouteId());
}

Entity entity = getTraceEntityFromExchange(ese.getExchange());
if (entity instanceof Subsegment) {
if (entity instanceof Subsegment subsegment) {
AWSXRay.setTraceEntity(entity);
SegmentDecorator sd = getSegmentDecorator(ese.getEndpoint());
try {
Subsegment subsegment = (Subsegment) entity;
sd.post(subsegment, ese.getExchange(), ese.getEndpoint());
subsegment.close();
if (LOG.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public String getComponent() {
@Override
public String getOperationName(Exchange exchange, Endpoint endpoint) {
Object name = exchange.getProperty(Exchange.TIMER_NAME);
return name instanceof String ? (String) name : super.getOperationName(exchange, endpoint);
return name instanceof String stringName ? stringName : super.getOperationName(exchange, endpoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void post(Entity segment, Exchange exchange, Endpoint endpoint) {
protected String getHttpMethod(Exchange exchange, Endpoint endpoint) {
// 1. Use method provided in header.
Object method = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
if (method instanceof String) {
return (String) method;
if (method instanceof String stringMethod) {
return stringMethod;
}

// 2. GET if query string is provided in header.
Expand All @@ -80,12 +80,12 @@ protected String getHttpMethod(Exchange exchange, Endpoint endpoint) {

protected String getHttpUrl(Exchange exchange, Endpoint endpoint) {
Object url = exchange.getIn().getHeader(Exchange.HTTP_URL);
if (url instanceof String) {
return (String) url;
if (url instanceof String stringUrl) {
return stringUrl;
} else {
Object uri = exchange.getIn().getHeader(Exchange.HTTP_URI);
if (uri instanceof String) {
return (String) uri;
if (uri instanceof String stringUri) {
return stringUri;
} else {
// Try to obtain from endpoint
int index = endpoint.getEndpointUri().lastIndexOf("http:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ private List<MetricDatum> getMetricData(Exchange exchange) {
return CastUtils.cast((List<?>) body);
}

if (body instanceof MetricDatum) {
return Arrays.asList((MetricDatum) body);
if (body instanceof MetricDatum metricDatum) {
return Arrays.asList(metricDatum);
}

MetricDatum.Builder metricDatum = MetricDatum.builder().metricName(determineName(exchange))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ private static AttributeValue getAttributeValue(Object value) {
return AttributeValue.builder().n(value.toString()).build();
}

if (value instanceof Boolean) {
return AttributeValue.builder().bool((Boolean) value).build();
if (value instanceof Boolean booleanValue) {
return AttributeValue.builder().bool(booleanValue).build();
}

if (value instanceof String[]) {
return AttributeValue.builder().ss((String[]) value).build();
if (value instanceof String[] stringArray) {
return AttributeValue.builder().ss(stringArray).build();
}

if (value instanceof int[]) {
return AttributeValue.builder().ns(Stream.of((int[]) value).map(Object::toString).collect(Collectors.toList()))
if (value instanceof int[] intArray) {
return AttributeValue.builder().ns(Stream.of(intArray).map(Object::toString).collect(Collectors.toList()))
.build();
}

Expand Down
Loading
Loading