VerifyError using protobuf 2.4.1 - protocol-buffers

I am getting below error when trying to create a newBuilder() object for a given protobuf class. Having protobuf-java-2.4.1.jar in the classpath.
Same is working on the server side but fails on the client.
java.lang.VerifyError: Bad return type
Exception Details:
Location:
packagename.QuerySpecProtos$QuerySpec$Builder.clone()Lcom/google/protobuf/AbstractMessageLite$Builder; #4: areturn
Reason:
Type 'packagename.QuerySpecProtos$QuerySpec$Builder' (current frame, stack[0]) is not assignable to 'com/google/protobuf/AbstractMessageLite$Builder' (from method signature)
Current Frame:
bci: #4
flags: { }
locals: { 'packagename.QuerySpecProtos$QuerySpec$Builder' }
stack: { 'packagename.QuerySpecProtos$QuerySpec$Builder' }
Bytecode:
0000000: 2ab6 0062 b0

Looks like a version mismatch. You need to be sure that both:
You use the same jar version when compiling and running.
You use the same version of protoc to match the jar.

Related

I am having trouble sending a evm call while working with Substrate Frontier

I am just trying to follow the steps mentioned in the README.md file to send a simple call (link). I get the following error while trying to send the call using python substrate interface.
SubstrateRequestException: {'code': 1002, 'message': 'Verification Error: Runtime error: Execution failed: ApiError(FailedToConvertParameter { function: "validate_transaction", parameter: "tx", error: Error { cause: Some(Error { cause: Some(Error { cause: None, desc: "out of range decoding Compact<u32>" }), desc: "Could not decode `Call::call.2`" }), desc: "Could not decode `Call::EVM.0`" } })', 'data': 'RuntimeApi("Execution failed: ApiError(FailedToConvertParameter { function: \\"validate_transaction\\", parameter: \\"tx\\", error: Error { cause: Some(Error { cause: Some(Error { cause: None, desc: \\"out of range decoding Compact<u32>\\" }), desc: \\"Could not decode `Call::call.2`\\" }), desc: \\"Could not decode `Call::EVM.0`\\" } })")'}
Is it because I am missing some custom types when instantiating the substrate interface? If so what should I add to the custom types?
I already added the custom types mentioned at the top of the README.md.

Kotlin Mock Spring boot test can't compile

So I have the following test
#Test
fun `when save claims is called with email saved to that profile` () {
//arrange
given(profileRepository.findProfileByEmail(anyString())).willAnswer { daoProfile }
given(patientRepository.findById(anyInt())).willAnswer { Optional.of(daoPatient) }
given(claimRepository.saveAll(anyList())).willAnswer { mutableListOf(daoClaim) }
//act
val result = claimService.saveClaimsForEmail(listOf(dtoClaim), "Test#test.test")
//assert
assert(result != null)
assert(result?.isNotEmpty() ?: false)
verify(claimRepository).saveAll(anyList())
}
The line given(claimRepository.saveAll(anyList())).willAnswer { mutableListOf(daoClaim) } gives the folowing error
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate expression: KtBlockExpression
File being compiled at position: (217,71) in /Users/archer/Work/masterhealth/master_billing/src/test/kotlin/com/masterhealthsoftware/master_billing/data/service/ClaimServiceTest.kt
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.state.KotlinTypeMapper$typeMappingConfiguration$1.processErrorType(KotlinTypeMapper.kt:113)
...
Caused by: java.lang.IllegalStateException: Error type encountered: (???..???) (FlexibleTypeImpl).
at org.jetbrains.kotlin.codegen.state.KotlinTypeMapper$typeMappingConfiguration$1.processErrorType(KotlinTypeMapper.kt:113)
When the line is removed, it compiles but the test fails for obvious reasons.
claimRespoitory is annotated #MockBean at the top of the test class, and is a JpaInterface. Line 217 is the start of the function. I've also trie using when and other various willReturn or willAnswer....
Any idea why?
I was facing the same issue when using Mockito any(). Changing it to ArgumentMatchers.any(YourClass::class.java)) solved the compilation error, there is a deprecated ArgumentMatchers.anyListOf(YourClass::class.java) that might do the job.

Unknown type name 'WINBOOL'

