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

NPE when creating MongoItemReader using a builder without specifying sorting #4082

Closed
bodnarIQ opened this issue Mar 24, 2022 · 1 comment
Closed
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line in: infrastructure type: bug
Milestone

Comments

@bodnarIQ
Copy link

Bug description
When creating an instance of MongoItemReader using MongoItemReaderBuilder and no sorting is set, using the ItemReader results in NPE

Environment
Using dependency spring-boot-starter-batch, version 2.4.5

Steps to reproduce

    @Bean
    public ItemReader<Item> publicationReader(MongoOperations mongoOperations,
                                                     @Value("#{jobParameters['publicationId']}") String itemId) {
        return new MongoItemReaderBuilder<Item>()
                .name("currentItem")
                .template(mongoOperations)
                .collection("items")
                .targetType(Item.class)
                .pageSize(10)
                .query(query(where("_id").is(itemId)))
                //.sorts(new HashMap<>()) without this line it throws a NPE in MongoItemReader#convertToSort(Map<String, Sort.Direction> sorts); line 257
                .build();
    }

Expected behavior
When no sorting is provided, either default sorting should be used, or it should be validated, that sorting is set in MongoItemReaderBuilder#build() method. There is a validation when using queryString, but no one when using a Query object

Minimal Complete Reproducible example
See Steps to reproduce

@bodnarIQ bodnarIQ added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Mar 24, 2022
@fmbenhassine fmbenhassine added in: infrastructure for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line and removed status: waiting-for-triage Issues that we did not analyse yet labels Apr 5, 2022
@fmbenhassine fmbenhassine added this to the 5.0.0-M3 milestone Apr 5, 2022
@lcmarvin

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line in: infrastructure type: bug
Projects
None yet
Development

No branches or pull requests

3 participants