spring cloud contract - Wiremock Bad <init> method call from inside of a branch Exception Details - spring-cloud-contract

I have a producer which is:
springboot - 1.5.1.RELEASE
springcloudVersion = 'Camden.SR5'
Has classpath ("org.springframework.cloud:spring-cloud-contract-gradle-plugin:1.0.3.RELEASE")
testCompile('org.springframework.cloud:spring-cloud-starter-contract-verifier')
I can successfully run the build on producer and can see the generated contracts.
Now,
I have a consumer which is
springBootVersion = '2.0.1.RELEASE'
springCloudVersion = 'Finchley.RC1'
Has
testCompile("org.springframework.cloud:spring-cloud-starter-contract-stub-runner")
testCompile("org.springframework.cloud:spring-cloud-contract-verifier")
I have a simple contract test like this:
#Rule
public StubRunnerRule rule = new StubRunnerRule()
.downloadStub("groupid", "artifact")
.stubsMode(StubRunnerProperties.StubsMode.LOCAL);
#Test
public void testValidALPEndpoint() {
String output = runEndpointCheck("ac01");
assertEquals("test", output); }
#Test
public void testInvalidALPEndpoint() {
String output = runEndpointCheck("invalid");
assertNotEquals("invalid", output);
}
private String runEndpointCheck(String urlPath) {
URL url = this.rule.findStubUrl("groupid", "artifact"");
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet(url + "/" + urlPath);
CloseableHttpResponse response = httpclient.execute(httpGet);
return EntityUtils.toString(response.getEntity());
} catch (IOException e) {
throw new RuntimeException("HTTP client failed to open", e);
}
}
It is able to locate the stub jar from local m2 repo.
But then it error out with
org/springframework/cloud/contract/verifier/dsl/wiremock/DefaultResponseTransformer.<init>(ZLjava/lang/String;Lwiremock/com/github/jknack/handlebars/Helper;)V #108: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: b800 133a 0406 bd00 4059 031b b800 4653
0x0000010: 5904 2c53 5905 2d53 5910 ff12 04b8 004a
0x0000020: 2a5f ab00 0000 00a4 0000 0004 9db7 bd78
0x0000030: 0000 002a 0013 85ff 0000 0050 15b4 0b91
0x0000040: 0000 0060 286f b7a6 0000 0088 5f5a 5903
0x0000050: 32b8 0050 5f59 0432 b800 56c0 0058 5f59
0x0000060: 0532 125a b800 28c0 005a 5f57 b700 5ca7
0x0000070: 0061 5f5a 5903 32b8 0050 5f57 b700 3ca7
0x0000080: 0051 5f5a 5903 32b8 0050 5f59 0432 125e
0x0000090: b800 28c0 005e 5f59 0532 1222 b800 28c0
0x00000a0: 0022 5f57 b700 61a7 0029 5f5a 5903 32b8
0x00000b0: 0050 5f59 0432 1222 b800 28c0 0022 5f57
0x00000c0: b700 2ba7 000d bb00 6359 1265 b700 68bf
0x00000d0: 572a b600 333a 0519 052a 5fb5 0035 1905
0x00000e0: 57b1
Stackmap Table:
full_frame(#76,{UninitializedThis,Integer,Object[#88],Object[#90],Object[#57]},{Object[#110],UninitializedThis})
full_frame(#114,{UninitializedThis,Integer,Object[#88],Object[#90],Object[#57]},{Object[#110],UninitializedThis})
full_frame(#130,{UninitializedThis,Integer,Object[#88],Object[#90],Object[#57]},{Object[#110],UninitializedThis})
full_frame(#170,{UninitializedThis,Integer,Object[#88],Object[#90],Object[#57]},{Object[#110],UninitializedThis})
full_frame(#198,{UninitializedThis,Integer,Object[#88],Object[#90],Object[#57]},{Object[#110],UninitializedThis})
full_frame(#208,{Object[#2],Integer,Object[#88],Object[#90],Object[#57]},{Object[#110]})
at org.springframework.cloud.contract.stubrunner.provider.wiremock.WireMockHttpServerStub.responseTransformers(WireMockHttpServerStub.java:65)
at org.springframework.cloud.contract.stubrunner.provider.wiremock.WireMockHttpServerStub.config(WireMockHttpServerStub.java:51)
at org.springframework.cloud.contract.stubrunner.provider.wiremock.WireMockHttpServerStub.start(WireMockHttpServerStub.java:107)
at org.springframework.cloud.contract.stubrunner.StubServer.start(StubServer.java:51)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor$1.call(StubRunnerExecutor.java:260)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor$1.call(StubRunnerExecutor.java:256)
at org.springframework.cloud.contract.stubrunner.AvailablePortScanner.executeLogicForAvailablePort(AvailablePortScanner.java:79)
at org.springframework.cloud.contract.stubrunner.AvailablePortScanner.tryToExecuteWithFreePort(AvailablePortScanner.java:63)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.startStubServers(StubRunnerExecutor.java:256)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.runStubs(StubRunnerExecutor.java:76)
at org.springframework.cloud.contract.stubrunner.StubRunner.runStubs(StubRunner.java:72)
at org.springframework.cloud.contract.stubrunner.BatchStubRunner.runStubs(BatchStubRunner.java:46)
at org.springframework.cloud.contract.stubrunner.junit.StubRunnerRule$1.before(StubRunnerRule.java:69)
at org.springframework.cloud.contract.stubrunner.junit.StubRunnerRule$1.evaluate(StubRunnerRule.java:62)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

You're using an ancient release train. Also most likely you have a mismatch of dependencies. Most likely there's a problem with WireMock versions. It would be best if you upgraded the release train versions and check again.

I suppose its a JAVA version issue. Had to add jvmargs -noverify to bootrun and tests for supressing it.
Works ok now.
Will keep looking for the compatible JDK version to fix this issue without involving -noverify

Related

OSSEC adding allowed fields from decoders to rules description

I am using OSSEC for HIDS.
I have created a custom decoder and extracted fields from the log like srcip, dstip and protocol.
Here is the log tested with the ./ossec-logtest
Sep 2 14:39:23 rana-HP-Notebook kernel: [21261.042146] [UFW BLOCK] IN=wlp19s0 OUT= MAC=cc:b0:da:66:20:c3:00:23:15:d4:dd:70:08:00 SRC=192.153.41.125 DST=192.153.41.12 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=28858 PROTO=TCP SPT=2662 DPT=0 WINDOW=512 RES=0x00 URGP=0
Decoder written for the log is:
<decoder name="iptables-blockedip">
<parent>iptables</parent>
<prematch offset="after_parent">^\S+ [UFW BLOCK] IN=\S+ OUT= MAC=\S+ </prematch>
<regex offset="after_prematch">^SRC=(\S+) DST=(\S+) LEN=\S+ TOS=\S+ PREC=\S+ TTL=\S+ ID=\S+ PROTO=(\S+) SPT=(\S+) DPT=(\S+) WINDOW=\S+ RES=\S+ URGP=\S+$</regex>
<order>srcip,dstip,protocol,srcport,dstport</order>
</decoder>
The rule for it is:
<rule id="100002" level="8">
<decoded_as>iptables</decoded_as>
<description>An ip was blocked by the firewall</description>
</rule>
This is the result of the ossec-logtest
**Phase 1: Completed pre-decoding.
full event: 'Sep 2 14:39:23 rana-HP-Notebook kernel: [21261.042146] [UFW BLOCK] IN=wlp19s0 OUT= MAC=cc:b0:da:66:20:c3:00:23:15:d4:dd:70:08:00 SRC=192.153.41.125 DST=192.153.41.12 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=28858 PROTO=TCP SPT=2662 DPT=0 WINDOW=512 RES=0x00 URGP=0'
hostname: 'rana-HP-Notebook'
program_name: 'kernel'
log: '[21261.042146] [UFW BLOCK] IN=wlp19s0 OUT= MAC=cc:b0:da:66:20:c3:00:23:15:d4:dd:70:08:00 SRC=192.153.41.125 DST=192.153.41.12 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=28858 PROTO=TCP SPT=2662 DPT=0 WINDOW=512 RES=0x00 URGP=0'
**Phase 2: Completed decoding.
decoder: 'iptables'
srcip: '192.153.41.125'
dstip: '192.153.41.12'
proto: 'TCP'
srcport: '2662'
dstport: '0'
**Phase 3: Completed filtering (rules).
Rule id: '100002'
Level: '8'
Description: 'An ip was blocked by the firewall'
Now main question is that:
is it possible to add the srcip from the decoder to the rule description so that it will be shown in the description when the alert was raised.
My expected result for the phase3 of the ossec-logtest is :
**Phase 3: Completed filtering (rules).
Rule id: '100002'
Level: '8'
Description: 'An ip 192.153.41.125 was blocked by the firewall'
You can use the following syntax in the description: $(field_name).
Your rule would look like this:
<rule id="100002" level="8">
<decoded_as>iptables</decoded_as>
<description>An ip $(srcip) was blocked by the firewall</description>
</rule>
You have more information on this in the Wazuh documentation: https://documentation.wazuh.com/3.13/user-manual/ruleset/ruleset-xml-syntax/rules.html#description

Spring Integration tcp reply MessageTimeoutException

I'm using spring integration to interface with a company that listens for a tcp connection.
I use a TcpOutboundGateway to send the message and put the ack on the reply channel.
This works pretty well.
However, I periodically and sometimes consistently get the MessageTimeoutException while waiting for my 3rd party to send the Ack. In their logs they complain that the socket connection was closed before they could send the ack. It seems to occur very quickly even though I've tried to specify they have up to 10 seconds to send the ack.
I've set the remotetimeout, requesttimeout, sendtimeout, soTimeout, but it seems like nothing much is helping to reduce the occurance.
I'm trying to run multiple of these gateways, don't think that's a problem.
I don't know enough to know what I should be looking for.
I believe this is the relevant bit of code:
#Bean
public TcpNetClientConnectionFactory createTcpClientConnectionFactory() {
TcpNetClientConnectionFactory tcpNetClientConnectionFactory = new TcpNetClientConnectionFactory(host, port);
LisSerializer lisSerializer = new LisSerializer(maxMessageSize);
tcpNetClientConnectionFactory.setSerializer(lisSerializer);
tcpNetClientConnectionFactory.setDeserializer(lisSerializer);
tcpNetClientConnectionFactory.setSingleUse(true);
tcpNetClientConnectionFactory.setSoTimeout(tcpTimeout);
return tcpNetClientConnectionFactory;
}
#Bean
#ServiceActivator(inputChannel="tcpToLisEncoded")
public TcpOutboundGateway createTcpOutboundGateway(TcpNetClientConnectionFactory createTcpClientConnectionFactory){
TcpOutboundGateway tcpOutboundGateway = new TcpOutboundGateway();
tcpOutboundGateway.setConnectionFactory(createTcpClientConnectionFactory);
tcpOutboundGateway.setReplyChannel(tcpOutAck());
tcpOutboundGateway.setRemoteTimeout(tcpTimeout);
tcpOutboundGateway.setRequestTimeout(tcpTimeout);
tcpOutboundGateway.setSendTimeout(tcpTimeout);
tcpOutboundGateway.setRequiresReply(true);
return tcpOutboundGateway;
}
Error I get:
018-02-22 22:56:44.969 ERROR 29 --- [SimpleAsyncTaskExecutor-1] o.s.i.ip.tcp.TcpOutboundGateway : Tcp Gateway exception
org.springframework.integration.MessageTimeoutException: Timed out waiting for response
at org.springframework.integration.ip.tcp.TcpOutboundGateway.handleRequestMessage(TcpOutboundGateway.java:146) ~[spring-integration-ip-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:360) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:271) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:188) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:150) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:45) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:42) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:38) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:79) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:70) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:449) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:422) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:478) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:433) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:424) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayCompletableFutureProxyFactoryBean.invoke(GatewayCompletableFutureProxyFactoryBean.java:65) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) [spring-aop-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at com.sun.proxy.$Proxy120.sendMessage(Unknown Source) [na:na]

Robolectric 2.3 & android annotation

After mulitple problems in order to use robolectric with android studio, i get an error to create an activity.
So i use the following code
#Before
public void setUp() throws Exception {
mapActivity = Robolectric.buildActivity(MapActivity_.class).create().visible().get();
}
I've decided to build annotated activity but i fall on this problem (same problem if i build "normal" activity)
WARNING: No manifest file found at /path/to/AndroidManifest.xml.Falling back to the Android OS resources only.
To remove this warning, annotate your test class with #Config(manifest=Config.NONE).
WARNING: no system properties value for ro.build.date.utc
org.fest.reflect.exception.ReflectionError: Unable to create a new object from the enclosed constructor
at org.fest.reflect.constructor.Invoker.newInstance(Invoker.java:82)
at org.robolectric.util.ActivityController.<init>(ActivityController.java:41)
at org.robolectric.Robolectric.buildActivity(Robolectric.java:1376)
at com.ecab.MapActivityTest.setUp(MapActivityTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 30
Exception Details:
Location:
com/google/android/gms/location/LocationRequest.setExpirationTime(J)Lcom/google/android/gms/location/LocationRequest; #7: ifeq
Reason:
Expected stackmap frame at this location.
Bytecode:
0000000: 2ab4 010c c100 0299 0017 2ab4 010c c000
Do you know how can i solve this ?
Thx

Meteor.http.post sets lowercase 'host' header. How do I override this?

I need to talk to a finicky web server that crashes when I execute this code:
payload = JSON.stringify({
jsonrpc: '2.0',
method: 'sendMessage',
id: 1,
params: {
accountID: 0,
messageText: message,
countDownTime: 0,
interval: 0
}
});
result = Meteor.http.post(api_endpoint, { content: payload });
After some debugging I've narrowed it down to the host header. A tcpdump of my request shows that meteor is sending it in lowercase:
0x0000: 4500 00dd f959 4000 4006 162b 0a01 0b58 E....Y#.#..+...X
0x0010: 0a01 0b3d d6a5 1388 ae92 8657 3d7b 996e ...=.......W={.n
0x0020: 8018 01c9 2b66 0000 0101 080a 183e 7f02 ....+f.......>..
0x0030: 34da 9ad8 504f 5354 202f 2048 5454 502f 4...POST./.HTTP/
0x0040: 312e 310d 0a43 6f6e 7465 6e74 2d54 7970 1.1..Content-Typ
0x0050: 653a 2061 7070 6c69 6361 7469 6f6e 2f78 e:.application/x
0x0060: 2d77 7777 2d66 6f72 6d2d 7572 6c65 6e63 -www-form-urlenc
0x0070: 6f64 6564 0d0a 5573 6572 2d41 6765 6e74 oded..User-Agent
0x0080: 3a20 4d65 7465 6f72 0d0a 4163 6365 7074 :.Meteor..Accept
0x0090: 3a20 2a2f 2a0d 0a68 6f73 743a 2031 302e :.*/*..host:.10.
0x00a0: 312e 3131 2e36 313a 3530 3030 0d0a 636f 1.11.61:5000..co
0x00b0: 6e74 656e 742d 6c65 6e67 7468 3a20 3135 ntent-length:.15
0x00c0: 310d 0a43 6f6e 6e65 6374 696f 6e3a 206b 1..Connection:.k
0x00d0: 6565 702d 616c 6976 650d 0a0d 0a eep-alive....
0x0000: 4500 00cb f95a 4000 4006 163c 0a01 0b58 E....Z#.#..<...X
0x0010: 0a01 0b3d d6a5 1388 ae92 8700 3d7b 996e ...=........={.n
0x0020: 8018 01c9 2b54 0000 0101 080a 183e 7f02 ....+T.......>..
0x0030: 34da 9ad9 7b22 6a73 6f6e 7270 6322 3a22 4...{"jsonrpc":"
0x0040: 322e 3022 2c22 6d65 7468 6f64 223a 2273 2.0","method":"s
0x0050: 656e 644d 6573 7361 6765 222c 2269 6422 endMessage","id"
0x0060: 3a31 2c22 7061 7261 6d73 223a 7b22 6163 :1,"params":{"ac
0x0070: 636f 756e 7449 4422 3a30 2c22 6d65 7373 countID":0,"mess
0x0080: 6167 6554 6578 7422 3a22 4974 2077 6173 ageText":"It.was
0x0090: 2061 2064 6172 6b20 616e 6420 7374 6f72 .a.dark.and.stor
0x00a0: 6d79 206e 6967 6874 2e22 2c22 636f 756e my.night.","coun
0x00b0: 7444 6f77 6e54 696d 6522 3a30 2c22 696e tDownTime":0,"in
0x00c0: 7465 7276 616c 223a 307d 7d terval":0}}
And this server apparently checks only for 'Host' (case sensitive) then throws an assertion error if it can't find it. Using curl, I've confirmed that the exact same request succeeds with the capitalized header name. Sadly, fixing this bad behavior in the (proprietary) server is not an option, so I have to make meteor send the values it expects.
I already tried setting the header like this:
result = Meteor.http.post(
api_endpoint,
{ headers: { 'Host': instance.host }, content: payload }
);
but the host header still gets sent in lowercase.
How do I override the host header properly?
Using meteor 0.6.5.1.
Make sure you update your code as the API changes, meteor is still in a preview release so stuff keeps changing. Meteor.http is now just HTTP.
So it looks like meteor converts headers to lowercase (see here). You need to alter some meteor packages to get it to work how you want.
Alter what you're looking for you need to make yourself a custom HTTP package.
1) Get the files over from https://github.com/meteor/meteor/blob/devel/packages/http/
2) Create a folder, if you don't aleady have one, called packages in your project's root directory and in it another directory HTTP
3) Add all the files you got from 1 in this HTTP directory.
4) run meteor add HTTP to override the default HTTP package with your one.
5) Alter the file httpcall_client.js at Line 143 (as at version Meteor 0.6.5.1) to alter the part that converts headers to lowercase so that they're used as is.
According to this answer, HTTP RFC 2616 states that header field names are case-insensitive, so the calling behavior is correct by spec.
If you are making the call from the client then try converting to a Meteor method and executing it on the server. Meteor client-side uses the
browser's XMLHttpRequest object so it will be browser-dependent. (You would see the same behavior using jQuery since it also uses the same browser objects.)
Meteor server-side uses Node's request function so first test that to see if it preserves case.
If not, since fixing the remote server is not possible, you will have to proxy the call through a server you control that can send the headers in the format required. That can either mean finding one that let's you control header case (maybe even dropping down to curl) or doing low-level string manip on the raw request.
So I think a plan of action is:
Test server-side Meteor.call
Find/write a proxy server
Replace the problem client-side calls with calls to your new proxy
Fix request headers en-route
Forward on to original end-point
Deal with responses
Hope that helps!

Generic keyboard emulation using Arduino Leonardo

I am trying to use an Arduino Leonardo for keyboard emulation since that is one of its advertised features. I have been playing with the Leonardo and wrote a very simple sketch based off the Blink example.
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;
// The setup routine runs once when you press reset:
void setup()
{
// Initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// The loop routine runs over and over again forever:
void loop()
{
delay(5000); // Wait for five seconds
digitalWrite(led, HIGH); // Turn the LED on (HIGH is the voltage level)
delay(100); // Wait for a secondA
digitalWrite(led, LOW); // Turn the LED off by making the voltage LOW
Keyboard.write('A'); // Write an A using keyboard emulator
}
Now this example works great on my Windows XP machine. It is recognized as a generic HID keyboard and will type an 'A' every five seconds.
The targeted environment is running DOS so to my knowledge I need to get the Arduino Leonardo recognized by the BIOS on this machine, which it is not and it does not type the 'A' in DOS.
I have been making modifications to the USB device descriptor of the Leonardo, trying to make it match a Dell L100 as much as possible. The modifications I've made haven't helped, and I suspect it is because the Leonardo is a composite device which exposes the serial communication, keyboard emulation, and mouse emulation on the same USB port. The source code for the USB descriptors/configuration is available to be edited and is located at:
Arduino_Installation\hardware\arduino\cores\arduino\HID.cpp
Arduino_Installation\hardware\arduino\cores\arduino\USBDesc.h
Arduino_Installation\hardware\arduino\cores\arduino\USBCore.h
Arduino_Installation\hardware\arduino\cores\arduino\USBCore.cpp
The following is a dump from USB Device Viewer for the Leonardo:
[Port3] : USB Composite Device
---===>Device Information<===---
English product name: "Arduino Leonardo"
ConnectionStatus:
Current Config Value: 0x01 -> Device Bus Speed: Full
Device Address: 0x03
Open Pipes: 4
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0010 = 0x10 bytes
bInterval: 0x40
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x01
===>Device Descriptor<===
bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0110
bDeviceClass: 0x00
*!*ERROR: device class should be Multi-interface Function 0xEF
When IAD descriptor is used
bDeviceSubClass: 0x00
*!*ERROR: device SubClass should be USB Common Sub Class 2
When IAD descriptor is used
bDeviceProtocol: 0x00
*!*ERROR: device Protocol should be USB IAD Protocol 1
When IAD descriptor is used
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0x2341 = Vendor ID not listed with USB.org as of 03-19-2008
idProduct: 0x8036
bcdDevice: 0x0100
iManufacturer: 0x01
English (United States) "Arduino LLC"
iProduct: 0x02
English (United States) "Arduino Leonardo"
iSerialNumber: 0x00
bNumConfigurations: 0x01
===>Configuration Descriptor<===
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x0064 -> Validated
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 -> Bus Powered
MaxPower: 0xFA = 500 mA
===>IAD Descriptor<===
bLength: 0x08
bDescriptorType: 0x0B
bFirstInterface: 0x00
bInterfaceCount: 0x02
bFunctionClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bFunctionSubClass: 0x01
bFunctionProtocol: 0x01
iFunction: 0x00
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 00 10 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 01 01 01
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x04
bDescriptorType: 0x24
04 24 02 06
-> This is a Communications (CDC Control) USB Device Interface Class
===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 06 00 01
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0010 = 0x10 bytes
bInterval: 0x40
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x02 -> Direction: OUT - EndpointID: 2
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x83 -> Direction: IN - EndpointID: 3
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00
===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x03 -> HID Interface Class
bInterfaceSubClass: 0x01
bInterfaceProtocol: 0x00
CAUTION: This may be an invalid bInterfaceProtocol
iInterface: 0x00
===>HID Descriptor<===
bLength: 0x09
bDescriptorType: 0x21
bcdHID: 0x0101
bCountryCode: 0x00
bNumDescriptors: 0x01
bDescriptorType: 0x22
wDescriptorLength: 0x0065
===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x84 -> Direction: IN - EndpointID: 4
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x01
How could I get this Leonardo recognized by a BIOS as a generic keyboard?
Arduino does not support the boot protocol. I have started using Teensy (which is Arduino compatible), and it works pretty well.
I might be mistaken, but if you want your device to be recognized during boot, its bInterfaceSubClass should be 0x01 (boot device subclass).
In source files, as you have pointed out, sub class is set to 0x00 everywhere.
You may try to set the subclass in all usages of the D_INTERFACE macro from file USBCore.h to 0x01.
I'm not an Arduino user. I was only once playing with HID keyboard emulation on AVR using V-USB. You can try to find detailed information about usb descriptors at USB.org in documentation. But it's quite a pile of pages to read.
Here is part od HID descriptor dump of my keyboard, notice values in Interface Descriptor:
Bus 005 Device 002: ID 046d:c30e Logitech, Inc. UltraX Keyboard (Y-BL49)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x046d Logitech, Inc.
idProduct 0xc30e UltraX Keyboard (Y-BL49)
bcdDevice 1.80
iManufacturer 1 Logitech
iProduct 2 HID compliant keyboard
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 59
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 62
The dump was made using "lsusb -v" as root under Linux.

Resources