redhat-developer / redhat-developer/vscode-java

Unexpected dead code warning.

Open
#4,152 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

SessionCallback<List<Object>> obj;

    public void method() throws TransactionException {
        StringRedisTemplate stringRedisTemplate = resourcePool.template();
        var res = obj.execute(stringRedisTemplate);// @Nullable <K, V> T execute(RedisOperations<K, V> operations) throws DataAccessException;
        if (res == null) {
            System.out.println("Direct execution is not Dead Code");
        }
        List<Object> results = stringRedisTemplate.execute(new SessionCallback<List<Object>>() {
            @Override
            @Nullable
            public <K, V> List<Object> execute(@NonNull RedisOperations<K, V> operations) throws DataAccessException {
                operations.multi();
                return null;
            }
        });
        // @Override public <T> T StringRedisTemplate::execute(SessionCallback<T> session) {
        // 	...
        // 	try {
        // 		return session.execute(this); -> this is NullAble
        // 	} finally {
        // 		RedisConnectionUtils.unbindConnection(factory);
        // 	}
        // }
        if (results == null) {
            throw new TransactionException("Transaction failed, please retry") {
            };
        }
    }
Image

Minimal reproduce repo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduce repository linked in the issue and run the Java snippet that triggers the dead-code warning. Compare the warning with the shown nullable execution paths and attached diagnostic; done means the warning behavior is correctly resolved or clearly reproduced for the project maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.