Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public Vectors read(JsonReader in) throws IOException {
vector = float_1d.fromJsonTree(array);
}

assert (vector instanceof float[]) || (vector instanceof float[][]) : "invalid vector type";
assert (vector instanceof float[]) || (vector instanceof float[][])
: "invalid vector type " + vector.getClass();

namedVectors.put(vectorName, vector);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.HashMap;
import java.util.Map;

import io.weaviate.client6.v1.internal.DateUtil;
import io.weaviate.client6.v1.api.collections.CollectionHandleDefaults;
import io.weaviate.client6.v1.internal.DateUtil;
import io.weaviate.client6.v1.internal.grpc.Rpc;
import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateGrpc.WeaviateBlockingStub;
import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateGrpc.WeaviateFutureStub;
Expand Down Expand Up @@ -79,7 +79,7 @@ static <T> Rpc<AggregateRequest, WeaviateProtoAggregate.AggregateRequest, Aggreg
} else if (groupBy.hasBooleans()) {
groupedBy = new GroupedBy<>(property, groupBy.getBooleans().getValuesList().toArray(Boolean[]::new));
} else {
assert false : "(aggregate) branch not covered";
throw new IllegalArgumentException(property + " data type is not supported");
}

var properties = unmarshalAggregation(result.getAggregations());
Expand Down Expand Up @@ -148,7 +148,7 @@ private static Map<String, Object> unmarshalAggregation(WeaviateProtoAggregate.A
metric.hasMode() ? metric.getMode() : null,
metric.hasSum() ? metric.getSum() : null);
} else {
assert false : "branch not covered";
throw new IllegalArgumentException(property + " data type is not supported");
}

if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public CompletableFuture<AsyncPage<PropertiesT>> fetchNextPage() {
// If it is null after the first iteration it is
// because we haven't requested Metadata.UUID, in which
// case pagination will continue to run unbounded.
assert nextCursor != null : "page cursor is null";
if (nextCursor == null) {
throw new IllegalStateException("page cursor is null");
}
return new AsyncPage<>(nextCursor, pageSize, fetch, nextPage);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public boolean tryAdvance(Consumer<? super WeaviateObject<PropertiesT, Object, Q
// If it is null after the first iteration it is
// because we haven't requested Metadata.UUID, in which
// case pagination will continue to run unbounded.
assert cursor != null : "page cursor is null";
if (cursor == null) {
throw new IllegalStateException("page cursor is null");
}

currentPage = nextPage.iterator();
return tryAdvance(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static <T> void setProperty(String property, WeaviateProtoProperties.Val
builder.setOffsetDateTimeArray(property, dates);
}
} else {
assert false : "(query) branch not covered";
throw new IllegalArgumentException(property + " data type is not supported");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private ObjectBuilder<CollectionConfig> inspectClass(CollectionConfig.Builder b)
}

if (ctor == null) {
throw new IllegalArgumentException(type.getCanonicalName() + " fields are not supported");
throw new IllegalArgumentException(type.getCanonicalName() + " property is not supported");
}

assert ctor != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ public Map<String, Object> readProperties() {
var out = new HashMap<String, Object>();
for (var field : properties.getClass().getDeclaredFields()) {
var propertyName = PojoDescriptor.propertyName(field);
field.setAccessible(true);
try {
out.put(propertyName, field.get(properties));
} catch (IllegalAccessException e) {
assert e == null : e.getMessage();
if (field.trySetAccessible()) {
try {
out.put(propertyName, field.get(properties));
} catch (IllegalAccessException e) {
new RuntimeException("accessible flag set but access denied", e);
}
}
// TODO: how do we handle the case where a property is not accessible?
// E.g. we weren't able to set `accessible` flag.
}
return out;
}
Expand Down