Skip to content

[java] Model connect and no-arg constructors of piped streams - #2294

Merged
dulmarod merged 1 commit into
meta:mainfrom
tanvir-ux:piped-reader-writer
Nov 2, 2026
Merged

dulmarod merged 1 commit into
meta:mainfrom
tanvir-ux:piped-reader-writer

Conversation

@tanvir-ux

Copy link
Copy Markdown
Contributor

Summary

Two gaps in the Java Pulse models for piped streams:

  1. PipedReader() and PipedWriter() (no-arg constructors) were not tracked as resources. Only the constructors that take the other end were covered, through the generic Reader/Writer delegation model.
  2. connect on PipedInputStream, PipedOutputStream, PipedReader and PipedWriter was not modeled, so Pulse did not know it can throw IOException.

Because of this, a pipe end created with the no-arg constructor and closed only on the normal path after connect was never reported. FN_pipedReaderNotConnectedBad and FN_pipedWriterNotClosedAfterConnectBad show this.

  • Model the 1-argument <init> (just this) of PipedReader/PipedWriter with Resource.allocate. These constructors don't throw. The constructors that take the other end keep the existing delegation model.
  • Model connect on all four piped classes with Resource.use ~exn_class_name:"java.io.IOException", the same way read/write are modeled.

Tests

  • FN_pipedReaderNotConnectedBad and FN_pipedWriterNotClosedAfterConnectBad are renamed without the FN_ prefix and are now reported.
  • pipedReaderNotClosedAfterConnectOk was a leak (close() is skipped if connect or read throws), so it is renamed pipedReaderNotClosedAfterReadBad and is now reported.
  • New tests pipedInputStreamNotClosedAfterConnectBad and pipedOutputStreamNotClosedAfterConnectBad in ResourceLeaks.java cover connect for the byte streams.
  • pipedReaderClosedOk, pipedWriterClosedOk and the other Ok cases stay clean. FN_pipedWriterNotConnectedBad and FN_pipedReaderWriterBad are left as they are.

Test plan

  • Before (main @ a8f5b17): none of the 5 tests above is reported
  • After: PULSE_RESOURCE_LEAK for all 5, allocated by the PipedReader(), PipedWriter(), PipedInputStream() or PipedOutputStream() constructor
  • make direct_java_pulse_test: the only issues.exp changes are those 5 lines. (As in [java] Track PipedInputStream and PipedOutputStream as resources #2290, I still get the unrelated lambda-name differences in InvokeDynamic/TransitiveAccess locally with my javac; not committed.)
  • ocamlformat 0.29.0 reports no changes for PulseModelsJava.ml

PipedReader() and PipedWriter() were not tracked as resources, and
connect on the four piped classes was not modeled as a call that can
throw IOException. A pipe end closed only on the normal path after
connect was therefore never reported.
@meta-cla meta-cla Bot added the CLA Signed label Nov 2, 2026
@dulmarod
dulmarod merged commit 3a0aef6 into meta:main Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants