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

Null serialisation is not disabled when spring.gson.serialize-nulls is set to false #16332

Closed
wants to merge 1 commit into from
Closed

Null serialisation is not disabled when spring.gson.serialize-nulls is set to false #16332

wants to merge 1 commit into from

Conversation

zhanglc
Copy link

@zhanglc zhanglc commented Mar 27, 2019

fix: #13622

gson should not serialize null value when set spring.gson.serialize-nulls=false

test case:

       @Test
	public void serializeNullsFalse() {
		this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:false")
				.run((context) -> {
					Gson gson = context.getBean(Gson.class);
					assertThat(gson.serializeNulls()).isFalse();
				});
	}

gson should not serialize null value when set `spring.gson.serialize-nulls=false`
@zhanglc zhanglc changed the title fix: #13622 fix: #13622 gson should not serialize null value Mar 27, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 27, 2019
@zhanglc
Copy link
Author

zhanglc commented Mar 27, 2019

The code which I changed pass the Tests.

[INFO] Running org.springframework.boot.autoconfigure.gson.GsonAutoConfigurationTests
[INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.268 s - in org.springframework.boot.autoconfigure.gson.GsonAutoConfigurationTests

But some test failed from the master branch:

[INFO] Running org.springframework.boot.autoconfigure.ImportAutoConfigurationTests
[ERROR] Tests run: 5, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.155 s <<< FAILURE! - in org.springframework.boot.autoconfigure.ImportAutoConfigurationTests
[ERROR] multipleAnnotationsShouldMergeCorrectly(org.springframework.boot.autoconfigure.ImportAutoConfigurationTests)  Time elapsed: 0.088 s  <<< FAILURE!
java.lang.AssertionError: 

Actual and expected have the same elements but not in the same order, at index 0 actual element was:
  <"ConfigC">
whereas expected element was:
  <"ConfigA">

@wilkinsona
Copy link
Member

@zhanglc Thank you for your efforts to contribute to Spring Boot. They're much appreciated. Please note that there's no need to close a pull request and open a new one if you want to refine it. Doing so creates some extra noise for everyone watching the repository. Instead, please push new commits to the branch you have used for the pull request or amend an existing commit and force-push it.

@zhanglc
Copy link
Author

zhanglc commented Mar 27, 2019

@wilkinsona Sorry for that.

This is my first time contributing to the open source project and I am not too familiar with it.
The master branch can't build now.
What should I do next?

@wilkinsona
Copy link
Member

No problem. That failure seems to be unrelated to the proposed change so please don't worry about it. Master is building against snapshots of Spring Framework so it may be that a change there as caused the test to start to fail.

@snicoll snicoll self-assigned this Mar 29, 2019
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 29, 2019
@snicoll snicoll added this to the 2.1.4 milestone Mar 29, 2019
@snicoll snicoll changed the title fix: #13622 gson should not serialize null value Disable nulls serialization when spring.gson.serialize-nulls is set to false Mar 29, 2019
snicoll added a commit that referenced this pull request Mar 29, 2019
* pr/16332:
  Disable nulls serialization when serialize-nulls property is false
@snicoll snicoll closed this in 4d1717f Mar 29, 2019
@snicoll
Copy link
Member

snicoll commented Mar 29, 2019

@zhanglc thank you for making your first contribution to Spring Boot. This is now merged in 2.1.x and master.

@wilkinsona wilkinsona changed the title Disable nulls serialization when spring.gson.serialize-nulls is set to false Null serialisation is not disabled when spring.gson.serialize-nulls is set to false Mar 29, 2019
@zhanglc zhanglc deleted the gson-serialize-null-false-issue branch March 29, 2019 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spring.gson.serialize-nulls=false invalid
4 participants