Rule java:S1854 Recognition exception!

rule java:S1854 Recognition exception!

  • Operating system: win11
  • SonarLint plugin version: 10.3.0.77475
  • Programming language you’re coding in: java
  • idea 2023.3.3

My exception code is as follows. But I can’t reproduce the bug after I restarted my computer today.

@SuppressWarnings({ "java:S110" })
public class SecurityGrpcRemoteResourceClientInterceptor implements ClientInterceptor {

	private final Metadata.Key<String> authorizationKey;

	public SecurityGrpcRemoteResourceClientInterceptor(SecurityGrpcProperties properties) {
		this.authorizationKey = properties.authorizationKey();
	}

	@Override
	public <S, R> ClientCall<S, R> interceptCall(MethodDescriptor<S, R> method, CallOptions callOptions, Channel next) {
		ClientCall<S, R> call = next.newCall(method, callOptions);
		return new ForwardingClientOnCall<>(call) {
			@Override
			public void onStartBefore(Listener<R> responseListener, Metadata headers) {
				SecurityToken securityToken = SecurityTokenHolder.get();
				if (securityToken != null && securityToken.isAvailable()) {
					headers.put(authorizationKey, securityToken.getRaw());
				}
			}
		};
	}

}

Hey there.

I’ve moved your post to the section on reporting false-positives.

Can you please update your post with a text-based code sample where the issue can be reproduced? Thanks!