pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
14+ messages / 4 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 06:01 "dfa1 (@dfa1)" <[email protected]>
  0 siblings, 0 replies; 14+ messages in thread

From: dfa1 (@dfa1) @ 2026-05-10 06:01 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Previously returned new CharArrayReader(value.toCharArray()), which allocates a char[] proportional to the string length (2 * n bytes). StringReader wraps the String directly with no extra allocation.

No benchmark written: the allocation is trivially O(n) and the fix is mechanical. Visible in -prof gc as reduced char[] allocation under any workload that calls getCharacterStream().


^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 10:07 ` "davecramer (@davecramer)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: davecramer (@davecramer) @ 2026-05-10 10:07 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The only challenge here is that this while doesn't break the API, it does materially change what is returned. This would be a breaking change.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 12:34 ` "dfa1 (@dfa1)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: dfa1 (@dfa1) @ 2026-05-10 12:34 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Would a changelog entry ("getCharacterStream now returns StringReader; callers should rely on the Reader contract as per JDBC spec") be enough to address it?  Alternatively I could extend the PR to make this opt-in change (but I would need guidance for the best mechanism).


^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 20:00 ` "davecramer (@davecramer)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: davecramer (@davecramer) @ 2026-05-10 20:00 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

For sure needs a change log entry.  The question is will it require a major version? We've released what we thought were harmless minor versions only to find out it broke something somewhere

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 20:03 ` "vlsi (@vlsi)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: vlsi (@vlsi) @ 2026-05-10 20:03 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Why major version? The change is subtle, and the return type is still Reader. I think patch version is fine

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-10 20:14 ` "davecramer (@davecramer)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: davecramer (@davecramer) @ 2026-05-10 20:14 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Agreed it is a Reader, but if someone actually casts it to CharArrayReader in their code then it will break their code.
That said I could be convinced otherwise as it does meet the API

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 07:56 ` "vlsi (@vlsi)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: vlsi (@vlsi) @ 2026-05-11 07:56 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> if someone actually casts it to CharArrayReader in their code then it will break their code

That is fair. `CharArrayReader` has been sitting there since 2002.

On the other hand, `CharArrayReader` adds no new methods, and its `char[] buf` is protected, so I am leaning towards patch-level change. If we treat this as minor, then we would have to bump minor in virtually every change we make, which would render "minor bump" useless for the users.

Frankly, I see two options:

* We could consider this as an internal/bugfix/almost backward-compatible change. In that case we just fix it.
* We could consider this as a user-visible/non backward-compatible change. In that case we should rather add an option to allow users switching to the new default, and after 2 years we could flip the default.

I would accept either way (we shouldn't spent time on discussing the trivial changes), however, I would prefer just fix it as it is unlikely to break users' code.

---

There's yet another possibility: the resultset holds `byte[]` + `encoding`. @dfa1 , have you evaluated/profiled the approach of using `new InputStreamReader(new ByteArrayInputStream(bytes), charset)` approach?

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 11:24 ` "sehrope (@sehrope)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: sehrope (@sehrope) @ 2026-05-11 11:24 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Changing the class while still returning a `Reader` is not a breaking change. Anybody that is relying on the exact underlying implementation has been gambling that it will never change. And that user must have been explicitly casting the reader type too. So I doubt this is a problem in the real world and even if it is, it's the user's problem to fix.

This is a purely internal change and does not require maintaining any backwards compatible flag for the old behavior. If we want the change, just change the returned value and that's it.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 11:26 ` "davecramer (@davecramer)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: davecramer (@davecramer) @ 2026-05-11 11:26 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

I'm just exercising caution. We have been here before. I'm not a proponent of adding yet another configuration option so I will stop arguing against this.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 11:27 ` "davecramer (@davecramer)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: davecramer (@davecramer) @ 2026-05-11 11:27 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@dfa1 Can you add something to the Changelog and I will merge it.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 18:46 ` "dfa1 (@dfa1)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: dfa1 (@dfa1) @ 2026-05-11 18:46 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer  please have a look now

@vlsi  @sehrope  thanks for the review!

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 19:36 ` "vlsi (@vlsi)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: vlsi (@vlsi) @ 2026-05-11 19:36 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on CHANGELOG.md:112)

What was the reason to modify the lines? Please do not mix unrelated changes into the PR.

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 19:43 ` "dfa1 (@dfa1)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: dfa1 (@dfa1) @ 2026-05-11 19:43 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on CHANGELOG.md:112)

sorry that is my editor configured to trim trailing spaces automatically 

^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader
@ 2026-05-11 19:50 ` "vlsi (@vlsi)" <[email protected]>
  12 siblings, 0 replies; 14+ messages in thread

From: vlsi (@vlsi) @ 2026-05-11 19:50 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on CHANGELOG.md:112)

Spaces at the end of lines are **significant** for markdown. We have .editorconfig so editors that support it configure automatically

^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2026-05-11 19:50 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-10 06:01 [pgjdbc/pgjdbc] PR #4063: fix: getCharacterStream wraps String in StringReader "dfa1 (@dfa1)" <[email protected]>
2026-05-10 10:07 ` "davecramer (@davecramer)" <[email protected]>
2026-05-10 12:34 ` "dfa1 (@dfa1)" <[email protected]>
2026-05-10 20:00 ` "davecramer (@davecramer)" <[email protected]>
2026-05-10 20:03 ` "vlsi (@vlsi)" <[email protected]>
2026-05-10 20:14 ` "davecramer (@davecramer)" <[email protected]>
2026-05-11 07:56 ` "vlsi (@vlsi)" <[email protected]>
2026-05-11 11:24 ` "sehrope (@sehrope)" <[email protected]>
2026-05-11 11:26 ` "davecramer (@davecramer)" <[email protected]>
2026-05-11 11:27 ` "davecramer (@davecramer)" <[email protected]>
2026-05-11 18:46 ` "dfa1 (@dfa1)" <[email protected]>
2026-05-11 19:36 ` "vlsi (@vlsi)" <[email protected]>
2026-05-11 19:43 ` "dfa1 (@dfa1)" <[email protected]>
2026-05-11 19:50 ` "vlsi (@vlsi)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox