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

[BUG][Java][okhttp] POST request with an empty body results in a NullPointerException #11833

Closed
5 of 6 tasks
pg-fine opened this issue Mar 8, 2022 · 6 comments
Closed
5 of 6 tasks

Comments

@pg-fine
Copy link

pg-fine commented Mar 8, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Sending a POST request with an empty body results in a NullPointerException.
This issue exists since version 5.3.1.

Unexpected exception thrown: java.lang.NullPointerException: Parameter specified as non-null is null: method okhttp3.MediaType$Companion.parse, parameter $this$toMediaTypeOrNull
org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.NullPointerException: Parameter specified as non-null is null: method okhttp3.MediaType$Companion.parse, parameter $this$toMediaTypeOrNull
openapi-generator version

OpenAPI 5.4.0 and OpenAPI 5.3.1

OpenAPI declaration file content or url

see https://github.com/pg-fine/openapi-post-empty-body-bug

Generation Details

see https://github.com/pg-fine/openapi-post-empty-body-bug

Steps to reproduce

see https://github.com/pg-fine/openapi-post-empty-body-bug

Related issues/PRs

4ecceb1

"* remove default content-type in java okhttp client" is the reason for this bug

Suggest a fix

add a default content-type or allow empty request bodies with empty content-types.

@wing328
Copy link
Member

wing328 commented Mar 8, 2022

add a default content-type or allow empty request bodies with empty content-types.

I prefer the latter. May I know if you can help contribute a fix for it?

@pg-fine
Copy link
Author

pg-fine commented Mar 9, 2022

I prefer the latter. May I know if you can help contribute a fix for it?

I also prefer the latter. My first suggestion would only be a quick fix and not solve the problem per se.
Unfortunately, I have no idea how to fix this correctly since I have no overview of all implications a change would bring.

@QuyetVV2
Copy link

QuyetVV2 commented Aug 2, 2022

Hi there, did the problem resolved ?

@codemolition22
Copy link

Hello, is there already a new status regarding this issue?

@fileme
Copy link

fileme commented Jan 19, 2023

This issue is resolved in 6.2.0.
pg-fine/openapi-post-empty-body-bug#1

@pg-fine
Copy link
Author

pg-fine commented Jan 19, 2023

Thanks for your help @fileme !

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

No branches or pull requests

5 participants