I am seeing `java.lang.
# spicedb
a
I am seeing
java.lang.ClassCastException: class io.grpc.stub.ClientCalls$BlockingResponseStream cannot be cast to class java.lang.Iterable (io.grpc.stub.ClientCalls$BlockingResponseStream is in unnamed module of loader 'app'; java.lang.Iterable is in module java.base of loader 'bootstrap')
this is in reference to lookupresources call where internally the response is not getting constrcuted
v
any code you could share with us?
a
Copy code
public int lookupResources(
    RelationshipType relationshipType,
    ResourceType resourceType,
    SubjectType subjectType,
    String subjectID
  ) {
    int size = 0;
    PermissionService.LookupResourcesRequest request = PermissionService
      .LookupResourcesRequest.newBuilder()
      .setConsistency(
        PermissionService.Consistency.newBuilder().setMinimizeLatency(true).build()
      )
      .setResourceObjectType(resourceType.getResourceType())
      .setPermission( relationshipType.getRelationshipType())
      .setSubject(
        Core
          .SubjectReference.newBuilder()
          .setObject(
            Core
              .ObjectReference.newBuilder()
              .setObjectType(subjectType.getSubjectType())
              .setObjectId(subjectID)
              .build()
          )
          .build()
      )
      .build();

    try {

     Iterator<LookupResourcesResponse> response = this.getPermissionsService().lookupResources(request);
     size = Iterables.size((Iterable<?>) response);
      System.out.println("result: " + size);
    } catch (Exception exception) {
      exception.printStackTrace();
    }

    return size;
  }
The request object as I start to debug already flashes a compilation error for the response object
It is is at the ITerator level where it is having issue getting the permissionship
Not sure what is wrong but this is the code it should be i guess
v
I wrote a test-case to show-case how it works: https://github.com/authzed/authzed-java/pull/73
I don't think size works here because this is a streaming API, and the server will send results as they become available
a
Thanks @vroldanbet this works , yes this is a streaming API so it is not deterministic call i presume more like the promises futrue call
v
exactly