Menu

Update 2.5.0 -> 2.5.1: java.time.OffsetTime regression

Help
2020-10-01
2020-10-03
  • Marnick L'Eau

    Marnick L'Eau - 2020-10-01

    (I didn't realize you could create a topic normally and did it by mail first, but that doesn't seem to be working — sorry if this topic ends up getting created twice)

    Upgrading from 2.5.0 to 2.5.1 caused a test failure. Here's the simplest reproduction code:

    @Test
    public void regression() throws SQLException {
        try (Connection conn = dataSource.getConnection()) {
            OffsetTime in = OffsetTime.now(ZoneId.of("Etc/GMT-14")).truncatedTo(ChronoUnit.SECONDS);
    
            conn.createStatement().execute("create table test(val time with time zone not null)");
    
            PreparedStatement insert = conn.prepareStatement("insert into test(val) values(?)");
            insert.setObject(1, in);
            insert.execute();
    
            ResultSet rs = conn.createStatement().executeQuery("select val from test");
            rs.next();
            OffsetTime out = rs.getObject(1, OffsetTime.class);
    
            assertThat(out).isEqualTo(in);
        }
    }
    

    Expecting:
    <02:51:05+14:00>
    to be equal to:
    <12:51:05+14:00>
    but was not.

    Something's obviously going wrong with the time component, the offset seems actually persisted correctly.

    In 2.5.0 this test works fine. It's part of a suite of tests against most of the java.time classes, all with similar scenarios, and they all work in both versions without changes.

    Was this an intended change (not clearly listed in release notes though) or a bug, or is "time with time zone" not the right column type?

     

    Last edit: Marnick L'Eau 2020-10-01
  • Fred Toussi

    Fred Toussi - 2020-10-02

    Thanks for reporting. It is a regression and will be fixed.

     
    👍
    1
  • Fred Toussi

    Fred Toussi - 2020-10-03

    Fixed and committed to SVN. I would suggest you build the jar and check. Alternatively, your can check the next snapshot jar, available in a few days.

     
  • Marnick L'Eau

    Marnick L'Eau - 2020-10-03

    I'm just gonna wait for the patch release, but thanks!

     
  • Fred Toussi

    Fred Toussi - 2020-10-03
     

Log in to post a comment.