本文介绍了在karate-config.js中配置代理获取解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于测试的代理设置,例如

I have proxy settings for our testing, e.g.,

function() {                                                                                                                                                                                                                                            

    var config = { // base config JSON                                                                                                                                                                                                                  
        sslConfig: true,                                                                                                                                                                                                                                
        apiUrl: 'https://my-api.com',                                                                                                                                                                                                                   
        api2Url: 'https://my-api2.com',                                                                                                                                                                                                                 
        proxy:                                                                                                                                                                                                                                          
        {                                                                                                                                                                                                                                               
            uri: 'http://my-proxy.com:3128',
            nonProxyHosts:                                                                                                                                                                                                                              
            [                                                                                                                                                                                                                                           
                'my-api2.com',                                                                                                                                                                                                                          
            ]                                                                                                                                                                                                             
        }                                                                                                                                                                                                                                               
    };                                                                                                                                                                                                                                                  

    karate.configure('connectTimeout', 10001);                                                                                                                                                                                                          
    karate.configure('readTimeout', 10000);                                                                                                                                                                                                             
    karate.configure('proxy', config.proxy);                                                                                                                                                                                                            
    return config;                                                                                                                                                                                                                                      
}

它在0.9.2中正常工作,升级到0.9.3后,我得到下面的解析错误消息,并在那里挂起进程

And it works fine in 0.9.2, after upgrade to 0.9.3, I get parsing error message below and process hanging there

    13:47:45.639 | [ForkJoinPool-1-worker-1] | ERROR 

    failed function body: function() {

          var config = { // base config JSON
              sslConfig: true,
              apiUrl: 'https://my-api.com',
              api2Url: 'https://my-api2.com',
              proxy:
              {
                  uri: 'http://my-proxy.com:3128',
                  nonProxyHosts:
                  [
                      'my-api2.com',
                  ]
              }
          };

          karate.configure('connectTimeout', 10001);
          karate.configure('readTimeout', 10000);
          karate.configure('proxy', config.proxy);
          return config;
      }

    13:47:45.646 | [ForkJoinPool-1-worker-1] | ERROR 

    evaluation of 'karate-config.js' failed: javascript function call failed: net.minidev.json.JSONArray cannot be cast to jdk.nashorn.api.scripting.ScriptObjectMirror

我尝试删除键nonProxyHosts,它再次起作用.谁能建议这个问题的解决方案?

And I try to remove the key nonProxyHosts, it works again. Can anyone suggest the solution for this issue?

推荐答案

是的,这是0.9.3中引入的错误-我们在此处打开了票证,并且已将其修复(在develop分支中) https://github.com/intuit/karate/issues/802

Yes, this is a bug that was introduced in 0.9.3 - we opened a ticket here and it is fixed (in the develop branch) https://github.com/intuit/karate/issues/802

如果您可以从源代码构建并确认它适用于您,我们可以加快发布补丁程序的版本.

If you can build this from source and confirm that it works for you, we can expedite releasing a patch version.

这篇关于在karate-config.js中配置代理获取解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:03