[
https://issues.apache.org/jira/browse/TINKERPOP-3176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18020466#comment-18020466
]
Cole Greer commented on TINKERPOP-3176:
---------------------------------------
This issue was not resolved by replacing the old ternary boolean semantics with
simplified binary semantics (TINKERPOP-3173) as the class cast exception itself
fell outside of the well defined comparability semantics. The reported cast
exception is stemming from the generics in the Text enum:
https://github.com/apache/tinkerpop/blob/fa698ba2aba8967dcd17eb61cb13648b934fab5b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Text.java#L33.
In order to make TextP's handling of illegal types consistent with standard
comparisons, I would suggest that we override the `test()` method in TextP to
be something like this:
{code:java}
@Override
public boolean test(final V testValue) {
return testValue instanceof String && super.test(testValue);
}
{code}
An argument could be made that we should coerce any arguments to TextP to be
Strings (1 would be converted to "1"), however I think that would be beyond the
scope of this simple inconsistent behaviour bug.
> Inconsistent operation of ternary boolean logics with multiproperties
> ---------------------------------------------------------------------
>
> Key: TINKERPOP-3176
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3176
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.7.3
> Reporter: Valentyn Kahamlyk
> Priority: Minor
> Fix For: 3.8.0
>
>
> The result of the search by vertices depends on the order of creating
> multi-properties. The reason is in the operation of ternary logics.
> result is correct when string property created first
> {code:java}
> gremlin> g.addV("test").property("p1", "test").property(list, "p1", 1)
> ==>v[23]
> gremlin> g.V().has("p1", TextP.containing("est"))
> ==>v[23]{code}
> but error if first property is not String
> {code:java}
> gremlin> g.addV("test").property("p1", 1).property(list, "p1", "test")
> ==>v[26]
> gremlin> g.V().has("p1", TextP.containing("est"))
> class java.lang.Integer cannot be cast to class java.lang.String
> (java.lang.Integer and java.lang.String are in module java.base of loader
> 'bootstrap'){code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)