Skip to content
Open
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 @@ -97,6 +97,63 @@ public Set<String> getMethods() {
return methods;
}

/**
* Check if an artifact is an actual connector or just a dependency.
*
* @param artifactName The name of the artifact
* @return true if it's an actual connector, false if it's a dependency
*/
private boolean isActualConnector(String artifactName) {
if (log.isDebugEnabled()) {
log.debug("Checking if artifact is an actual connector: " + artifactName);
}
// Actual connectors typically start with "mi-connector-" or "mi-inbound-"
artifactName.startsWith("mi-inbound-") ||
artifactName.startsWith("org.wso2.carbon.connector")) {
return true;
}

// Common dependency patterns to exclude
String[] dependencyPatterns = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this is not the best way to identify the connector dependencies. This is not future-proof and we have to keep on updating this list.

"kafka-schema-registry-client",
"kafka-avro-serializer",
"kafka-clients",
"kafka-schema-serializer",
"avro-",
"jedis-",
"scala-library",
"common-config",
"jackson-",
"netty-",
"slf4j-",
"log4j-",
"commons-",
"guava-",
"protobuf-",
"bson-",
"mongo-java-driver"
};

// Check if artifact name matches any dependency pattern
for (String pattern : dependencyPatterns) {
if (artifactName.startsWith(pattern)) {
return false;
}
}

// If artifact name contains "-connector" or ends with ".connector", it's likely a connector
if (artifactName.contains("-connector") || artifactName.endsWith(".connector")) {
return true;
}

// Default: if it has version numbers (e.g., "library-1.2.3"), treat as dependency
if (artifactName.matches(".*-\\d+\\.\\d+.*")) {
return false;
}

return true;
}

@Override
public boolean invoke(MessageContext messageContext) {

Expand Down Expand Up @@ -446,6 +503,14 @@ private JSONObject convertCarbonAppToJsonObject(CarbonApplication carbonApp) {
continue;
}

// Filter out dependency JARs for synapse/lib type
if ("lib".equals(type) && !isActualConnector(artifactName)) {
if (log.isDebugEnabled()) {
log.debug("Filtering out dependency artifact: " + artifactName);
}
continue;
Comment on lines +506 to +511
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 2

Suggested change
// Filter out dependency JARs for synapse/lib type
if ("lib".equals(type) && !isActualConnector(artifactName)) {
if (log.isDebugEnabled()) {
log.debug("Filtering out dependency artifact: " + artifactName);
}
continue;
// Filter out dependency JARs for synapse/lib type
if ("lib".equals(type) && !isActualConnector(artifactName)) {
if (log.isDebugEnabled()) {
log.debug("Filtering out dependency artifact: " + artifactName);
}
log.info("Excluded dependency artifact from response: " + artifactName);
continue;

}

JSONObject artifactObject = new JSONObject();

artifactObject.put(Constants.NAME, artifactName);
Expand All @@ -460,4 +525,4 @@ private void sendFaultResponse(org.apache.axis2.context.MessageContext axis2Mess
axis2MessageContext.setProperty(Constants.NO_ENTITY_BODY, true);
axis2MessageContext.setProperty(SynapseConstants.HTTP_SC, 500);
}
}
}