Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 084CD200C15 for ; Wed, 8 Feb 2017 20:19:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 072A6160B67; Wed, 8 Feb 2017 19:19:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4FA60160B5A for ; Wed, 8 Feb 2017 20:19:47 +0100 (CET) Received: (qmail 21133 invoked by uid 500); 8 Feb 2017 19:19:46 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 21121 invoked by uid 99); 8 Feb 2017 19:19:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2017 19:19:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id BB4F71A0153 for ; Wed, 8 Feb 2017 19:19:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id zT0N6tQ5F0-u for ; Wed, 8 Feb 2017 19:19:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 77EFB5F283 for ; Wed, 8 Feb 2017 19:19:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EDE65E0485 for ; Wed, 8 Feb 2017 19:19:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id BB65124D2F for ; Wed, 8 Feb 2017 19:19:41 +0000 (UTC) Date: Wed, 8 Feb 2017 19:19:41 +0000 (UTC) From: "Stian Soiland-Reyes (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COMMONSRDF-56) JSON-LD Literals wrongly compare equal MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 08 Feb 2017 19:19:48 -0000 [ https://issues.apache.org/jira/browse/COMMONSRDF-56?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858415#comment-15858415 ] Stian Soiland-Reyes commented on COMMONSRDF-56: ----------------------------------------------- Although the [fix has been proposed upstream|https://github.com/jsonld-java/jsonld-java/pull/190] I think we should avoid using .compareTo() at all and rather do this using direct calls on the getters. > JSON-LD Literals wrongly compare equal > -------------------------------------- > > Key: COMMONSRDF-56 > URL: https://issues.apache.org/jira/browse/COMMONSRDF-56 > Project: Apache Commons RDF > Issue Type: Bug > Components: jsonld-java > Reporter: Stian Soiland-Reyes > Fix For: 0.3.0 > > > There's a [bug in JSON-LD Java](https://github.com/jsonld-java/jsonld-java/pull/190) in {{Node.compareTo()}} for Literals, namely, they don't compare the values of the literal, language or datatype, which in Commons RDF can wrongly match a literal, say in dataset.stream() or in Literal.equals(): > {code} > JsonLdRDF rdf = new JsonLdRDF(); > JsonLdLiteral lit1 = rdf.createLiteral("Hello"); > JsonLdLiteral lit2 = rdf.createLiteral("Hello there"); > assertNotEquals(lit1, lit2); > {code} > The above will fail because JsonLdLiteralImpl.equals does a short citcuit: > {code} > if (obj instanceof JsonLdLiteral) { > final JsonLdLiteral other = (JsonLdLiteral) obj; > return asJsonLdNode().compareTo(other.asJsonLdNode()) == 0; > } > {code} > Similarly, using .contains or .stream matching a literal object backed by a JSON-LD Graph or Dataset will wrongly match any literal: > {code} > JsonLdDataset dataset = rdf.createDataset(); > JsonLdIRI s = rdf.createIRI("http://example.com/s"); > JsonLdIRI p = rdf.createIRI("http://example.com/p"); > JsonLdLiteral lit1 = rdf.createLiteral("Hello"); > JsonLdLiteral lit2 = rdf.createLiteral("Other"); > > dataset.add(null, s, p, lit1); > assertTrue(dataset.contains(Optional.empty(), s, p, lit2)); > assertFalse(dataset.contains(Optional.empty(), s, p, lit2)); > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)