Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberFormatException when fetching PGInterval with small value #1677

Closed
1 of 2 tasks
baardsen opened this issue Jan 23, 2020 · 0 comments · Fixed by #1678
Closed
1 of 2 tasks

NumberFormatException when fetching PGInterval with small value #1677

baardsen opened this issue Jan 23, 2020 · 0 comments · Fixed by #1678

Comments

@baardsen
Copy link
Contributor

I'm submitting a ...

  • bug report
  • feature request

Describe the issue
I get a NumberFormatException when fetching a PGInterval with value less than 1 millisecond.

Driver Version?
42.2.9

Java Version?
11

OS Version?
Manjaro linux with kernel 5.3.11-1-MANJARO

PostgreSQL Version?
11.6

To Reproduce

  • create table foo(bar interval)
  • insert into foo(bar) values ('0.0001 seconds')
  • Fetching the row as PGInterval will throw exception

Expected behaviour
Get a PGInterval instance with 100 microseconds.

Logs

...
Caused by: org.postgresql.util.PSQLException: Failed to create object for: interval.
	at org.postgresql.jdbc.PgConnection.getObject(PgConnection.java:646)
	at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2594)
	at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:266)
	at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:239)
	at org.springframework.jdbc.core.SingleColumnRowMapper.getColumnValue(SingleColumnRowMapper.java:149)
	at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:114)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:94)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:61)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:679)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617)
	... 7 more
Caused by: java.lang.NumberFormatException: For input string: "0E-4"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at org.postgresql.util.PGInterval.setSeconds(PGInterval.java:378)
	at org.postgresql.util.PGInterval.setValue(PGInterval.java:233)
	at org.postgresql.util.PGInterval.setValue(PGInterval.java:213)
	at org.postgresql.jdbc.PgConnection.getObject(PgConnection.java:631)
	... 16 more
baardsen added a commit to baardsen/pgjdbc that referenced this issue Jan 24, 2020
davecramer pushed a commit that referenced this issue Jan 28, 2020
…value (#1678)

* fix: #1677 NumberFormatException when fetching PGInterval with small value

* fix: PGInterval.getValue for microsecond values

* ensure getValue always uses at least one decimal place for seconds

* fix: PGInterval.getSeconds for microsecond values
paplorinc pushed a commit to paplorinc/pgjdbc that referenced this issue Feb 10, 2020
* origin/master: (427 commits)
  refactor: make PSQLState enum consts for integrity constraint violations (pgjdbc#1699)
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release REL42.2.10
  pass gpg key through arguments
  add passphrase to release mvn task
  chore: update signing key
  Metadata queries improvment (pgjdbc#1694)
  WIP release notes for 42.2.10 (pgjdbc#1688)
  chore(deps): bump checkstyle from 8.28 to 8.29 in /pgjdbc (pgjdbc#1691)
  Cleanup PGProperty, sort values, and add some missing to docs (pgjdbc#1686)
  fix: Fixes issue pgjdbc#1592 where one thread is reading the copy and another thread closes the connection (pgjdbc#1594)
  Fixing LocalTime rounding (losing precision) (pgjdbc#1570)
  sync error message value with tested value (pgjdbc#1664)
  add DatabaseMetaDataCacheTest to test suite to run it (pgjdbc#1685)
  Fix Network Performance of PgDatabaseMetaData.getTypeInfo() method (pgjdbc#1668)
  fix: Issue pgjdbc#1680 updating a boolean field requires special handling to set it to t or f instead of true or false (pgjdbc#1682)
  fix testSetNetworkTimeoutEnforcement test failure (pgjdbc#1681)
  minor: fix checkstyle violation of unused import (pgjdbc#1683)
  fix: pgjdbc#1677 NumberFormatException when fetching PGInterval with small value (pgjdbc#1678)
  fix: actually use milliseconds instead of microseconds for timeouts (pgjdbc#1653)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant