comment stringlengths 1 45k | method_body stringlengths 23 281k | target_code stringlengths 0 5.16k | method_body_after stringlengths 12 281k | context_before stringlengths 8 543k | context_after stringlengths 8 543k |
|---|---|---|---|---|---|
You shouldn't use the pipe equal operator here. Just do standard assignment operation. | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported |= importClassPath.equals(CLIENT_LOOGER_PATH);
hasSlf4jImported |= importClassPath.startsWith(SLF4J);
hasLog4jimported |= importClassPa... | hasLog4jimported |= importClassPath.startsWith(LOG4J); | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class GoodLoggingCheck extends AbstractCheck {
private static final String CLIENT_LOOGER_PATH = "com.azure.core.util.logging.ClientLogger";
private static final String CLIENT_LOGGER = "ClientLogger";
private static final String SLF4J = "org.slf4j";
private static final String LOG4J = "org.apache.logging.log4j";
private... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
This can be condensed into `return typeName != null && typeName.equals(CLIENT_LOGGER);` | private boolean isTypeClientLogger(DetailAST varDefAST) {
DetailAST typeAST = varDefAST.findFirstToken(TokenTypes.TYPE);
DetailAST varNameAST = varDefAST.findFirstToken(TokenTypes.IDENT);
if (typeAST == null || varNameAST == null) {
return false;
}
DetailAST typeNameAST = typeAST.findFirstToken(TokenTypes.IDENT);
if (t... | return false; | private boolean isTypeClientLogger(DetailAST varDefAST) {
final DetailAST typeAST = varDefAST.findFirstToken(TokenTypes.TYPE);
if (typeAST == null) {
return false;
}
return TokenUtil.findFirstTokenByPredicate(typeAST, node ->
node.getType() == TokenTypes.IDENT && node.getText().equals(CLIENT_LOGGER)
).isPresent();
} | class name. Use ''%s.class'' instead of ''%s.class''", className, containerClassName));
}
break;
case TokenTypes.VARIABLE_DEF:
if (!hasClientLoggerImported || !isTypeClientLogger(ast)) {
return;
} | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
You don't use this varNameAST variable. | private boolean isTypeClientLogger(DetailAST varDefAST) {
DetailAST typeAST = varDefAST.findFirstToken(TokenTypes.TYPE);
DetailAST varNameAST = varDefAST.findFirstToken(TokenTypes.IDENT);
if (typeAST == null || varNameAST == null) {
return false;
}
DetailAST typeNameAST = typeAST.findFirstToken(TokenTypes.IDENT);
if (t... | DetailAST varNameAST = varDefAST.findFirstToken(TokenTypes.IDENT); | private boolean isTypeClientLogger(DetailAST varDefAST) {
final DetailAST typeAST = varDefAST.findFirstToken(TokenTypes.TYPE);
if (typeAST == null) {
return false;
}
return TokenUtil.findFirstTokenByPredicate(typeAST, node ->
node.getType() == TokenTypes.IDENT && node.getText().equals(CLIENT_LOGGER)
).isPresent();
} | class name. Use ''%s.class'' instead of ''%s.class''", className, containerClassName));
}
break;
case TokenTypes.VARIABLE_DEF:
if (!hasClientLoggerImported || !isTypeClientLogger(ast)) {
return;
} | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
Some of these case blocks are _really_ long. I'd put these in another method. | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported |= importClassPath.equals(CLIENT_LOOGER_PATH);
hasSlf4jImported |= importClassPath.startsWith(SLF4J);
hasLog4jimported |= importClassPa... | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class GoodLoggingCheck extends AbstractCheck {
private static final String CLIENT_LOOGER_PATH = "com.azure.core.util.logging.ClientLogger";
private static final String CLIENT_LOGGER = "ClientLogger";
private static final String SLF4J = "org.slf4j";
private static final String LOG4J = "org.apache.logging.log4j";
private... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... | |
You can log the error here directly instead of keeping track of the import and then logging the error in `LITERAL_CLASS`. Importing a different log package is sufficient to flag the issue. | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
for (final String logger : INVALID_LOG_SET) {
if (importClassP... | invalidLogger = logger; | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class GoodLoggingCheck extends AbstractCheck {
private static final String CLIENT_LOGGER_PATH = "com.azure.core.util.logging.ClientLogger";
private static final String CLIENT_LOGGER = "ClientLogger";
private static final String LOGGER_NAME_ERROR = "ClientLogger instance naming: use ''%s'' instead of ''%s'' for consiste... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
Was there an error when we tried to return the range object itself? I wonder why we had to construct a new one if Range is an immutable object. | public Range range() {
return (range == null) ? null : new Range(range.start(), range.end());
} | return (range == null) ? null : new Range(range.start(), range.end()); | public Range range() {
return range;
} | class SettingSelector {
private String key;
private String label;
private SettingFields[] fields;
private String acceptDatetime;
private Range range;
/**
* Creates a setting selector that will populate responses with all of the
* {@link ConfigurationSetting ConfigurationSetting's} properties and select all
* {@link Con... | class SettingSelector {
private String key;
private String label;
private SettingFields[] fields;
private String acceptDatetime;
private Range range;
/**
* Creates a setting selector that will populate responses with all of the
* {@link ConfigurationSetting ConfigurationSetting's} properties and select all
* {@link Con... |
Add a comment to clarify why you are using `containerClassName.length() - 6` as the end index. | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
final DetailAST elistToken = literalNewToken.findFirstToken(TokenTypes.ELIST);
final Detail... | containerClassName = containerClassName.substring(0, containerClassName.length() - 6); | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ |
You have most of your log messages up there, except for this one. | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
for (final String logger : INVALID_LOG_SET) {
if (importClassP... | log(ast, String.format("Do not use Java System class for logging. Use ClientLogger in ''%s'' instead.", CLIENT_LOGGER_PATH)); | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class GoodLoggingCheck extends AbstractCheck {
private static final String CLIENT_LOGGER_PATH = "com.azure.core.util.logging.ClientLogger";
private static final String CLIENT_LOGGER = "ClientLogger";
private static final String LOGGER_NAME_ERROR = "ClientLogger instance naming: use ''%s'' instead of ''%s'' for consiste... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
Are you sure you want to "add first"? If I have the structure: ``` class Foo { class Bar { class Baz { } } } ``` The stack would look like: ["Baz", "Bar", "Foo"] | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | classNameDeque.addFirst(ast.findFirstToken(TokenTypes.IDENT).getText()); | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
I would swap to using a Queue, and doing push, pop, rather than removing and adding from the front | public void leaveToken(DetailAST ast) {
if (ast.getType() == TokenTypes.CLASS_DEF) {
classNameDeque.pollFirst();
}
} | classNameDeque.pollFirst(); | public void leaveToken(DetailAST ast) {
if (ast.getType() == TokenTypes.CLASS_DEF) {
classNameDeque.pollFirst();
}
} | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
I see you are removing and adding from the front, only. You should switch to queues. | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | classNameDeque.addFirst(ast.findFirstToken(TokenTypes.IDENT).getText()); | public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IMPORT:
final String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
hasClientLoggerImported = hasClientLoggerImported || importClassPath.equals(CLIENT_LOGGER_PATH);
INVALID_LOGS.forEach(item -> {
if (importClassPath.start... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... | class name AST node
private Deque<String> classNameDeque = new ArrayDeque<>();
private static final Set<String> INVALID_LOGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"org.slf4j", "org.apache.logging.log4j", "java.util.logging"
)));
@Override
public int[] getDefaultTokens() {
return getRequiredTokens()... |
nit: The other error messages are constant strings up in the class, but this one is inline here. | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | log(exprToken, String.format("Not newing a ClientLogger with matching class name. Use ''%s.class'' instead of ''%s''", className, containerClassName)); | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ |
```suggestion // Add suffix of '.class' at the end of class name ``` | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ | |
I keep one-time used error message inline because it only used once. | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | log(exprToken, String.format("Not newing a ClientLogger with matching class name. Use ''%s.class'' instead of ''%s''", className, containerClassName)); | private void checkLoggerInstantiation(DetailAST literalNewToken) {
final DetailAST identToken = literalNewToken.findFirstToken(TokenTypes.IDENT);
if (identToken == null || !identToken.getText().equals(CLIENT_LOGGER)) {
return;
}
TokenUtil.findFirstTokenByPredicate(literalNewToken.findFirstToken(TokenTypes.ELIST), exprT... | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ | class name for the same class.
*
* @param literalNewToken LITERAL_NEW node
*/ |
There is only one case. Switch to an if statement. | public void leaveToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.CLASS_DEF:
if (!classNameStack.isEmpty()) {
classNameStack.removeLast();
}
break;
default:
break;
}
} | case TokenTypes.CLASS_DEF: | public void leaveToken(DetailAST token) {
if (token.getType() == TokenTypes.CLASS_DEF && !classNameStack.isEmpty()) {
classNameStack.removeLast();
}
} | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Do you mean "2. The method's return type should be the class itself" | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | |
I'd move this to line 118, you don't need to query the typeToken if the classNamestack is empty. | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE); | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
I think the logic here is wrong? If a method has parameters __and__ the number of parameters is 2, isPresent() will return `false`, the `!` would make it true, and this would silently return. | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Same with the logic here. I don't think its correct? | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | typeToken, c -> c.getType() == TokenTypes.IDENT && c.getText().equals(classNameStack.peekLast())).isPresent()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
@conniey , I believe the condition is fine. We want to make sure that a method definition has only 1 parameter, so return is hit if the childCount() is more or less than 1. But I agree it is confusing to have it as a negative logic. @mssfang what about removing the `!` and changing `== 1` to `!=1` .. So it is easy to... | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Yes. Thank you for the rewording. | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | |
@conniey, The logic here is to ensure we only have one parameter, PARAMETER_DEF, under PARAMETERS token. Logic should be fine. But yes sorry for the confusion of using negate operator !. @conniey @vhvb1989 | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (!TokenUtil.findFirstTokenByPredicate(methodDefToken,
c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) {
return;
}
final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE);
if (classNameStack.isEmpty()) ... | c -> c.getType() == TokenTypes.PARAMETERS && c.getChildCount() == 1).isPresent()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private Deque<String> classNameStack = new ArrayDeque<>();
/**
* Setter to specifies valid identifiers
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(String... avoidStartWords) {
Collections.a... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
The order of these checks seems inverted. should we be doing this classNameStack check _before_ doing the code in line 101? | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only has one parameter.");
}
if (classNameStac... | if (classNameStack.isEmpty()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Is it possible to have a method without any class? | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only has one parameter.");
}
if (classNameStac... | if (classNameStack.isEmpty()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Some of your error messages are in constants above, and others inline. I'd be consistent and have them in one place or another. Also: "A fluent method should only have one parameter." | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only has one parameter.");
}
if (classNameStac... | log(methodDefToken, "A fluent method should only has one parameter."); | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
what about ``` return TokenUtil.findFirstTokenByPredicate(modifiersToken, node -> TokenTypes.ANNOTATION == node.getType() && TokenUtil.findFirstTokenByPredicate(annotation -> TokenTypes.IDENT== annotation.getType() && anootation.getText().equals("Fluent")) ... | private boolean isFluentMethod(DetailAST methodDefToken) {
final DetailAST modifiersToken = methodDefToken.findFirstToken(TokenTypes.MODIFIERS);
for (DetailAST annotationToken = modifiersToken.getFirstChild(); annotationToken != null;
annotationToken = annotationToken.getNextSibling()) {
if (annotationToken.getType() !... | for (DetailAST annotationToken = modifiersToken.getFirstChild(); annotationToken != null; | private boolean isFluentMethod(DetailAST methodDefToken) {
final DetailAST modifiersToken = methodDefToken.findFirstToken(TokenTypes.MODIFIERS);
return TokenUtil.findFirstTokenByPredicate(modifiersToken,
annotationToken -> annotationToken.getType() == TokenTypes.ANNOTATION
&& TokenUtil.findFirstTokenByPredicate(annotat... | class is annotated with @Fluent, false otherwise.
*/ | class is annotated with @Fluent, false otherwise.
*/ |
IMO, this validation can be sent to a method. Just like what we have for previous `checkMethodNamePrefix(token)`. But no need to change if you want to keep it though XD | public void visitToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.CLASS_DEF:
classNameStack.addLast(token.findFirstToken(TokenTypes.IDENT).getText());
break;
case TokenTypes.METHOD_DEF:
if (!isFluentMethod(token)) {
return;
}
checkMethodNamePrefix(token);
if (token.findFirstToken(TokenTypes.LITERAL_T... | if (token.findFirstToken(TokenTypes.LITERAL_THROWS) != null) { | public void visitToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.CLASS_DEF:
classNameStack.addLast(token.findFirstToken(TokenTypes.IDENT).getText());
break;
case TokenTypes.METHOD_DEF:
if (!isFluentMethod(token)) {
return;
}
checkMethodNamePrefix(token);
if (token.findFirstToken(TokenTypes.LITERAL_T... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
Would the condition ever be satisfied? We are visiting a methodDefinition here, I believe we can't have a method definition out of a class definition. So, I think we would never get a case where no class name is in the stack while visiting a method definition. Looks like a safe ward to be 101% sure, but might be also a... | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only has one parameter.");
}
if (classNameStac... | if (classNameStack.isEmpty()) { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
we are not using the cool thing about a `Set` (constant access) here by doing a forEach() to iterate it. You might want to change this to use a simple Array like String[] and for a simple `for(String avoidStartWord : avoidStartWords)` | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only has one parameter.");
}
if (classNameStac... | avoidStartWords.forEach(avoidStartWord -> { | private void checkMethodNamePrefix(DetailAST methodDefToken) {
if (TokenUtil.findFirstTokenByPredicate(methodDefToken, parameters ->
parameters.getType() == TokenTypes.PARAMETERS && parameters.getChildCount() != 1).isPresent()) {
log(methodDefToken, "A fluent method should only have one parameter.");
}
final DetailAST ... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... | class names when traversals the AST tree.
*/
private final Deque<String> classNameStack = new ArrayDeque<>();
/**
* Adds words that methods in fluent classes should not be prefixed with.
* @param avoidStartWords the starting strings that should not start with in fluent method
*/
public final void setAvoidStartWords(Str... |
My guess is that the common case will not have form parameters. If this is true, then I suggest inverting the null check (to `if (formSubmmissions == null) return Collections.emptyList()`), instead of creating a new arraylist every time. | public Iterable<EncodedParameter> encodedFormParameters(Object[] swaggerMethodArguments) {
final List<EncodedParameter> result = new ArrayList<>();
if (formSubstitutions != null) {
final PercentEscaper escaper = UrlEscapers.QUERY_ESCAPER;
for (Substitution formSubstitution : formSubstitutions) {
final int parameterInde... | if (formSubstitutions != null) { | public Iterable<EncodedParameter> encodedFormParameters(Object[] swaggerMethodArguments) {
if (formSubstitutions == null) {
return Collections.emptyList();
}
final List<EncodedParameter> result = new ArrayList<>();
final PercentEscaper escaper = UrlEscapers.QUERY_ESCAPER;
for (Substitution formSubstitution : formSubsti... | class || returnValueWireType == DateTimeRfc1123.class) {
this.returnValueWireType = returnValueWireType;
} | class || returnValueWireType == DateTimeRfc1123.class) {
this.returnValueWireType = returnValueWireType;
} |
You don't need to worry about size here. | public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ConfigurationSetting)) {
return false;
}
ConfigurationSetting other = (ConfigurationSetting) o;
if (!Objects.equals(this.key, other.key)
|| !Objects.equals(this.label, other.label)
|| !Objects.equals(this.value, other.value)
|| !Object... | && Objects.equals(this.tags, other.tags); | public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ConfigurationSetting)) {
return false;
}
ConfigurationSetting other = (ConfigurationSetting) o;
if (!Objects.equals(this.key, other.key)
|| !Objects.equals(this.label, other.label)
|| !Objects.equals(this.value, other.value)
|| !Object... | class ConfigurationSetting {
/**
* The default label for configuration settings is the label, "\0".
* Users use this value when they want to explicitly reference a configuration setting that has no label.
* This gets URL encoded as "%00".
*/
public static final String NO_LABEL = "\0";
@JsonProperty(value = "key", requi... | class ConfigurationSetting {
/**
* The default label for configuration settings is the label, "\0".
* Users use this value when they want to explicitly reference a configuration setting that has no label.
* This gets URL encoded as "%00".
*/
public static final String NO_LABEL = "\0";
@JsonProperty(value = "key", requi... |
updated. Yes. The enabled spotbugs and checkstyle PR is closed but not merged. Because of the change for enabling the spotbugs and checkstyle is less line. The changes moved to here. | public static void cleanupAfterAllTest() throws ExecutionException, InterruptedException, IOException {
if (managementClient == null) {
return;
}
if(SessionTests.entityNameCreatedForAllTests != null)
{
managementClient.deleteQueueAsync(SessionTests.entityNameCreatedForAllTests).get();
}
managementClient.close();
} | { | public static void cleanupAfterAllTest() throws ExecutionException, InterruptedException, IOException {
if (managementClient != null) {
if (SessionTests.entityNameCreatedForAllTests != null) {
managementClient.deleteQueueAsync(SessionTests.entityNameCreatedForAllTests).get();
}
managementClient.close();
}
} | class SessionTests extends Tests {
private static String entityNameCreatedForAllTests = null;
private static String receiveEntityPathForAllTest = null;
private static ManagementClientAsync managementClient;
MessagingFactory factory;
IMessageSender sender;
IMessageSession session;
private String entityName;
String recei... | class SessionTests extends Tests {
private static String entityNameCreatedForAllTests = null;
private static String receiveEntityPathForAllTest = null;
private static ManagementClientAsync managementClient;
MessagingFactory factory;
IMessageSender sender;
IMessageSession session;
private String entityName;
String recei... |
This makes me cry. I would much rather accept the previous line of code, but I know it won't be easy to bend CheckStyle to our will here, so it's ok. | public void transportTypeAmqpWebSocketsWithProxyCreatesConnectionWithCorrectPorts() throws Exception {
int proxyPort = 8899;
ProxyServer proxyServer = ProxyServer.create("localhost", proxyPort);
proxyServer.start(throwable -> {
});
ProxySelector defaultProxySelector = ProxySelector.getDefault();
this.isProxySelectorInv... | }); | public void transportTypeAmqpWebSocketsWithProxyCreatesConnectionWithCorrectPorts() throws Exception {
int proxyPort = 8899;
ProxyServer proxyServer = ProxyServer.create("localhost", proxyPort);
proxyServer.start(throwable -> {
});
ProxySelector defaultProxySelector = ProxySelector.getDefault();
this.isProxySelectorInv... | class TransportTypeTest extends ApiTestBase {
private volatile boolean isProxySelectorInvoked = false;
@Test
public void transportTypeAmqpCreatesConnectionWithPort5671() throws Exception {
ConnectionStringBuilder builder = new ConnectionStringBuilder(TestContext.getConnectionString().toString());
builder.setTransportTy... | class TransportTypeTest extends ApiTestBase {
private volatile boolean isProxySelectorInvoked = false;
@Test
public void transportTypeAmqpCreatesConnectionWithPort5671() throws Exception {
ConnectionStringBuilder builder = new ConnectionStringBuilder(TestContext.getConnectionString().toString());
builder.setTransportTy... |
It looks like this file has tabs in it, rather than spaces, hence the odd indentation here. Please resolve this so that the code is indented correctly. | public static void deleteEntities() throws ExecutionException, InterruptedException, IOException {
if (managementClient == null) {
return;
}
managementClient.deleteQueueAsync(queuePath).get();
managementClient.deleteQueueAsync(sessionfulQueuePath).get();
managementClient.deleteTopicAsync(topicPath).get();
managementCli... | } | public static void deleteEntities() throws ExecutionException, InterruptedException, IOException {
if (managementClient != null) {
managementClient.deleteQueueAsync(queuePath).get();
managementClient.deleteQueueAsync(sessionfulQueuePath).get();
managementClient.deleteTopicAsync(topicPath).get();
managementClient.close(... | class ClientValidationTests extends ConfigValidateTestBase
{
private static final String ENTITY_NAME_PREFIX = "ClientValidationTests";
private static String queuePath;
private static String sessionfulQueuePath;
private static String topicPath;
private static String subscriptionPath;
private static String sessionfulSubs... | class ClientValidationTests extends TestBase {
private static final String ENTITY_NAME_PREFIX = "ClientValidationTests";
private static String queuePath;
private static String sessionfulQueuePath;
private static String topicPath;
private static String subscriptionPath;
private static String sessionfulSubscriptionPath;
... |
Eventually you'll enable spotbugs / checkstyle on here as well? I see braces on new lines, etc that can be fixed eventually. | public static void cleanupAfterAllTest() throws ExecutionException, InterruptedException, IOException {
if (managementClient == null) {
return;
}
if(SessionTests.entityNameCreatedForAllTests != null)
{
managementClient.deleteQueueAsync(SessionTests.entityNameCreatedForAllTests).get();
}
managementClient.close();
} | { | public static void cleanupAfterAllTest() throws ExecutionException, InterruptedException, IOException {
if (managementClient != null) {
if (SessionTests.entityNameCreatedForAllTests != null) {
managementClient.deleteQueueAsync(SessionTests.entityNameCreatedForAllTests).get();
}
managementClient.close();
}
} | class SessionTests extends Tests {
private static String entityNameCreatedForAllTests = null;
private static String receiveEntityPathForAllTest = null;
private static ManagementClientAsync managementClient;
MessagingFactory factory;
IMessageSender sender;
IMessageSession session;
private String entityName;
String recei... | class SessionTests extends Tests {
private static String entityNameCreatedForAllTests = null;
private static String receiveEntityPathForAllTest = null;
private static ManagementClientAsync managementClient;
MessagingFactory factory;
IMessageSender sender;
IMessageSession session;
private String entityName;
String recei... |
Changed to return just the range value | public Range range() {
return (range == null) ? null : new Range(range.start(), range.end());
} | return (range == null) ? null : new Range(range.start(), range.end()); | public Range range() {
return range;
} | class SettingSelector {
private String key;
private String label;
private SettingFields[] fields;
private String acceptDatetime;
private Range range;
/**
* Creates a setting selector that will populate responses with all of the
* {@link ConfigurationSetting ConfigurationSetting's} properties and select all
* {@link Con... | class SettingSelector {
private String key;
private String label;
private SettingFields[] fields;
private String acceptDatetime;
private Range range;
/**
* Creates a setting selector that will populate responses with all of the
* {@link ConfigurationSetting ConfigurationSetting's} properties and select all
* {@link Con... |
[SpotBugs-P1] Impossible downcast of toArray() result: : The toArray() of almost all collections return an Object[]. They can't really do anything else, since the Collection object has no reference to the declared generic type of the collection. | private void schedulePruningRequestResponseLockTokens() {
Timer.schedule(() -> {
Instant systemTime = Instant.now();
MessageReceiver.this.requestResponseLockTokensToLockTimesMap.entrySet().removeIf(entry -> entry.getValue().isBefore(systemTime));
}, Duration.ofSeconds(3600), TimerType.RepeatRun);
} | }, Duration.ofSeconds(3600), TimerType.RepeatRun); | private void schedulePruningRequestResponseLockTokens() {
Timer.schedule(() -> {
Instant systemTime = Instant.now();
Entry<UUID, Instant>[] copyOfEntries = (Entry<UUID, Instant>[]) MessageReceiver.this.requestResponseLockTokensToLockTimesMap.entrySet().toArray();
for (Entry<UUID, Instant> entry : copyOfEntries) {
if (e... | class MessageReceiver extends InitializableEntity implements IMessageReceiver, IMessageBrowser {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(MessageReceiver.class);
private static final int DEFAULT_PREFETCH_COUNT_PEEKLOCK = 0;
private static final int DEFAULT_PREFETCH_COUNT_RECEIVEANDDELETE = 0;
... | class MessageReceiver extends InitializableEntity implements IMessageReceiver, IMessageBrowser {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(MessageReceiver.class);
private static final int DEFAULT_PREFETCH_COUNT_PEEKLOCK = 0;
private static final int DEFAULT_PREFETCH_COUNT_RECEIVEANDDELETE = 0;
... |
[SpotBugs-P1] Reliance on default encoding: Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name o... | public String toString() {
return new String(txnId.array(), txnId.position(), txnId.limit(), UTF_8);
} | return new String(txnId.array(), txnId.position(), txnId.limit(), UTF_8); | public String toString() {
return new String(txnId.array(), txnId.position(), txnId.limit(), UTF_8);
} | class TransactionContext {
public static TransactionContext NULL_TXN = new TransactionContext(null, null);
private ByteBuffer txnId;
private ITransactionHandler txnHandler = null;
private MessagingFactory messagingFactory;
public TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory) {
this.txnId = txn... | class TransactionContext {
public static TransactionContext NULL_TXN = new TransactionContext(null, null);
private ByteBuffer txnId;
private ITransactionHandler txnHandler = null;
private MessagingFactory messagingFactory;
public TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory) {
this.txnId = txn... |
[SpotBugs-P1] Local variable is not read and used in any subsequent instruction | private static String normalizeForwardToAddress(String forwardTo, URI baseAddress) {
try {
new URI(forwardTo);
return forwardTo;
} catch (URISyntaxException e) {
return baseAddress.resolve(forwardTo).toString();
}
} | new URI(forwardTo); | private static String normalizeForwardToAddress(String forwardTo, URI baseAddress) {
try {
new URI(forwardTo);
return forwardTo;
} catch (URISyntaxException e) {
return baseAddress.resolve(forwardTo).toString();
}
} | class SubscriptionDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionDescriptionSerializer.class);
static String serialize(SubscriptionDescription subscriptionDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = newInstance();
DocumentBuilder d... | class SubscriptionDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionDescriptionSerializer.class);
static String serialize(SubscriptionDescription subscriptionDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = newInstance();
DocumentBuilder d... |
[SpotBugs-P1] Local variable is not read and used in any subsequent instruction | private static String normalizeForwardToAddress(String forwardTo, URI baseAddress) {
try {
new URL(forwardTo);
return forwardTo;
} catch (MalformedURLException e) {
return baseAddress.resolve(forwardTo).toString();
}
} | new URL(forwardTo); | private static String normalizeForwardToAddress(String forwardTo, URI baseAddress) {
try {
new URL(forwardTo);
return forwardTo;
} catch (MalformedURLException e) {
return baseAddress.resolve(forwardTo).toString();
}
} | class QueueDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static String serialize(QueueDescription queueDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... | class QueueDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static String serialize(QueueDescription queueDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... |
[SpotBugs-P1] Reliance on default encoding: Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. | public void onSendComplete(final Delivery delivery) {
DeliveryState outcome = delivery.getRemoteState();
final String deliveryTag = new String(delivery.getTag(), UTF_8);
TRACE_LOGGER.debug("Received ack for delivery. path:{}, linkName:{}, deliveryTag:{}, outcome:{}", CoreMessageSender.this.sendPath, this.sendLink.getNa... | final String deliveryTag = new String(delivery.getTag(), UTF_8); | public void onSendComplete(final Delivery delivery) {
DeliveryState outcome = delivery.getRemoteState();
final String deliveryTag = new String(delivery.getTag(), UTF_8);
TRACE_LOGGER.debug("Received ack for delivery. path:{}, linkName:{}, deliveryTag:{}, outcome:{}", CoreMessageSender.this.sendPath, this.sendLink.getNa... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... |
[SpotBugs-P1] Coding mistake: sendData is value in the map, it should use key class of map in remove() | private void processSendWork() {
synchronized (this.pendingSendLock) {
if (!this.isSendLoopRunning) {
this.isSendLoopRunning = true;
} else {
return;
}
}
TRACE_LOGGER.debug("Processing pending sends to '{}'. Available link credit '{}'", this.sendPath, this.linkCredit);
try {
if (!this.ensureLinkIsOpen().isDone()) {
ret... | this.pendingSendsData.remove(deliveryTag.getDeliveryTag()); | private void processSendWork() {
synchronized (this.pendingSendLock) {
if (!this.isSendLoopRunning) {
this.isSendLoopRunning = true;
} else {
return;
}
}
TRACE_LOGGER.debug("Processing pending sends to '{}'. Available link credit '{}'", this.sendPath, this.linkCredit);
try {
if (!this.ensureLinkIsOpen().isDone()) {
ret... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... |
[SpotBugs-P1] Reliance on default encoding: Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. | private void processSendWork() {
synchronized (this.pendingSendLock) {
if (!this.isSendLoopRunning) {
this.isSendLoopRunning = true;
} else {
return;
}
}
TRACE_LOGGER.debug("Processing pending sends to '{}'. Available link credit '{}'", this.sendPath, this.linkCredit);
try {
if (!this.ensureLinkIsOpen().isDone()) {
ret... | delivery = sendLinkCurrent.delivery(deliveryTag.getDeliveryTag().getBytes(UTF_8)); | private void processSendWork() {
synchronized (this.pendingSendLock) {
if (!this.isSendLoopRunning) {
this.isSendLoopRunning = true;
} else {
return;
}
}
TRACE_LOGGER.debug("Processing pending sends to '{}'. Available link credit '{}'", this.sendPath, this.linkCredit);
try {
if (!this.ensureLinkIsOpen().isDone()) {
ret... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... | class CoreMessageSender extends ClientEntity implements IAmqpSender, IErrorContextProvider {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(CoreMessageSender.class);
private static final String SEND_TIMED_OUT = "Send operation timed out";
private static final Duration LINK_REOPEN_TIMEOUT = Duration.... |
[SpotBugs-P1] Reliance on default encoding: Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. | private void runSendLoop() {
synchronized(this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while(this.sendLink != null && this.sendLink.getLocalState... | Delivery delivery = this.sendLink.delivery(UUID.randomUUID().toString().getBytes(UTF_8)); | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | public static Message convertAmqpMessageToBrokeredMessage(org.apache.qpid.proton.message.Message amqpMessage, byte[] deliveryTag) {
Message brokeredMessage;
Section body = amqpMessage.getBody();
if (body != null) {
if (body instanceof Data) {
Binary messageData = ((Data)body).getValue();
brokeredMessage = new Message(U... | default: | public static Message convertAmqpMessageToBrokeredMessage(org.apache.qpid.proton.message.Message amqpMessage, byte[] deliveryTag) {
Message brokeredMessage;
Section body = amqpMessage.getBody();
if (body != null) {
if (body instanceof Data) {
Binary messageData = ((Data)body).getValue();
brokeredMessage = new Message(U... | class MessageConverter {
public static org.apache.qpid.proton.message.Message convertBrokeredMessageToAmqpMessage(Message brokeredMessage) {
org.apache.qpid.proton.message.Message amqpMessage = Proton.message();
MessageBody body = brokeredMessage.getMessageBody();
if (body != null) {
if (body.getBodyType() == MessageBo... | class MessageConverter {
public static org.apache.qpid.proton.message.Message convertBrokeredMessageToAmqpMessage(Message brokeredMessage) {
org.apache.qpid.proton.message.Message amqpMessage = Proton.message();
MessageBody body = brokeredMessage.getMessageBody();
if (body != null) {
if (body.getBodyType() == MessageBo... |
Add final modifier to stay same as EventHubs has | public void onLinkLocalClose(Event event) {
final Link link = event.getLink();
if (link != null) {
TRACE_LOGGER.debug("local link close. linkName:{}", link.getName());
closeSession(link);
}
} | final Link link = event.getLink(); | public void onLinkLocalClose(Event event) {
final Link link = event.getLink();
if (link != null) {
TRACE_LOGGER.debug("local link close. linkName:{}", link.getName());
closeSession(link);
}
} | class BaseLinkHandler extends BaseHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(BaseLinkHandler.class);
private final IAmqpLink underlyingEntity;
public BaseLinkHandler(final IAmqpLink amqpLink) {
this.underlyingEntity = amqpLink;
}
@Override
@Override
public void onLinkRemoteClose(Event ... | class BaseLinkHandler extends BaseHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(BaseLinkHandler.class);
private final IAmqpLink underlyingEntity;
public BaseLinkHandler(final IAmqpLink amqpLink) {
this.underlyingEntity = amqpLink;
}
@Override
@Override
public void onLinkRemoteClose(Event ... |
[SpotBugs-P2] Null passed for non-null parameter of closeSession(Link) in com.microsoft.azure.servicebus.amqp.BaseLinkHandler.onLinkLocalClose(Event) This method call passes a null value for a non-null method parameter. Either the parameter is annotated as a parameter that should always be non-null, or analysis has sh... | public void onLinkLocalClose(Event event) {
final Link link = event.getLink();
if (link != null) {
TRACE_LOGGER.debug("local link close. linkName:{}", link.getName());
closeSession(link);
}
} | closeSession(link); | public void onLinkLocalClose(Event event) {
final Link link = event.getLink();
if (link != null) {
TRACE_LOGGER.debug("local link close. linkName:{}", link.getName());
closeSession(link);
}
} | class BaseLinkHandler extends BaseHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(BaseLinkHandler.class);
private final IAmqpLink underlyingEntity;
public BaseLinkHandler(final IAmqpLink amqpLink) {
this.underlyingEntity = amqpLink;
}
@Override
@Override
public void onLinkRemoteClose(Event ... | class BaseLinkHandler extends BaseHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(BaseLinkHandler.class);
private final IAmqpLink underlyingEntity;
public BaseLinkHandler(final IAmqpLink amqpLink) {
this.underlyingEntity = amqpLink;
}
@Override
@Override
public void onLinkRemoteClose(Event ... |
[SpotBugs-P2] Possible doublecheck on com.microsoft.azure.servicebus.amqp.SendLinkHandler.isFirstFlow in com.microsoft.azure.servicebus.amqp.SendLinkHandler.onLinkFlow(Event) This method may contain an instance of double-checked locking. This idiom is not correct according to the semantics of the Java memory model. ... | public void onLinkFlow(Event event) {
if (this.isFirstFlow.compareAndSet(true, false)) {
this.msgSender.onOpenComplete(null);
}
Sender sender = event.getSender();
this.msgSender.onFlow(sender.getRemoteCredit());
if (TRACE_LOGGER.isDebugEnabled()) {
TRACE_LOGGER.debug("onLinkFlow: linkName:{}, unsettled:{}, credit:{}", ... | } | public void onLinkFlow(Event event) {
if (this.isFirstFlow.compareAndSet(true, false)) {
this.msgSender.onOpenComplete(null);
}
Sender sender = event.getSender();
this.msgSender.onFlow(sender.getRemoteCredit());
TRACE_LOGGER.debug("onLinkFlow: linkName:{}, unsettled:{}, credit:{}", sender.getName(), sender.getUnsettled... | class SendLinkHandler extends BaseLinkHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SendLinkHandler.class);
private final IAmqpSender msgSender;
private AtomicBoolean isFirstFlow;
public SendLinkHandler(final IAmqpSender sender) {
super(sender);
this.msgSender = sender;
this.isFirstFlow =... | class SendLinkHandler extends BaseLinkHandler {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SendLinkHandler.class);
private final IAmqpSender msgSender;
private AtomicBoolean isFirstFlow;
public SendLinkHandler(final IAmqpSender sender) {
super(sender);
this.msgSender = sender;
this.isFirstFlow =... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static AuthorizationRule parseSasAuthRule(Element xEntry) {
SharedAccessAuthorizationRule rule = new SharedAccessAuthorizationRule();
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element =... | default: | private static AuthorizationRule parseSasAuthRule(Element xEntry) {
SharedAccessAuthorizationRule rule = new SharedAccessAuthorizationRule();
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element =... | class AuthorizationRuleSerializer {
static Element serializeRules(List<AuthorizationRule> authorizationRules, Document doc) throws ServiceBusException {
if (authorizationRules == null) {
return null;
}
Element rules = doc.createElementNS(ManagementClientConstants.SB_NS, "AuthorizationRules");
for (AuthorizationRule rul... | class AuthorizationRuleSerializer {
static Element serializeRules(List<AuthorizationRule> authorizationRules, Document doc) throws ServiceBusException {
if (authorizationRules == null) {
return null;
}
Element rules = doc.createElementNS(ManagementClientConstants.SB_NS, "AuthorizationRules");
for (AuthorizationRule rul... |
[SpotBugs-P2]: This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static NamespaceInfo parseFromEntry(Node xEntry) {
NamespaceInfo namespaceInfo = new NamespaceInfo();
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.... | default: | private static NamespaceInfo parseFromEntry(Node xEntry) {
NamespaceInfo namespaceInfo = new NamespaceInfo();
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.... | class NamespaceInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(NamespaceInfoSerializer.class);
static NamespaceInfo parseFromContent(String xml) throws ServiceBusException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentB... | class NamespaceInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(NamespaceInfoSerializer.class);
static NamespaceInfo parseFromContent(String xml) throws ServiceBusException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentB... |
[SpotBugs-P2] Possible null pointer dereference of autoDeleteOnIdle in com.microsoft.azure.servicebus.management.QueueDescription.setAutoDeleteOnIdle(Duration) There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code... | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle != null
&& autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | if (this.autoDeleteOnIdle != null | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle == null
|| autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
[SpotBugs-P2] Possible null pointer dereference of defaultMessageTimeToLive in com.microsoft.azure.servicebus.management.QueueDescription.setDefaultMessageTimeToLive(Duration) There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerExceptio... | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (this.defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
[SpotBugs-P2] Possible null pointer dereference of duplicationDetectionHistoryTimeWindow in com.microsoft.azure.servicebus.management.QueueDescription.setDuplicationDetectionHistoryTimeWindow(Duration) There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would gen... | public void setDuplicationDetectionHistoryTimeWindow(Duration duplicationDetectionHistoryTimeWindow) {
if (duplicationDetectionHistoryTimeWindow != null
&& (duplicationDetectionHistoryTimeWindow.compareTo(ManagementClientConstants.MIN_DUPLICATE_HISTORY_DURATION) < 0
|| duplicationDetectionHistoryTimeWindow.compareTo(Ma... | if (this.duplicationDetectionHistoryTimeWindow != null | public void setDuplicationDetectionHistoryTimeWindow(Duration duplicationDetectionHistoryTimeWindow) {
if (duplicationDetectionHistoryTimeWindow == null
|| (duplicationDetectionHistoryTimeWindow.compareTo(ManagementClientConstants.MIN_DUPLICATE_HISTORY_DURATION) < 0
|| duplicationDetectionHistoryTimeWindow.compareTo(Ma... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static QueueDescription parseFromEntry(Node xEntry) {
QueueDescription qd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | default: | private static QueueDescription parseFromEntry(Node xEntry) {
QueueDescription qd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | class QueueDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static String serialize(QueueDescription queueDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... | class QueueDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static String serialize(QueueDescription queueDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static QueueRuntimeInfo parseFromEntry(Node xEntry) {
QueueRuntimeInfo qd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | default: | private static QueueRuntimeInfo parseFromEntry(Node xEntry) {
QueueRuntimeInfo qd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | class QueueRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static QueueRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder... | class QueueRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(QueueDescriptionSerializer.class);
static QueueRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static RuleDescription parseFromEntry(Node xEntry) {
RuleDescription rd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch(element.getTagName()) {
case "t... | default: | private static RuleDescription parseFromEntry(Node xEntry) {
RuleDescription rd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch(element.getTagName()) {
case "t... | class RuleDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(RuleDescriptionSerializer.class);
static String serialize(RuleDescription ruleDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder =... | class RuleDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(RuleDescriptionSerializer.class);
static String serialize(RuleDescription ruleDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder =... |
[SpotBugs-P2] This method contains a switch statement where default case is missing. Usually you need to provide a default case. | private static Filter parseCorrelationFilterFromElement(Element filterElement) {
CorrelationFilter filter = new CorrelationFilter();
NodeList nList = filterElement.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (... | default: | private static Filter parseCorrelationFilterFromElement(Element filterElement) {
CorrelationFilter filter = new CorrelationFilter();
NodeList nList = filterElement.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (... | class RuleDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(RuleDescriptionSerializer.class);
static String serialize(RuleDescription ruleDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder =... | class RuleDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(RuleDescriptionSerializer.class);
static String serialize(RuleDescription ruleDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder =... |
You can still pass in `null` and have it set to the `this.defaultMessageTimeToLive` field. It just won't blow up here. But may in other parts of the code. You may want to ask the owner for what they want to do if the value is null. | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (this.defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
Same for the other fixes below. | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (this.defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
@yvgopal Do you have any idea? | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (this.defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... | class QueueDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ... |
[SpotBugs-P2]: .getDeliveryTag() may expose internal representation by returning MessageWithDeliveryTag.deliveryTag Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes... | public byte[] getDeliveryTag() {
if (this.deliveryTag == null) {
return null;
}
return Arrays.copyOf(this.deliveryTag, this.deliveryTag.length);
} | if (this.deliveryTag == null) { | public byte[] getDeliveryTag() {
if (this.deliveryTag == null) {
return null;
}
return Arrays.copyOf(this.deliveryTag, this.deliveryTag.length);
} | class MessageWithDeliveryTag {
private final Message message;
private final byte[] deliveryTag;
public MessageWithDeliveryTag(Message message, byte[] deliveryTag) {
this.message = message;
if (deliveryTag == null) {
this.deliveryTag = null;
} else {
this.deliveryTag = Arrays.copyOf(deliveryTag, deliveryTag.length);
}
}... | class MessageWithDeliveryTag {
private final Message message;
private final byte[] deliveryTag;
public MessageWithDeliveryTag(Message message, byte[] deliveryTag) {
this.message = message;
if (deliveryTag == null) {
this.deliveryTag = null;
} else {
this.deliveryTag = Arrays.copyOf(deliveryTag, deliveryTag.length);
}
}... |
[SpotBugs-P2] MessageWithDeliveryTag(Message, byte[]) may expose internal representation by storing an externally mutable object into MessageWithDeliveryTag.deliveryTag This code stores a reference to an externally mutable object into the internal representation of the object. If instances are accessed by untrusted c... | public MessageWithDeliveryTag(Message message, byte[] deliveryTag) {
this.message = message;
if (deliveryTag == null) {
this.deliveryTag = null;
} else {
this.deliveryTag = Arrays.copyOf(deliveryTag, deliveryTag.length);
}
} | this.message = message; | public MessageWithDeliveryTag(Message message, byte[] deliveryTag) {
this.message = message;
if (deliveryTag == null) {
this.deliveryTag = null;
} else {
this.deliveryTag = Arrays.copyOf(deliveryTag, deliveryTag.length);
}
} | class MessageWithDeliveryTag {
private final Message message;
private final byte[] deliveryTag;
public Message getMessage() {
return message;
}
public byte[] getDeliveryTag() {
if (this.deliveryTag == null) {
return null;
}
return Arrays.copyOf(this.deliveryTag, this.deliveryTag.length);
}
} | class MessageWithDeliveryTag {
private final Message message;
private final byte[] deliveryTag;
public Message getMessage() {
return message;
}
public byte[] getDeliveryTag() {
if (this.deliveryTag == null) {
return null;
}
return Arrays.copyOf(this.deliveryTag, this.deliveryTag.length);
}
} |
[SpotBugs-P2] Possible null pointer dereference of encodedPair in com.microsoft.azure.servicebus.primitives.RequestResponseLink$InternalSender.runSendLoop() on exception path A reference value which is null on some exception control path is dereferenced here. This may lead to a NullPointerException when the code is e... | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | if (encodedPair != null) { | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... |
What error message would make more sense or the existing error message LGTU? @yvgopal | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | TRACE_LOGGER.error("NULL_POINTER exception: encodedPair in RequestResponseLink"); | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... |
Unreachable path. It will never come here. Just exclude this from spotbugs. | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | TRACE_LOGGER.error("NULL_POINTER exception: encodedPair in RequestResponseLink"); | private void runSendLoop() {
synchronized (this.pendingSendsSyncLock) {
if (this.isSendLoopRunning) {
return;
} else {
this.isSendLoopRunning = true;
}
}
TRACE_LOGGER.debug("Starting requestResponseLink {} internal sender send loop", this.parent.linkPath);
try {
while (this.sendLink != null && this.sendLink.getLocalSta... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... | class InternalSender extends ClientEntity implements IAmqpSender {
private Sender sendLink;
private Receiver matchingReceiveLink;
private RequestResponseLink parent;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private AtomicInteger availableCredit;
private LinkedList<String>... |
[SpotBugs-P2]: Possible null pointer dereference of autoDeleteOnIdle | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle != null
&& autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | if (this.autoDeleteOnIdle != null | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle == null
|| autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... |
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.SubscriptionDescriptionSerializer.parseFromEntry(String, Node) where default case is missing | private static SubscriptionDescription parseFromEntry(String topicName, Node xEntry) {
SubscriptionDescription sd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
swit... | default: | private static SubscriptionDescription parseFromEntry(String topicName, Node xEntry) {
SubscriptionDescription sd = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
swit... | class SubscriptionDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionDescriptionSerializer.class);
static String serialize(SubscriptionDescription subscriptionDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = newInstance();
DocumentBuilder d... | class SubscriptionDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionDescriptionSerializer.class);
static String serialize(SubscriptionDescription subscriptionDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = newInstance();
DocumentBuilder d... |
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.SubscriptionRuntimeInfoSerializer.parseFromEntry(String, Node) where default case is missing | private static SubscriptionRuntimeInfo parseFromEntry(String topicPath, Node xEntry) {
SubscriptionRuntimeInfo runtimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)n... | default: | private static SubscriptionRuntimeInfo parseFromEntry(String topicPath, Node xEntry) {
SubscriptionRuntimeInfo runtimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)n... | class SubscriptionRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionRuntimeInfoSerializer.class);
static SubscriptionRuntimeInfo parseFromContent(String topicPath, String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFacto... | class SubscriptionRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionRuntimeInfoSerializer.class);
static SubscriptionRuntimeInfo parseFromContent(String topicPath, String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFacto... |
[SpotBugs-P2]: Possible null pointer dereference of autoDeleteOnIdle in com.microsoft.azure.servicebus.management.TopicDescription.setAutoDeleteOnIdle(Duration) | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle != null
&& autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | if (this.autoDeleteOnIdle != null | public void setAutoDeleteOnIdle(Duration autoDeleteOnIdle) {
if (autoDeleteOnIdle == null
|| autoDeleteOnIdle.compareTo(ManagementClientConstants.MIN_ALLOWED_AUTODELETE_DURATION) < 0) {
throw new IllegalArgumentException(
String.format("The value must be greater than %s.",
ManagementClientConstants.MIN_ALLOWED_AUTODELE... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... |
[SpotBugs-P2] Possible null pointer dereference of duplicationDetectionHistoryTimeWindow in com.microsoft.azure.servicebus.management.TopicDescription.setDuplicationDetectionHistoryTimeWindow(Duration) | public void setDuplicationDetectionHistoryTimeWindow(Duration duplicationDetectionHistoryTimeWindow) {
if (duplicationDetectionHistoryTimeWindow != null
&& (duplicationDetectionHistoryTimeWindow.compareTo(ManagementClientConstants.MIN_DUPLICATE_HISTORY_DURATION) < 0
|| duplicationDetectionHistoryTimeWindow.compareTo(Ma... | if (this.duplicationDetectionHistoryTimeWindow != null | public void setDuplicationDetectionHistoryTimeWindow(Duration duplicationDetectionHistoryTimeWindow) {
if (duplicationDetectionHistoryTimeWindow == null
|| (duplicationDetectionHistoryTimeWindow.compareTo(ManagementClientConstants.MIN_DUPLICATE_HISTORY_DURATION) < 0
|| duplicationDetectionHistoryTimeWindow.compareTo(Ma... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... |
[SpotBugs-P2] Switch statement found in com.microsoft.azure.servicebus.management.TopicDescriptionSerializer.parseFromEntry(Node) where default case is missing | private static TopicDescription parseFromEntry(Node xEntry) {
TopicDescription td = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | default: | private static TopicDescription parseFromEntry(Node xEntry) {
TopicDescription td = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTagName()) {
case... | class TopicDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicDescriptionSerializer.class);
static String serialize(TopicDescription topicDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... | class TopicDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicDescriptionSerializer.class);
static String serialize(TopicDescription topicDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... |
[SpotBugs-P2]: Switch statement found in com.microsoft.azure.servicebus.management.TopicRuntimeInfoSerializer.parseFromEntry(Node) where default case is missing | private static TopicRuntimeInfo parseFromEntry(Node xEntry) {
TopicRuntimeInfo topicRuntimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTag... | default: | private static TopicRuntimeInfo parseFromEntry(Node xEntry) {
TopicRuntimeInfo topicRuntimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
switch (element.getTag... | class TopicRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicRuntimeInfoSerializer.class);
static TopicRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder... | class TopicRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicRuntimeInfoSerializer.class);
static TopicRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder... |
I think this encounters the same issue I pointed out in #3527. You're fixing the potential NullPointerException, but consequently, you're allowing `null` to be a valid value to pass into this method. | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... |
Same with the others below. | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... |
>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? | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... |
>if (doc.getTagName() == "entry") { [](start = 12, length = 34) Change it to equals. | static SubscriptionRuntimeInfo parseFromContent(String topicPath, String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Elemen... | if (doc.getTagName() == "entry") { | static SubscriptionRuntimeInfo parseFromContent(String topicPath, String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Elemen... | class SubscriptionRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionRuntimeInfoSerializer.class);
private static SubscriptionRuntimeInfo parseFromEntry(String topicPath, Node xEntry) {
SubscriptionRuntimeInfo runtimeInfo = null;
NodeList nList = xEntry.getChildNodes(... | class SubscriptionRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SubscriptionRuntimeInfoSerializer.class);
private static SubscriptionRuntimeInfo parseFromEntry(String topicPath, Node xEntry) {
SubscriptionRuntimeInfo runtimeInfo = null;
NodeList nList = xEntry.getChildNodes(... |
Same null check as I suggested in my last comment. | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | ManagementClientConstants.MAX_ALLOWED_TTL, | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... | class TopicDescription {
Duration duplicationDetectionHistoryTimeWindow = ManagementClientConstants.DEFAULT_HISTORY_DEDUP_WINDOW;
String path;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
String userMetadata = null;
long ... |
>f (doc.getTagName() == "entry") { [](start = 13, length = 33) Change it to equals. | static TopicDescription parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Element doc = dom.getDocumentEl... | if (doc.getTagName() == "entry") { | static TopicDescription parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Element doc = dom.getDocumentEl... | class TopicDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicDescriptionSerializer.class);
static String serialize(TopicDescription topicDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... | class TopicDescriptionSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicDescriptionSerializer.class);
static String serialize(TopicDescription topicDescription) throws ServiceBusException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuild... |
> if (doc.getTagName() == "entry") { [](start = 11, length = 35) Change it to equals. | static TopicRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Element doc = dom.getDocumentEl... | if (doc.getTagName() == "entry") { | static TopicRuntimeInfo parseFromContent(String xml) throws MessagingEntityNotFoundException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(new ByteArrayInputStream(xml.getBytes("utf-8")));
Element doc = dom.getDocumentEl... | class TopicRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicRuntimeInfoSerializer.class);
private static TopicRuntimeInfo parseFromEntry(Node xEntry) {
TopicRuntimeInfo topicRuntimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength();... | class TopicRuntimeInfoSerializer {
private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(TopicRuntimeInfoSerializer.class);
private static TopicRuntimeInfo parseFromEntry(Node xEntry) {
TopicRuntimeInfo topicRuntimeInfo = null;
NodeList nList = xEntry.getChildNodes();
for (int i = 0; i < nList.getLength();... |
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<AuthorizationRule> authorizationRules) { this.authorizationRules = authorizationRules; } | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive != null
&& (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | if (defaultMessageTimeToLive != null | public void setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) {
if (defaultMessageTimeToLive == null
|| (defaultMessageTimeToLive.compareTo(ManagementClientConstants.MIN_ALLOWED_TTL) < 0
|| defaultMessageTimeToLive.compareTo(ManagementClientConstants.MAX_ALLOWED_TTL) > 0)) {
throw new IllegalArgumentExcept... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... | class SubscriptionDescription {
private String topicPath;
private String subscriptionName;
Duration lockDuration = ManagementClientConstants.DEFAULT_LOCK_DURATION;
Duration defaultMessageTimeToLive = ManagementClientConstants.MAX_DURATION;
Duration autoDeleteOnIdle = ManagementClientConstants.MAX_DURATION;
int maxDeliv... |
[SpotBugs-P3] Exceptional return value of java.util.concurrent.ExecutorService.submit(Runnable) ignored in com.microsoft.azure.servicebus.primitives.RequestResponseLink$InternalReceiver.onReceiveComplete(Delivery) | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | try { | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... |
The checkstyle complains: '{' is not followed by whitespace. '}' is not preceded with whitespace. Do we still want to have a new line for the closing bracket '}' | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | } catch (MessagingEntityNotFoundException e) { } | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... |
[SpotBugs-P3] Exceptional return value of java.util.concurrent.ExecutorService.submit(Runnable) ignored in com.microsoft.azure.servicebus.primitives.AsyncUtil.run(Runnable) | public static void run(Runnable runnable) {
try {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} catch (RejectedExecutionException | NullPointerException e) {
e.printStackTrace();
}
} | try { | public static void run(Runnable runnable) {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... |
Is there any logger? Should check with the service team to ask if this behaviour change is OK with them. | public static void run(Runnable runnable) {
try {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} catch (RejectedExecutionException | NullPointerException e) {
e.printStackTrace();
}
} | try { | public static void run(Runnable runnable) {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... |
Should double check with service team if this is what they want to do with those exceptions. | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | try { | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... |
No longer an issue. Will suppress it. | public static void run(Runnable runnable) {
try {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} catch (RejectedExecutionException | NullPointerException e) {
e.printStackTrace();
}
} | try { | public static void run(Runnable runnable) {
MessagingFactory.INTERNAL_THREAD_POOL.submit(runnable);
} | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... | class AsyncUtil {
public static <T> boolean completeFutureAndGetStatus(CompletableFuture<T> future, T result) {
try {
return MessagingFactory.INTERNAL_THREAD_POOL.submit(new CompleteCallable<>(future, result)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return false;
}
}
public s... |
No longer an issue. Will suppress it. | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | try { | public void onReceiveComplete(Delivery delivery) {
Message responseMessage;
try {
responseMessage = Util.readMessageFromDelivery(this.receiveLink, delivery);
delivery.disposition(Accepted.getInstance());
delivery.settle();
} catch (Exception e) {
TRACE_LOGGER.warn("Reading message from delivery failed with unexpected e... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... | class InternalReceiver extends ClientEntity implements IAmqpReceiver {
private RequestResponseLink parent;
private Receiver receiveLink;
private Sender matchingSendLink;
private CompletableFuture<Void> openFuture;
private CompletableFuture<Void> closeFuture;
private int linkGeneration;
protected InternalReceiver(String... |
I'm surprised there isn't a check style about this not being on a new line and the ones below. If so, I'd fix these in this PR. | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | } catch (MessagingEntityNotFoundException e) { } | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... |
Well, if there are no more checkstyle issues on that line. It's all good. I was confused because it complained about: ```java Workitem() {} ``` And one of your PRs changed it to: ```java WorkItem() { } ``` | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | } catch (MessagingEntityNotFoundException e) { } | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... |
Both solve the CheckStyle error. Which one you would prefer to change to? I can change it to stay consistency | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | } catch (MessagingEntityNotFoundException e) { } | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... |
No worries. As long as checkstyle issue no longer shows up. :) | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | } catch (MessagingEntityNotFoundException e) { } | public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) { }
try {
Utils.completeFuture(this.managementClientAsync.getTop... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... | class ManagementTests extends TestBase {
private ManagementClientAsync managementClientAsync;
@Before
public void setup() {
URI namespaceEndpointURI = TestUtils.getNamespaceEndpointURI();
ClientSettings managementClientSettings = TestUtils.getManagementClientSettings();
managementClientAsync = new ManagementClientAsync... |
Move this inline to a ternary operator rather than if / else | public HttpPipeline build() {
if (httpClient == null) {
return new HttpPipeline(HttpClient.createDefault(), pipelinePolicies);
} else {
return new HttpPipeline(httpClient, pipelinePolicies);
}
} | } | public HttpPipeline build() {
List<HttpPipelinePolicy> policies = (pipelinePolicies == null) ? new ArrayList<>() : pipelinePolicies;
HttpClient client = (httpClient == null) ? HttpClient.createDefault() : httpClient;
return new HttpPipeline(client, policies);
} | class HttpPipelineBuilder {
private HttpClient httpClient;
private List<HttpPipelinePolicy> pipelinePolicies = new ArrayList<>();
HttpPipelineBuilder() {
}
/**
* Creates a {@link HttpPipeline} based on options set in the Builder. Every time {@code build()} is
* called, a new instance of {@link HttpPipeline} is created.... | class HttpPipelineBuilder {
private HttpClient httpClient;
private List<HttpPipelinePolicy> pipelinePolicies;
HttpPipelineBuilder() {
}
/**
* Creates a {@link HttpPipeline} based on options set in the Builder. Every time {@code build()} is
* called, a new instance of {@link HttpPipeline} is created.
*
* If HttpClient i... |
This is still not right! It might be that we have packages under the implementation package, e.g. `com.azure.implementation.logging` | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.endsWith(DOT_IMPLEMENTATION);
return;
} else {
if (th... | this.isImplPackage = packageName.endsWith(DOT_IMPLEMENTATION); | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... |
It would be nice to work through this code and replace the anonymous inner classes with lambdas. | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient() {
@Override
public Mono<HttpResponse> send(HttpRequest request) {
return Mono.empty();
}
})
.addPolicy(new HostPolicy(host))
.addPolicy((context, next) -> {
assertEquals(expectedU... | }) | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient())
.policies(new HostPolicy(host),
(context, next) -> {
assertEquals(expectedUrl, context.httpRequest().url().toString());
return next.process();
})
.build();
} | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... |
I made the MockHttpClient non-abstract and overrode the send method to return a no-op. | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient() {
@Override
public Mono<HttpResponse> send(HttpRequest request) {
return Mono.empty();
}
})
.addPolicy(new HostPolicy(host))
.addPolicy((context, next) -> {
assertEquals(expectedU... | }) | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient())
.policies(new HostPolicy(host),
(context, next) -> {
assertEquals(expectedUrl, context.httpRequest().url().toString());
return next.process();
})
.build();
} | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... |
Issue #3674 written to track the cleanup of these anonymous inner classes. | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient() {
@Override
public Mono<HttpResponse> send(HttpRequest request) {
return Mono.empty();
}
})
.addPolicy(new HostPolicy(host))
.addPolicy((context, next) -> {
assertEquals(expectedU... | }) | private static HttpPipeline createPipeline(String host, String expectedUrl) {
return HttpPipeline.builder()
.httpClient(new MockHttpClient())
.policies(new HostPolicy(host),
(context, next) -> {
assertEquals(expectedUrl, context.httpRequest().url().toString());
return next.process();
})
.build();
} | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... | class HostPolicyTests {
@Test
public void withNoPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeline.send(createHttpRequest("ftp:
}
@Test
public void withPort() throws MalformedURLException {
final HttpPipeline pipeline = createPipeline("localhost", "ftp:
pipeli... |
updated with a regular expression pattern match: private static final String IMPL_PACKAGE_REGULAR_EXPR = "^com\\.azure(\\..*)+\\.implementation(\\..*)*"; | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.endsWith(DOT_IMPLEMENTATION);
return;
} else {
if (th... | this.isImplPackage = packageName.endsWith(DOT_IMPLEMENTATION); | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... |
Rather than a regular expression, just check if the packageName.contains(".implementation") - far easier to read and far less likely to introduce bugs. | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = Pattern.matches(IMPL_PACKAGE_REGULAR_EXPR, packageName);
return;
... | this.isImplPackage = Pattern.matches(IMPL_PACKAGE_REGULAR_EXPR, packageName); | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... |
I don't like this approach of looking through the import list. It means you might miss fully-qualified class references to implementation classes. I would much rather you inspect the type in the `METHOD_DEF` branch down directly and not have the `implementationClassSet` collection at all. | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | implementationClassSet.add(className); | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... |
If you are unable to find a way to do this, just leave the code as is and we can return to it later | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | implementationClassSet.add(className); | public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (th... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... | class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";
private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();
@Overr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.