Skip to content

NPE in Debug Mode #4

@dengizik

Description

@dengizik

Hi,

first thanks for this nice implementation. I faced an issue and wanted to inform you about that.

In JpaSpecificationExecutorWithProjectionImpl:

private <R> Page<R> readPageWithProjection(Specification<T> spec, Class<R> projectionType, Pageable pageable, TypedQuery<T> query) {
        if (log.isDebugEnabled()) {
            query.getHints().forEach((key, value) -> {
                log.info("apply query hints -> {} : {}", key, value);
            });
        }

        Page<T> result = pageable == null ? new PageImpl(query.getResultList()) : this.readPage(query, this.getDomainClass(), pageable, spec);
        return ((Page)result).map((item) -> {
            return this.projectionFactory.createProjection(projectionType, item);
        });
    }

if (log.isDebugEnabled()) should be
if (log.isDebugEnabled() && !query.getHints.isEmpty())

There is no logical relationship between being in debug mode and having queryhints, at least I don't know. If we leave the code like this, it throws NPE in debug mode. I solved the problem by going out of debug mode.

Regards,
Deniz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions