[ https://issues.apache.org/jira/browse/GEODE-2143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15816518#comment-15816518 ]
Kevin Duling edited comment on GEODE-2143 at 1/10/17 11:26 PM: --------------------------------------------------------------- Steps to reproduce: Create an app similar to the Geode in 5 minutes example. {code} package geode; import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.ClientCacheFactory; import org.apache.geode.cache.client.ClientRegionShortcut; public class CustomerSerialization { /* How to run: 1. gfsh> start locator --name=locator 2. gfsh> start server --name=server 3. deploy --jar=customer-1.0-SNAPSHOT.jar 4. Run this application 5. gfsh> query --query="select * from /regionA" */ public static void main(String[] args) throws Exception { ClientCache cache = new ClientCacheFactory() .addPoolLocator("localhost", 10334) .setPoolSubscriptionEnabled(true) .create(); Region region = cache.<String, Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("regionA"); Customer customer = new Customer(1L, "johnson", "o'sullivan", "555-12-4444"); region.put("galen", customer); } } {code} and create a jar with a Customer object in it: {code} /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package geode; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.geode.internal.lang.ObjectUtils; import java.io.Serializable; /** * The Customer class models a customer entity. * <p/> * * @since GemFire 8.0 */ @JsonInclude(Include.NON_NULL) public class Customer implements Serializable { @JsonProperty("id") private Long customerId; private String firstName; private String lastName; @JsonProperty("ssn") private String socialSecurityNumber; public Customer() {} public Customer(final Long custId) { this.customerId = custId; } public Customer(final Long custId, final String fname, final String lname, final String ssn) { this.customerId = custId; this.firstName = fname; this.lastName = lname; this.socialSecurityNumber = ssn; } public Long getCustomerId() { return customerId; } public void setCustomerId(Long customerId) { this.customerId = customerId; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof Customer)) { return false; } final Customer that = (Customer) obj; return (ObjectUtils.equals(this.getCustomerId(), that.getCustomerId()) && ObjectUtils.equals(this.getLastName(), that.getLastName()) && ObjectUtils.equals(this.getFirstName(), that.getFirstName()) && ObjectUtils.equals(this.getSocialSecurityNumber(), that.getSocialSecurityNumber())); } public String getSocialSecurityNumber() { return socialSecurityNumber; } public void setSocialSecurityNumber(final String ssn) { this.socialSecurityNumber = ssn; } @Override public int hashCode() { int hashValue = 17; hashValue = 37 * hashValue + ObjectUtils.hashCode(getCustomerId()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName()); return hashValue; } @Override public String toString() { final StringBuilder buffer = new StringBuilder("{ type = "); buffer.append(getClass().getName()); buffer.append(", customerId = ").append(getCustomerId()); buffer.append(", firstName = ").append(getFirstName()); buffer.append(", lastName = ").append(getLastName()); buffer.append(", ssn = ").append(getSocialSecurityNumber()); buffer.append(" }"); return buffer.toString(); } } {code} was (Author: kduling): Steps to reproduce: Create an app similar to the Geode in 5 minutes example. {code} package geode; import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.ClientCacheFactory; import org.apache.geode.cache.client.ClientRegionShortcut; public class CustomerSerialization { /* How to run: 1. gfsh> start locator --name=locator 2. gfsh> start server --name=server 3. deploy --jar=customer-1.0-SNAPSHOT.jar 4. Run this application 5. gfsh> query --query="select * from /regionA" */ public static void main(String[] args) throws Exception { ClientCache cache = new ClientCacheFactory() .addPoolLocator("localhost", 10334) .setPoolSubscriptionEnabled(true) .create(); Region region = cache.<String, Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("regionA"); Customer customer = new Customer(1L, "johnson", "osullivan", "555-12-4444"); region.put("galen", customer); } } {code} and create a jar with a Customer object in it: {code} /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package geode; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.geode.internal.lang.ObjectUtils; import java.io.Serializable; /** * The Customer class models a customer entity. * <p/> * * @since GemFire 8.0 */ @JsonInclude(Include.NON_NULL) public class Customer implements Serializable { @JsonProperty("id") private Long customerId; private String firstName; private String lastName; @JsonProperty("ssn") private String socialSecurityNumber; public Customer() {} public Customer(final Long custId) { this.customerId = custId; } public Customer(final Long custId, final String fname, final String lname, final String ssn) { this.customerId = custId; this.firstName = fname; this.lastName = lname; this.socialSecurityNumber = ssn; } public Long getCustomerId() { return customerId; } public void setCustomerId(Long customerId) { this.customerId = customerId; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof Customer)) { return false; } final Customer that = (Customer) obj; return (ObjectUtils.equals(this.getCustomerId(), that.getCustomerId()) && ObjectUtils.equals(this.getLastName(), that.getLastName()) && ObjectUtils.equals(this.getFirstName(), that.getFirstName()) && ObjectUtils.equals(this.getSocialSecurityNumber(), that.getSocialSecurityNumber())); } public String getSocialSecurityNumber() { return socialSecurityNumber; } public void setSocialSecurityNumber(final String ssn) { this.socialSecurityNumber = ssn; } @Override public int hashCode() { int hashValue = 17; hashValue = 37 * hashValue + ObjectUtils.hashCode(getCustomerId()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getLastName()); hashValue = 37 * hashValue + ObjectUtils.hashCode(getFirstName()); return hashValue; } @Override public String toString() { final StringBuilder buffer = new StringBuilder("{ type = "); buffer.append(getClass().getName()); buffer.append(", customerId = ").append(getCustomerId()); buffer.append(", firstName = ").append(getFirstName()); buffer.append(", lastName = ").append(getLastName()); buffer.append(", ssn = ").append(getSocialSecurityNumber()); buffer.append(" }"); return buffer.toString(); } } {code} > JSON deserialization fails if a String contains an apostrophe > ------------------------------------------------------------- > > Key: GEODE-2143 > URL: https://issues.apache.org/jira/browse/GEODE-2143 > Project: Geode > Issue Type: Bug > Components: gfsh > Reporter: Jared Stewart > Assignee: Kevin Duling > > Testing revealed this causes an issue when a String value contains a single > apostrophe in it. For example: {{Customer customer = new Customer(1L, > "Galen", "O'Sullivan", "555-11-2222");}} > If you create a region and put in a value which is an instance of > org.apache.geode.rest.internal.web.controllers.Customer, then gfsh blows up > when attempting to display the value: > {code} > gfsh>query --query="select * from /customers" > Result : true > startCount : 0 > endCount : 20 > Rows : 1 > Value > ------------------------------------------------------------------------------- > Error getting bean properties Expected a ',' or '}' at 86 [character 87 line > 1] > {code} > It would be good to determine why this occurs to prevent the same error from > arising with user-provided classes. > The error occurs in the GfJsonObject, which will be replaced in an upcoming > release. -- This message was sent by Atlassian JIRA (v6.3.4#6332)