![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Android™) Execution Plan Failure Due to Circular DependenciesSee more CURL ExamplesThis example demonstrates what happens when an execution plan cannot be created due to a cycle in the dependency graph. The target This creates a circular dependency:
Because each required value ultimately depends on itself, there is no starting point with a known or independently resolvable input. As a result, it is impossible to construct a valid execution plan. When This example highlights that dependency resolution requires an acyclic graph. Every chain of dependencies must eventually terminate in a known value. If a cycle exists, the system correctly identifies it and prevents execution. Note: This example requires Chilkat v11.5.0 or greater. For more information, see https://www.chilkatsoft.com/curl_dependency_engine.asp
// Important: Don't forget to include the call to System.loadLibrary // as shown at the bottom of this code sample. package com.test; import android.app.Activity; import com.chilkatsoft.*; import android.widget.TextView; import android.os.Bundle; public class SimpleActivity extends Activity { private static final String TAG = "Chilkat"; // Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean success = false; CkHttpCurl httpCurl = new CkHttpCurl(); // This example uses fake URLs and fake variables to demonstrate a dependency cycle. // No requests are sent because we only call ExaminePlan. // The target curl command requires {{report_id}}. String targetCurl = "curl -X GET https://api.example.com/reports/{{report_id}}"; // getReportId can produce report_id, but it requires user_id. String fnName = "getReportId"; httpCurl.AddFunction(fnName,"curl -X GET https://api.example.com/report-id?user={{user_id}}"); httpCurl.AddOutput(fnName,"report.id","report_id"); // getUserId can produce user_id, but it requires account_id. fnName = "getUserId"; httpCurl.AddFunction(fnName,"curl -X GET https://api.example.com/user-id?account={{account_id}}"); httpCurl.AddOutput(fnName,"user.id","user_id"); // getAccountId can produce account_id, but it requires report_id. // This creates a cycle: // // report_id -> user_id -> account_id -> report_id // // In other words: // - targetCurl needs report_id // - report_id requires user_id // - user_id requires account_id // - account_id requires report_id // // There is no starting point where the dependency chain can be resolved. fnName = "getAccountId"; httpCurl.AddFunction(fnName,"curl -X GET https://api.example.com/account-id?report={{report_id}}"); httpCurl.AddOutput(fnName,"account.id","account_id"); // Examine the execution plan without sending any requests. // The plan cannot be created because the dependencies contain a cycle. CkJsonObject planJson = new CkJsonObject(); planJson.put_EmitCompact(false); success = httpCurl.ExaminePlan(targetCurl,planJson); // Success is expected to be false. Log.i(TAG, "success = " + String.valueOf(success)); Log.i(TAG, planJson.emit()); // Expected result: // // { // "errors": [{ // "variable": "report_id", // "msg": "Cycle detected" // },{ // "variable": "account_id", // "msg": "Unable to resolve" // },{ // "variable": "user_id", // "msg": "Unable to resolve" // },{ // "variable": "report_id", // "msg": "Unable to resolve" // }] // } static { System.loadLibrary("chilkat"); // Note: If the incorrect library name is passed to System.loadLibrary, // then you will see the following error message at application startup: //"The application <your-application-name> has stopped unexpectedly. Please try again." } } |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.