当我在此代码上运行FindBugs时,它报告没有问题.
boolean _closed = false;
public void m1(@Nullable String text) {
if(_closed)
return;
System.out.println(text.toLowerCase());
}
Run Code Online (Sandbox Code Playgroud)
虽然在这里找到了预期的问题:
public void m1(@Nullable String text) {
System.out.println(text.toLowerCase()); // FindBugs: text must be nonnull but is marked as nullable
}
Run Code Online (Sandbox Code Playgroud)
为什么在第一种情况下会失败?
We are using a 3 site, 3 nodes per site Cassandra 1.1.12 cluster that has 8GB ram allocated per node. We have been seeing long GC pauses on nodes periodically and that is messing with our applications realtime requirements. The systems we run on are 8 core systems with 24GB of ram.
We've been seeing 120+ second pauses where it does a stop the world GC.
We are running with these flags on JDK 1.7.0_04
-XX:+UseThreadPriorities
-XX:ThreadPriorityPolicy=42
-Xms8G
-Xmx8G
-Xmn1600M …Run Code Online (Sandbox Code Playgroud) 我有本地和全局 gradle.properties,需要全局一个来配置代理,但它也包含其他参数,想知道如果为相同的设置指定不同的值会发生什么,哪些文件将具有优先级,或者可能是它们它们是如何合并的?
我的全球 gradle.properties
systemProp.http.proxyHost=hostname
systemProp.http.proxyPort=8080
systemProp.http.proxyPassword=password
org.gradle.parallel=false
Run Code Online (Sandbox Code Playgroud)
我本地的 gradle.properties
android.useDeprecatedNdk=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4096M
Run Code Online (Sandbox Code Playgroud)
例如,org.gradle.parallel将使用哪个?
在编译以下使用Lombok自动生成getter和setter的类时,Checkstyle会抛出一个编译错误:
实用程序类不应具有公共或默认构造函数
@Getter
@Setter
public class foo {
private String type;
private int value;
}
Run Code Online (Sandbox Code Playgroud)
当Checkstyle不遵循checkstyle文档中指定的实用程序类定义时,为什么Checkstyle将上面的类分类为实用程序类?即仅包含静态方法或字段的类.checkstyle是解析默认的源文本文件还是lombok生成的源文件?
当我在Windows 8.1上运行cobertura-maven-plugin时配置冗长(用于禁止项目中的任何覆盖率下降)cobertura:check目标失败并出现错误The command line is too long.
问题可能与命令提示符(Cmd.exe)命令行字符串限制有关,因为当我限制提供给Cobertura的配置量时它会消失.而且,它在Linux上运行良好.
我怎样才能克服这个问题?
登录调试级别:
[DEBUG] Executing command line:
[DEBUG] cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_25\jre\bin\java" net.sourceforge.cobertura.check.CheckCoverageMain --datafile C:\IdeaProjects\checkstyle\target\cobertura\cobertura.ser --branch 100 --line 100 --totalbranch 82 --totalline 90 --regex .*.checks.UncommentedMainCheck:88:83 --regex .*.checks.indentation.MethodCallLineWrapHandler:0:0 --regex .*.checks.indentation.ImportHandler:87:50 --regex .*.checks.imports.Guard:100:86 --regex .*.checks.sizes.AnonInnerLengthCheck:92:100 --regex .*.checks.DeclarationCollector:100:94 --regex .*.checks.whitespace.ParenPadCheck:95:86 --regex .*.TreeWalker:91:92 --regex .*.checks.naming.AbstractTypeParameterNameCheck:83:75 --regex .*.checks.naming.LocalVariableNameCheck:100:94 --regex .*.api.SeverityLevelCounter:76:50 --regex .*.checks.indentation.ForHandler:95:75 --regex .*.checks.regexp.RegexpMultilineCheck:76:100 --regex com.puppycrawl.tools.checkstyle.Utils:93:85 --regex .*.checks.coding.VariableDeclarationUsageDistanceCheck:97:90 --regex .*.checks.imports.ImportControlLoader:88:72 --regex .*.api.LocalizedMessage:81:66 --regex .*.api.FileContents:94:96 --regex .*.api.AbstractViolationReporter:90:100 --regex .*.checks.imports.CustomImportOrderCheck:91:93 --regex .*.checks.javadoc.AbstractJavadocCheck:93:90 …Run Code Online (Sandbox Code Playgroud) 更新Findbugs插件高达3.0.1版本后,我无法在Android Studio中编译多模块项目.我还使用"com.google.code.findbugs:annotations:3.0.1"依赖项来使用FindBugs注释(例如@SuppressFBWarnings).
组装项目时出现以下错误:
Execution failed for task ':presentation:packageAllDevelopDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
有条件地将某些东西添加到字符串的好旧java方式如下:
if (booleanFlag) {
myString += "something to append"
}
Run Code Online (Sandbox Code Playgroud)
我能以更加时髦的方式做同样的事吗,理想情况下是一行吗?
当我在Gradle中运行测试时,我希望:
com.me.MyTest > myTest PASSED当测试失败时,我希望显示所有标准流和堆栈跟踪
com.me.MyTest > myTest STANDARD_OUT
...
com.me.MyTest > myTest STANDARD_ERROR
...
com.me.MyTest > myTest FAILED
<full stacktrace>
Run Code Online (Sandbox Code Playgroud)我通过设置来实现第二个:
tasks.withType(Test).testLogging { TestLoggingContainer container ->
container.with {
events FAILED, PASSED, SKIPPED, STANDARD_ERROR, STANDARD_OUT
exceptionFormat = FULL
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
}
}
Run Code Online (Sandbox Code Playgroud)
但这些设置会PASSED使用STANDARD_ERROR和污染测试日志STANDARD_OUT.
我可以以某种方式静音STANDARD_ERROR和测试STANDARD_OUT事件PASSED吗?
我有以下Java方法:
private int calculate() {
return (bytes[0] & 0xff) + ((bytes[1] & 0xff) << 8);
}
Run Code Online (Sandbox Code Playgroud)
PMD对此代码抱怨"UselessParentheses"违规.
我已经审查了运算符优先级规则,但我仍然没有在该代码中看到冗余的括号.我错过了什么吗?
例如,不要通过字符串操作等来构建查询.