Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

CodecNotFoundException because an off-by-one error #18

Open
lucasgp opened this issue Mar 15, 2017 · 0 comments
Open

CodecNotFoundException because an off-by-one error #18

lucasgp opened this issue Mar 15, 2017 · 0 comments

Comments

@lucasgp
Copy link

lucasgp commented Mar 15, 2017

When calling method com.github.adejanovski.cassandra.jdbc.CassandraResultSet#getTimestamp(int, java.util.Calendar) I get a CodecNotFoundException.

This error is caused because this method delegates to com.github.adejanovski.cassandra.jdbc.CassandraResultSet#getTimestamp(int) passing a wrong value in the index parameter.

public Timestamp getTimestamp(int index) throws SQLException {
    this.checkIndex(index);
    java.util.Date date = this.currentRow.getTimestamp(index - 1);
    return date == null?null:new Timestamp(this.currentRow.getTimestamp(index - 1).getTime());
}

public Timestamp getTimestamp(int index, Calendar calendar) throws SQLException {
    this.checkIndex(index);
    java.util.Date date = this.currentRow.getTimestamp(index - 1);
    return date == null?null:this.getTimestamp(index - 1);
}

If the method getTimestamp(int, java.util.Calendar) receives 2 in the index param, it would then call getTimestamp(int) with index - 1. This causes the call to this.currentRow.getTimestamp(index - 1) being done over the previous column, not the current one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant