Skip to content

ClassCastException when arangodb.acquireHostList=true #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rashtao opened this issue Aug 8, 2019 · 4 comments
Closed

ClassCastException when arangodb.acquireHostList=true #21

rashtao opened this issue Aug 8, 2019 · 4 comments
Assignees

Comments

@rashtao
Copy link
Contributor

rashtao commented Aug 8, 2019

When arangodb.acquireHostList=true is set com.arangodb.ArangoDBTest fails with the following error:


java.lang.ClassCastException: class com.arangodb.internal.velocystream.VstConnectionAsync cannot be cast to class com.arangodb.internal.velocystream.internal.VstConnectionSync (com.arangodb.internal.velocystream.VstConnectionAsync and com.arangodb.internal.velocystream.internal.VstConnectionSync are in unnamed module of loader 'app')

	at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:42)
	at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:132)
	at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:47)
	at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:79)
	at com.arangodb.internal.net.ExtendedHostResolver.resolveFromServer(ExtendedHostResolver.java:139)
	at com.arangodb.internal.net.ExtendedHostResolver.resolve(ExtendedHostResolver.java:91)
	at com.arangodb.internal.net.FallbackHostHandler.confirm(FallbackHostHandler.java:75)
	at com.arangodb.internal.net.DirtyReadHostHandler.confirm(DirtyReadHostHandler.java:73)
	at com.arangodb.internal.velocystream.VstCommunication.connect(VstCommunication.java:100)
	at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:131)
	at com.arangodb.internal.ArangoExecutorAsync.execute(ArangoExecutorAsync.java:65)
	at com.arangodb.internal.ArangoExecutorAsync.execute(ArangoExecutorAsync.java:57)
	at com.arangodb.internal.ArangoDBAsyncImpl.createDatabase(ArangoDBAsyncImpl.java:100)
	at com.arangodb.ArangoDBTest.createDatabase(ArangoDBTest.java:84)
	...


@rashtao rashtao self-assigned this Aug 8, 2019
@wajda
Copy link

wajda commented Mar 25, 2020

Any update on this please?

@rashtao
Copy link
Contributor Author

rashtao commented Mar 26, 2020

I haven't worked on this yet.
From a first look to the related code, it seems to me a bit hard to implement without blocking the thread, because of the way it has been designed (VstConnectionAsync delegating VstConnectionSync). If you can figure out an easy way to fix it, feel free to submit a PR!
Otherwise, as workaround I suggest you adding all the hosts in the configuration.

Also consider that we are currently working on a rewrite of the driver based on reactive streams, which will supersede the asynchronous driver. You can follow the development here: https://github.com/arangodb/arangodb-java-driver/tree/next

@wajda
Copy link

wajda commented Mar 26, 2020

Thanks for the update @rashtao
I've realized that in my case this error only happens on the first call on the application start time. The second time I call the same method it works. Will retest it in a new driver, but meantime this is a workaround that works for me:

try {
  arangoDatabase.getInfo.get()
} catch {
  // The first call fails with a CCE due to a bug in ArangoDB Java Driver (arangodb/arangodb-java-driver-async#21)
  case ee: ExecutionException if ee.getCause.isInstanceOf[ClassCastException] =>
    arangoDatabase.getInfo.get()
}

@rashtao
Copy link
Contributor Author

rashtao commented Mar 23, 2021

Fixed by arangodb/arangodb-java-driver#378

@rashtao rashtao closed this as completed Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants