#vulnerable code 
                              Map<WorkflowInstance, Long> allActiveStates() throws IOException {
    final EntityQuery activeStatesQuery = Query.entityQueryBuilder()
        .kind(KIND_ACTIVE_STATE)
        .build();

    final ImmutableMap.Builder<WorkflowInstance, Long> mapBuilder = ImmutableMap.builder();

    final QueryResults<Entity> results = datastore.run(activeStatesQuery);
    while (results.hasNext()) {
      final Entity activeState = results.next();
      final WorkflowInstance instance = parseWorkflowInstance(activeState);
      final long counter = activeState.getLong(PROPERTY_ACTIVE_STATE_COUNTER);

      mapBuilder.put(instance, counter);
    }

    return mapBuilder.build();
  } 
                            #location 1 
                            #vulnerability type CHECKERS_IMMUTABLE_CAST
#fixed code
                              DatastoreStorage(Datastore datastore, Duration retryBaseDelay) {
    this.datastore = Objects.requireNonNull(datastore);
    this.retryBaseDelay = Objects.requireNonNull(retryBaseDelay);

    this.componentKeyFactory = datastore.newKeyFactory().kind(KIND_COMPONENT);
    this.globalConfigKey = datastore.newKeyFactory().kind(KIND_STYX_CONFIG).newKey(KEY_GLOBAL_CONFIG);
  }