Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

gigaspaces issues

Hi,

I found an inconsistency in gigaspaces XAP 10.2.1 code(java version) regarding joda time exceptions.

The problem is that in some cases I got an exception, ClassCastException, while in other cases, no error is thrown.

Please take a look at the following classes ( Employee, Department) and a method (query()) that provides the scenarios.

package sample.model;

import com.gigaspaces.annotation.pojo.SpaceClass; import com.gigaspaces.annotation.pojo.SpaceId; import com.ubs.com.ubs.model.*; import org.joda.time.LocalDate;

import java.util.ArrayList; import java.util.List;

@SpaceClass public class Department { private Long id; private List<employee> employees = new ArrayList<employee>();

@SpaceId(autoGenerate = false)
public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public void setEmployees(List<Employee> employees) {
    this.employees = employees;
}

public List<Employee> getEmployees() {
    return employees;
}

}

package sample.model;

import com.gigaspaces.annotation.pojo.SpaceClass; import com.gigaspaces.annotation.pojo.SpaceId; import org.joda.time.LocalDate;

@SpaceClass public class Employee { private Long id; private String name; private LocalDate birthDate;

@SpaceId(autoGenerate = false)
public Long getId() {
    return id;
}
public void setId(Long id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public LocalDate getBirthDate() {
    return birthDate;
}

public void setBirthDate(LocalDate birthDate) {
    this.birthDate = birthDate;
}

}

public static  void query() {
    String url = "/./mySpace";
    GigaSpace space = new GigaSpaceConfigurer(new UrlSpaceConfigurer(url)).gigaSpace();

    Employee employee = new Employee();
    employee.setId(1L);
    employee.setBirthDate(LocalDate.parse("1980-12-12"));

    space.write(employee);

    Employee saved = space.read(new SQLQuery<Employee>(Employee.class, "birthDate <  ? ", LocalDate.now()));
    if (saved != null) {
        System.out.println("I'm able to find the employee!!");
    }

    // Although the jodatime class throws a exception, gigaspace code capture and swallow the ClassCastException
    /* public int compareTo(ReadablePartial other) {
            if (this == other) {
                return 0;
            }
            if (size() != other.size()) {
                throw new ClassCastException("ReadablePartial objects must have matching field types");
            .......
     }*/
    saved = space.read(new SQLQuery<Employee>(Employee.class, "birthDate <  ? ", LocalDateTime.now()));
    if (saved == null) {
        System.out.println("I'm not able to find the employee but no exception is thrown!!");
    }

    employee = new Employee();
    employee.setId(2L);
    employee.setBirthDate(LocalDate.parse("1980-12-12"));

    Department department = new Department();
    department.setId(1L);
    department.getEmployees().add(employee);

    space.write(department);

    Department savedDept = space.read(new SQLQuery<Department>(Department.class, " employees[*].birthDate <  ? ", LocalDate.now()));
    if (savedDept != null) {
        System.out.println("I'm able to find!!");
    }

    // This call throws a exception   java.lang.ClassCastException: ReadablePartial objects must have matching field types
    savedDept = space.read(new SQLQuery<Department>(Department.class, " employees[*].birthDate <  ? ", LocalDateTime.now()));
}

I know that I can avoid the problem by just using compatible types of joda time in the queries. LocalDate with LocalDate , LocalDateTime with LocalDateTime.

Should you provide some advice regarding this issue? Should I alert everyone to be careful while using joda time as in some cases we got exceptions and in other cases only empty results?

Best regards,

Helio Clementino

asked 2016-10-11 03:22:25 -0500

Helio Clementino gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Hi

We'll reproduce this and ask Engineering for suggestions, whether that will include a fix, a workaround, or just updated documentation we can't say at present.

Regards

jb

answered 2016-10-12 12:15:10 -0500

jb gravatar image
edit flag offensive delete link more
0

Hi

We've reproduced this, and will update this question when we have input from Engineering.

Regards

John

answered 2016-10-12 13:15:41 -0500

jb gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-11 03:22:25 -0500

Seen: 339 times

Last updated: Oct 12 '16