Skip to content

fix null inputstream behavior - #193

Merged
phax merged 3 commits into
phax:masterfrom
glelouet:ensure_transmit_nullsourcedinputstream
Sep 8, 2026
Merged

phax merged 3 commits into
phax:masterfrom
glelouet:ensure_transmit_nullsourcedinputstream

Conversation

@glelouet

@glelouet glelouet commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator
  • ensures the generator receives at least one SourcedInputStream (NULL if none actually transmitted)
  • helloworldgenerator prints a warning when it receives a non null source (as if several are received, it will apply several times to the JCM with the same params and this leads to error when creating the same class twice). The example has a data set to show this works :)
  • csv and json generators print a warning if the inputstream is null. They are designed to work against a source, so not receiving a source to work against may be an issue.

@glelouet
glelouet requested a review from phax September 8, 2026 00:21
@glelouet glelouet added bug patch patch-level change : no addition of feature, no breaking change. labels Sep 8, 2026
@glelouet

glelouet commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

it fails because the tests assume receiving a null source is correct for csv ; it's not.

2026-09-08T00:16:34.3983679Z [ERROR] com.helger.jcodemodel.plugin.generators.csv.CSVGeneratorTest.testNoSource -- Time elapsed: 0.018 s <<< ERROR!
2026-09-08T00:16:34.3985115Z java.lang.IllegalArgumentException: generator CSVGenerator needs to receive inputstream, received NullSourced[]
2026-09-08T00:16:34.3986233Z at com.helger.jcodemodel.plugin.generators.csv.CSVGenerator.loadSource(CSVGenerator.java:68)
2026-09-08T00:16:34.3987637Z at com.helger.jcodemodel.plugin.generators.csv.CSVGeneratorTest.testNoSource(CSVGeneratorTest.java:103)

@glelouet

glelouet commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

The issue with accepting null source for generators that need one is that it is not clear why it stopped producing classes : was the plugin disabled ?

Maybe we can warn instead of illegalargumentexception

@glelouet

glelouet commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Now it warns in the tests.

[main] WARN com.helger.jcodemodel.plugin.generators.csv.CSVGenerator - generator CSVGenerator did not receive a valid source, received NullSourced[] instead

and again, the helloworld warns too

[WARNING] generator HelloWorldGenerator2 received a source DirectSourced[inputStream=com.helger.base.io.nonblocking.NonBlockingByteArrayInputStream@4cbb217e] which is discarded. If multiple sources are provided, this may lead to runtime error

@phax
phax merged commit fe09f88 into phax:master Sep 8, 2026
4 checks passed
@phax

phax commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Sounds like a plan :)

@glelouet
glelouet deleted the ensure_transmit_nullsourcedinputstream branch September 8, 2026 20:57
@glelouet

glelouet commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

@phax also you may have noticed I don't appear twice anymore on the commits. I changed my mail address on my local machine to the noreply of git, instead of n@mo .

@phax

phax commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Okay cool - honestly I don't care about that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug patch patch-level change : no addition of feature, no breaking change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants