diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java b/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java index 2c5dacf4..b89cf7fc 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java @@ -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); } } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AggregateRequest.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AggregateRequest.java index 89e891cf..fa8290f6 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AggregateRequest.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AggregateRequest.java @@ -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; @@ -79,7 +79,7 @@ static Rpc(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()); @@ -148,7 +148,7 @@ private static Map 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) { diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/AsyncPage.java b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/AsyncPage.java index baddef6f..691b8bad 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/AsyncPage.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/AsyncPage.java @@ -61,7 +61,9 @@ public CompletableFuture> 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); }); } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/CursorSpliterator.java b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/CursorSpliterator.java index 27132fc2..3b0335d8 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/CursorSpliterator.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/CursorSpliterator.java @@ -45,7 +45,9 @@ public boolean tryAdvance(Consumer 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"); } } } diff --git a/src/main/java/io/weaviate/client6/v1/internal/orm/PojoDescriptor.java b/src/main/java/io/weaviate/client6/v1/internal/orm/PojoDescriptor.java index bcb1b470..d0a1f218 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/orm/PojoDescriptor.java +++ b/src/main/java/io/weaviate/client6/v1/internal/orm/PojoDescriptor.java @@ -147,7 +147,7 @@ private ObjectBuilder 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; diff --git a/src/main/java/io/weaviate/client6/v1/internal/orm/PojoReader.java b/src/main/java/io/weaviate/client6/v1/internal/orm/PojoReader.java index 82ccea5a..41ace15d 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/orm/PojoReader.java +++ b/src/main/java/io/weaviate/client6/v1/internal/orm/PojoReader.java @@ -15,12 +15,15 @@ public Map readProperties() { var out = new HashMap(); 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; }