I'm trying to link psapi in to a kotlin-native application and I encountered this error that I don't know how to fix.
By the type of error it looks like I'm missing something in the linker options but I couldn't find any information about it.
build.gradle.kts:
plugins {
kotlin("multiplatform") version "1.3.50"
}
repositories {
mavenCentral()
}
kotlin {
mingwX64("HelloWorld") {
val main by compilations.getting
val psapi by main.cinterops.creating
binaries {
executable("HelloWorldApp") {
entryPoint = "sample.helloworld.main"
}
}
}
}
src/nativeInterop/cinterop/psapi.def:
headers = psapi.h
headerFilter = psapi/*
linkerOpts.mingw = -lpsapi
The actual exception message:
Exception in thread "main" java.lang.Error: C:\Users\pawer\.konan\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1-2\x86_64-w64-mingw32\include\psapi.h:75:3: error: unknown type name 'WINBOOL'
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:146)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:963)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:952)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:222)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:69)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
FAILURE: Build failed with an exception.
Problem solved
src/nativeInterop/cinterop/psapi.def:
headers = windows.h \ psapi.h
headerFilter = psapi.h
package = psapi
linkerOpts.mingw = -lpsapi

Protobuf (gRPC) Code Generator for Go Creating Invalid Code

Everything works when I have my proto file defining a service with a streaming response. However when I return a single value, then the generated code is invalid!
Proto File:
syntax = "proto3";
package analyticsServicesGlobal;
option go_package = "generated/analyticsServices";
service HealthCheck {
rpc Health (HealthCheckParam) returns (HealthCheckPayload) {}
}
message HealthCheckPayload {
string message = 1;
}
message HealthCheckParam {
string response = 1;
}
The code generation completes without issue : protoc --go_out=plugins=grpc:$GOPATH/src/gauss minimal.proto
The ide and command line compilation return this error in the generated Go code though:
./minimal.pb.go:130: cannot use handler (type func("gauss/vendor/golang.org/x/net/context".Context, interface {}) (interface {}, error)) as type grpc.UnaryHandler in argument to interceptor
./minimal.pb.go:139: cannot use _HealthCheck_Health_Handler (type func(interface {}, "gauss/vendor/golang.org/x/net/context".Context, func(interface {}) error, grpc.UnaryServerInterceptor) (interface {}, error)) as type grpc.methodHandler in field value
This issue shows up for any service where a non-stream response is returned. I have create this minimal proto file to demonstrate, but every similar service definition has the same issue.
I am on OSX using Go version 1.8.1, protoc version 3.3.0, and the latest protoc plugin for Go go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
I'm sure I'm doing something wrong given the lack of reports on this issue - but I don't see what. Any suggestions are appreciated!

Hive Solr Storage handler Httpclient error

I developed Hive solrCloud storage handler, when I run select statement hive is throwing below error:
Exception in thread "main" java.lang.VerifyError: Bad return type
Exception Details:
Location:
org/apache/solr/client/solrj/impl/HttpClientUtil.createClient(Lorg/apache/solr/common/params/SolrParams;Lorg/apache/http/conn/ClientConnectionManager;)Lorg/apache/http/impl/client/CloseableHttpClient; #62: areturn
Reason:
Type 'org/apache/http/impl/client/DefaultHttpClient' (current frame, stack[0]) is not assignable to 'org/apache/http/impl/client/CloseableHttpClient' (from method signature)
Current Frame:
bci: #62
flags: { }
locals: { 'org/apache/solr/common/params/SolrParams', 'org/apache/http/conn/ClientConnectionManager', 'org/apache/solr/common/params/ModifiableSolrParams', 'org/apache/http/impl/client/DefaultHttpClient' }
stack: { 'org/apache/http/impl/client/DefaultHttpClient' }
Bytecode:
0000000: bb00 0359 2ab7 0004 4db2 0005 b900 0601
0000010: 0099 001e b200 05bb 0007 59b7 0008 1209
0000020: b600 0a2c b600 0bb6 000c b900 0d02 00bb
0000030: 0011 592b b700 124e 2d2c b800 102d b0
Stackmap Table:
append_frame(#47,Object[#127])
at org.apache.solr.client.solrj.impl.CloudSolrClient.(CloudSolrClient.java:189)
Is there any jar I need to update in class path?
PS: I don't have write access to add any jar in Hadoop or hive lib directory.
System configuration:
Hive 0.13, solrcloud 5.2.
There is an open issue in JIRA for solrj httpclient version conflict. The root cause of this issue is httpclient library version conflict in hadoop class path. The solrj client is not getting initialized by right version of httpclient.
Initializing solrj client with default Httpclient should resolve this issue.
e.g.
SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
this.server = new CloudSolrClient(url,httpClient);
You can export hadoop class path to add additional jar files to classpath. Check blog for adding jars to mapreduce job classpath.
export HADOOP_CLASSPATH=/xxx/noggit-0.6.jar:/xxx/httpclient-4.5.1.jar

Resources