From notifications-return-14153-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Fri Oct 5 06:31:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 18E1B180649 for ; Fri, 5 Oct 2018 06:31:04 +0200 (CEST) Received: (qmail 81400 invoked by uid 500); 5 Oct 2018 04:31:04 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 81386 invoked by uid 99); 5 Oct 2018 04:31:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2018 04:31:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 727D4183E5D for ; Fri, 5 Oct 2018 04:31:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.001 X-Spam-Level: X-Spam-Status: No, score=-109.001 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, KAM_NUMSUBJECT=0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id jCq0WWpvA_dm for ; Fri, 5 Oct 2018 04:31:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 2A2575F42E for ; Fri, 5 Oct 2018 04:31:01 +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 6046DE0101 for ; Fri, 5 Oct 2018 04:31:00 +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 263582474B for ; Fri, 5 Oct 2018 04:31:00 +0000 (UTC) Date: Fri, 5 Oct 2018 04:31:00 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (GROOVY-8824) CLONE - Wrong detection of Java 10 version in groovy-json Part 2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-8824?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King updated GROOVY-8824: ------------------------------ Description: I cloned the issue to cater for testing. I didn't get time to look at refactoring just yet. ORIGINAL BELOW: The following code from {{groovy.json.internal.Sys}} incorrectly parses {{java.version}} property on newer Java-s: {code:java} static { BigDecimal v = new BigDecimal("-1"); String sversion = System.getProperty("java.version"); if (sversion.indexOf("_") != -1) { final String[] split = sversion.split("_"); try { String ver = split[0]; if (ver.startsWith("1.7")) { v = new BigDecimal("1.7"); } if (ver.startsWith("1.8")) { v = new BigDecimal("1.8"); } if (ver.startsWith("1.9")) { v = new BigDecimal("1.9"); } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unable to determine build number or version"); } } else if ("1.8.0".equals(sversion)) { v = new BigDecimal("1.8"); } else { Pattern p = Pattern.compile("^([1-9]\\.[0-9]+)"); Matcher matcher = p.matcher(sversion); if (matcher.find()) { v = new BigDecimal(matcher.group(0)); } } is1_8OrLater = v.compareTo(new BigDecimal("1.8")) >= 0; is1_7 = v.compareTo(new BigDecimal("1.7")) == 0; is1_8 = v.compareTo(new BigDecimal("1.8")) == 0; } {code} Under Java 10+ ({{java.version=10.0.2}}) all {{is*}} fields are set to {{false}}. The outcome of it is e.g. {{LazyMap}} to use {{j.u.TreeMap}} instead of {{j.u.LinkedHashMap}} that would give insertion order for maps returned from {{JsonSlurper}}. Just extending the pattern to {code:java} "^([1-9]+\\.[0-9]+)" {code} seems to do the job. was: I cloned the issue to cater for testing. I didn't get time to look at refactoring just yet. The following code from {{groovy.json.internal.Sys}} incorrectly parses {{java.version}} property on newer Java-s: {code:java} static { BigDecimal v = new BigDecimal("-1"); String sversion = System.getProperty("java.version"); if (sversion.indexOf("_") != -1) { final String[] split = sversion.split("_"); try { String ver = split[0]; if (ver.startsWith("1.7")) { v = new BigDecimal("1.7"); } if (ver.startsWith("1.8")) { v = new BigDecimal("1.8"); } if (ver.startsWith("1.9")) { v = new BigDecimal("1.9"); } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unable to determine build number or version"); } } else if ("1.8.0".equals(sversion)) { v = new BigDecimal("1.8"); } else { Pattern p = Pattern.compile("^([1-9]\\.[0-9]+)"); Matcher matcher = p.matcher(sversion); if (matcher.find()) { v = new BigDecimal(matcher.group(0)); } } is1_8OrLater = v.compareTo(new BigDecimal("1.8")) >= 0; is1_7 = v.compareTo(new BigDecimal("1.7")) == 0; is1_8 = v.compareTo(new BigDecimal("1.8")) == 0; } {code} Under Java 10+ ({{java.version=10.0.2}}) all {{is*}} fields are set to {{false}}. The outcome of it is e.g. {{LazyMap}} to use {{j.u.TreeMap}} instead of {{j.u.LinkedHashMap}} that would give insertion order for maps returned from {{JsonSlurper}}. Just extending the pattern to {code:java} "^([1-9]+\\.[0-9]+)" {code} seems to do the job. > CLONE - Wrong detection of Java 10 version in groovy-json Part 2 > ---------------------------------------------------------------- > > Key: GROOVY-8824 > URL: https://issues.apache.org/jira/browse/GROOVY-8824 > Project: Groovy > Issue Type: Bug > Components: JSON > Affects Versions: 3.x, 2.5.2 > Environment: Oracle Java SE 10, Linux > Reporter: Przemek Wesolek > Assignee: Paul King > Priority: Major > > I cloned the issue to cater for testing. I didn't get time to look at refactoring just yet. > ORIGINAL BELOW: > The following code from {{groovy.json.internal.Sys}} incorrectly parses {{java.version}} property on newer Java-s: > {code:java} > static { > BigDecimal v = new BigDecimal("-1"); > String sversion = System.getProperty("java.version"); > if (sversion.indexOf("_") != -1) { > final String[] split = sversion.split("_"); > try { > String ver = split[0]; > if (ver.startsWith("1.7")) { > v = new BigDecimal("1.7"); > } > if (ver.startsWith("1.8")) { > v = new BigDecimal("1.8"); > } > if (ver.startsWith("1.9")) { > v = new BigDecimal("1.9"); > } > } catch (Exception ex) { > ex.printStackTrace(); > System.err.println("Unable to determine build number or version"); > } > } else if ("1.8.0".equals(sversion)) { > v = new BigDecimal("1.8"); > } else { > Pattern p = Pattern.compile("^([1-9]\\.[0-9]+)"); > Matcher matcher = p.matcher(sversion); > if (matcher.find()) { > v = new BigDecimal(matcher.group(0)); > } > } > is1_8OrLater = v.compareTo(new BigDecimal("1.8")) >= 0; > is1_7 = v.compareTo(new BigDecimal("1.7")) == 0; > is1_8 = v.compareTo(new BigDecimal("1.8")) == 0; > } > {code} > Under Java 10+ ({{java.version=10.0.2}}) all {{is*}} fields are set to {{false}}. > The outcome of it is e.g. {{LazyMap}} to use {{j.u.TreeMap}} instead of {{j.u.LinkedHashMap}} that would give insertion order for maps returned from {{JsonSlurper}}. > Just extending the pattern to > {code:java} > "^([1-9]+\\.[0-9]+)" > {code} > seems to do the job. -- This message was sent by Atlassian JIRA (v7.6.3#76005)