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

Unnecessary null checks in MongoConverters [DATAMONGO-2385] #3243

Closed
spring-projects-issues opened this issue Oct 2, 2019 · 1 comment
Closed

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Oct 2, 2019

M. Justin opened DATAMONGO-2385 and commented

Very, very minor thing, but I noticed that many of the converters in MongoConverters null check their inputs, returning null when the input value is null.

enum ObjectIdToStringConverter implements Converter<ObjectId, String> {
	INSTANCE;

	public String convert(ObjectId id) {
		return id == null ? null : id.toString();
	}
}

However, per the documentation of the implemented Converter interface, the input argument to the "convert" method will never be null:

Parameters:
source - the source object to convert, which must be an instance of S *(never null)*

Unless these converters are being used in an atypical way, these null checks therefore appear to be unnecessary


Referenced from: pull request #802

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

Successfully merging a pull request may close this issue.

None yet
2 participants