Skip to content

ServiceBus: SpotBugs P3 2 of 3#3557

Merged
mssfang merged 8 commits intoAzure:masterfrom
mssfang:ServiceBus-P3-Two
May 16, 2019
Merged

ServiceBus: SpotBugs P3 2 of 3#3557
mssfang merged 8 commits intoAzure:masterfrom
mssfang:ServiceBus-P3-Two

Conversation

@mssfang
Copy link
Contributor

@mssfang mssfang commented May 6, 2019

PR includes

(1) P3 SpotBugs: search with using [SpotBugs-P3]
(2) some checkstyles fixes to these files

@mssfang mssfang added Service Bus Client This issue points to a problem in the data-plane of the library. labels May 6, 2019
@mssfang mssfang requested review from conniey and yvgopal May 6, 2019 22:19
@mssfang mssfang self-assigned this May 6, 2019
{
this.retryCounts.put(clientId, 0);
}
public void resetRetryCount(String clientId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs-P3]
Sequence of calls to java.util.concurrent.ConcurrentHashMap may not be atomic in com.microsoft.azure.servicebus.primitives.RetryPolicy.resetRetryCount(String)

}

builder.append(exception.getMessage());
if (exception.getStackTrace() != null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs-P3]
Redundant nullcheck of Throwable.getStackTrace(), which is known to be non-null in com.microsoft.azure.servicebus.primitives.ExceptionUtil.toStackTraceString(Throwable, String)

{
if (innerException != null) {
builder.append("Cause: " + innerException.getMessage());
if (innerException.getStackTrace() != null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs-P3]
Redundant nullcheck of Throwable.getStackTrace(), which is known to be non-null in com.microsoft.azure.servicebus.primitives.ExceptionUtil.toStackTraceString(Throwable, String)

if (this.requestResponseLockTokensToLockTimesMap.containsKey(lockToken)) {
this.requestResponseLockTokensToLockTimesMap.put(lockToken, lockedUntilUtc);
}
this.requestResponseLockTokensToLockTimesMap.computeIfPresent(lockToken, (k, v) -> lockedUntilUtc);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs-P3]

Sequence of calls to java.util.concurrent.ConcurrentHashMap may not be atomic in com.microsoft.azure.servicebus.MessageReceiver.lambda$renewMessageLockBatchAsync$20(UUID[], Collection)

public class AmqpException extends Exception {
private static final long serialVersionUID = -750417419234273714L;
private ErrorCondition errorCondition;
private transient ErrorCondition errorCondition;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs-P3]
This Serializable class defines a non-primitive instance field which is neither transient, Serializable, or java.lang.Object, and does not appear to implement the Externalizable interface or the readObject() and writeObject() methods. Objects of this class will not be deserialized correctly if a non-Serializable object is stored in this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ErrorCondition already not serializable, Ignore it with using transient modifier to suppress the SpotBugs error

@azuresdkci
Copy link
Contributor

Can one of the admins verify this patch?


public class ReceiverErrorContext extends ErrorContext
{
private static final long serialVersionUID = -8154706630781986787L;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs]
Since ServiceBusException has serialVersionUID, it means it needs to implement Serializable. Change the ErrorContext to implements Serializable cause all its sub-extended class to have the serialVersionUID

{
abstract class ErrorContext implements Serializable {

private static final long serialVersionUID = -6342329018037308640L;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs]
Since ServiceBusException has serialVersionUID, it means it needs to implement Serializable. Change the ErrorContext to implements Serializable cause all its sub-extended class to have the serialVersionUID


public class SenderErrorContext extends ErrorContext
{
private static final long serialVersionUID = -8426189357575601244L;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SpotBugs]
Since ServiceBusException has serialVersionUID, it means it needs to implement Serializable. Change the ErrorContext to implements Serializable cause all its sub-extended class to have the serialVersionUID

Copy link
Member

@conniey conniey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Should pass the try {} catch changes with the service team. In case they want to log those errors rather than print a stack trace.

Copy link
Member

@conniey conniey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment about talking to the service team about that behaviour change.

Copy link
Member

@yvgopal yvgopal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mssfang mssfang merged commit b59d9c0 into Azure:master May 16, 2019
@mssfang mssfang deleted the ServiceBus-P3-Two branch May 16, 2019 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client This issue points to a problem in the data-plane of the library. Service Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments