ServiceBus: SpotBugs P2 part 3 of 3#3528
Conversation
...vicebus/src/main/java/com/microsoft/azure/servicebus/management/SubscriptionDescription.java
Outdated
Show resolved
Hide resolved
| sd.forwardDeadLetteredMessagesTo = fwdDlq.getNodeValue(); | ||
| } | ||
| break; | ||
| default: |
There was a problem hiding this comment.
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.SubscriptionDescriptionSerializer.parseFromEntry(String, Node) where default case is missing
| case "TransferDeadLetterMessageCount": | ||
| runtimeInfo.getMessageCountDetails().setTransferDeadLetterMessageCount(Long.parseLong(element.getFirstChild().getNodeValue())); | ||
| break; | ||
| default: |
There was a problem hiding this comment.
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.SubscriptionRuntimeInfoSerializer.parseFromEntry(String, Node) where default case is missing
...ure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/TopicDescription.java
Outdated
Show resolved
Hide resolved
...ure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/TopicDescription.java
Outdated
Show resolved
Hide resolved
| case "SupportOrdering": | ||
| td.supportOrdering = Boolean.parseBoolean(element.getFirstChild().getNodeValue()); | ||
| break; | ||
| default: |
There was a problem hiding this comment.
[SpotBugs-P2] Switch statement found in com.microsoft.azure.servicebus.management.TopicDescriptionSerializer.parseFromEntry(Node) where default case is missing
| case "TransferDeadLetterMessageCount": | ||
| topicRuntimeInfo.getMessageCountDetails().setTransferDeadLetterMessageCount(Long.parseLong(element.getFirstChild().getNodeValue())); | ||
| break; | ||
| default: |
There was a problem hiding this comment.
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.TopicRuntimeInfoSerializer.parseFromEntry(Node) where default case is missing
| final Properties properties = new Properties(); | ||
| InputStream clientPropInputStream = null; | ||
| try { | ||
| properties.load(ClientConstants.class.getResourceAsStream("/client.properties")); |
There was a problem hiding this comment.
[SpotBugs-P2]: com.microsoft.azure.servicebus.primitives.ClientConstants.getClientVersion() may fail to clean up java.io.InputStream
This method may fail to clean up (close, dispose of) a stream, database object, or other resource requiring an explicit cleanup operation.
In general, if a method opens a stream or other resource, the method should use a try/finally block to ensure that the stream or resource is cleaned up before the method returns.
This bug pattern is essentially the same as the OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE bug patterns, but is based on a different (and hopefully better) static analysis technique. We are interested is getting feedback about the usefulness of this bug pattern. For sending feedback, check:
contributing guideline
malinglist
In particular, the false-positive suppression heuristics for this bug pattern have not been extensively tuned, so reports about false positives are helpful to us.
See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for a description of the analysis technique.
| } | ||
|
|
||
| synchronized CompletableFuture<Void> initializeAsync() { | ||
| if (this.isInitialized) { |
There was a problem hiding this comment.
[SpotBugs-P2]: Inconsistent synchronization of com.microsoft.azure.servicebus.primitives.Controller.isInitialized; locked 50% of time
The fields of this class appear to be accessed inconsistently with respect to synchronization. This bug report indicates that the bug pattern detector judged that
The class contains a mix of locked and unlocked accesses,
The class is not annotated as javax.annotation.concurrent.NotThreadSafe,
At least one locked access was performed by one of the class's own methods, and
The number of unsynchronized field accesses (reads and writes) was no more than one third of all accesses, with writes being weighed twice as high as reads
A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe.
You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization.
Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held. Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.
|
Can one of the admins verify this patch? |
...vicebus/src/main/java/com/microsoft/azure/servicebus/management/SubscriptionDescription.java
Outdated
Show resolved
Hide resolved
conniey
left a comment
There was a problem hiding this comment.
Some changes with those null pointer fixes.
| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0 || | ||
| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) | ||
| { | ||
| if (defaultMessageTimeToLive != null |
There was a problem hiding this comment.
f (defaultMessageTimeToLive != null [](start = 9, length = 35)
May be you can change it to defaultMessageTimeToLive == null. That way it will throw a validation exception for the null case too. Can you do for every Description class where this null check is not done?
There was a problem hiding this comment.
Do you want to have all null checking for all setter methods that pass Object as parameters in the Description class if they don't handle NPE? Such as
public void setAuthorizationRules(List authorizationRules) {
this.authorizationRules = authorizationRules;
}
...c/main/java/com/microsoft/azure/servicebus/management/SubscriptionRuntimeInfoSerializer.java
Outdated
Show resolved
Hide resolved
| public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) { | ||
| if (defaultMessageTimeToLive != null && | ||
| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0 || | ||
| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) |
There was a problem hiding this comment.
Same null check as I suggested in my last comment.
...ebus/src/main/java/com/microsoft/azure/servicebus/management/TopicDescriptionSerializer.java
Outdated
Show resolved
Hide resolved
...ebus/src/main/java/com/microsoft/azure/servicebus/management/TopicRuntimeInfoSerializer.java
Outdated
Show resolved
Hide resolved
| public static <T> void completeFuture(CompletableFuture<T> future, T result) | ||
| { | ||
| public static <T> void completeFuture(CompletableFuture<T> future, T result) { | ||
| MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<T>(future, result)); |
There was a problem hiding this comment.
[](start = 73, length = 3)
Some places you removed the template type variable. Some places you didn't.
| { | ||
| this.timedOutUpdateStateRequestsDaemon = () -> { | ||
| try { | ||
| if (TRACE_LOGGER.isTraceEnabled()) { |
There was a problem hiding this comment.
if (TRACE_LOGGER.isTraceEnabled()) { [](start = 16, length = 36)
Why are you checking isTraceEnabled()? With SLF4J, you don't have to do this as long as you are using string formatting properly. Remove these isLevelEnabled calls.
| } finally { | ||
| if (clientPropInputStream != null) { | ||
| try { | ||
| clientPropInputStream.close(); |
There was a problem hiding this comment.
close the clientPropInputStream
…into ServiceBus-P2-Part3
…into ServiceBus-P2-Part3
|
@yvgopal There has no more spotbugs :). Can you review the changes? Thank you |
This PR contains:
(1) P2 SpotBugs: search [SpotBugs-P2] for detail explanation
(2) CheckStyles errors to these changed files