New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce checker framework #2

Merged
merged 3 commits into from Sep 12, 2017
Jump to file or symbol
Failed to load files and symbols.
+52 −4
Diff settings

Always

Just for now

View
@@ -1,3 +1,5 @@
ext.targetJavaVersion = JavaVersion.VERSION_1_8
buildscript {
ext {
springBootVersion = '2.0.0.M3'
@@ -37,6 +39,13 @@ sourceSets {
}
}
configurations {
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
}
annotationProcessors
}
dependencies {
compile('org.apache.maven:maven-artifact:3.5.0')
compile('org.springframework.boot:spring-boot-starter-webflux')
@@ -45,12 +54,34 @@ dependencies {
testCompile('com.codeborne:selenide:4.5.1')
testCompile('io.projectreactor:reactor-test')
// for lombok
def lombok = "org.projectlombok:lombok:1.16.16"
compileOnly lombok
annotationProcessors lombok
integrationTestCompile sourceSets.main.output
integrationTestCompile sourceSets.test.output
integrationTestCompile configurations.testCompile
integrationTestRuntime configurations.testRuntime
// for checker-framework
ext.checkerFrameworkVersion = '2.2.0'
ext.jdkVersion = 'jdk8'
checkerFrameworkAnnotatedJDK "org.checkerframework:${jdkVersion}:${checkerFrameworkVersion}"
annotationProcessors "org.checkerframework:checker:${checkerFrameworkVersion}"
compile "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
}
def processors = [
'org.checkerframework.checker.nullness.NullnessChecker',
'lombok.launch.AnnotationProcessorHider\$AnnotationProcessor',
]
compileJava.options.compilerArgs = [
'-processor', processors.join(','),
'-processorpath', configurations.annotationProcessors.asPath,
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
task integrationTest(type: Test) {
systemProperty "webdriver.chrome.driver", "/Users/kengo/bin/chromedriver"
testClassesDirs = files(sourceSets.integrationTest.java.outputDir)
@@ -13,6 +13,7 @@
import java.util.function.Function;
import java.util.function.Supplier;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -77,7 +78,9 @@
File parent = path.toFile().getParentFile();
try {
if (!parent.isDirectory() && !parent.mkdirs()) {
if (parent == null) {
throw new IOException("Given path has no parent directory: " + path.toFile());
} else if (!parent.isDirectory() && !parent.mkdirs()) {
throw new IOException("Failed to make directory at " + parent.getAbsolutePath());
}
return FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
@@ -46,6 +46,7 @@
});
}
@SuppressWarnings("nullness")
private Flux<ByteBuffer> unzip(File jar, String groupId, String artifactId, String version, String path) {
try {
ZipFile zip = new ZipFile(jar);
@@ -78,6 +79,7 @@
}
}
@SuppressWarnings("nullness")
Flux<Tuple2<String, Flux<ByteBuffer>>> unzip(File file) {
ZipFile zip;
try {
@@ -41,8 +41,11 @@
File dir = root.resolve(groupId).resolve(artifactId).resolve(version)
.toFile();
File file = new File(dir, path);
if (!file.getParentFile().isDirectory()) {
file.getParentFile().mkdirs();
File parent = file.getParentFile();
if (parent == null) {
return Mono.error(new IOException("Given path has no parent directory: " + file));
} else if (!parent.isDirectory() && !parent.mkdirs()) {
return Mono.error(new IOException("Failed to make directory at " + parent.getAbsolutePath()));
}
return Mono.create(subscriber -> {
@@ -1,6 +1,7 @@
package jp.skypencil.javadocky;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import lombok.NonNull;
@@ -19,6 +20,11 @@
if (!groupDir.isDirectory()) {
return Flux.empty();
}
return Flux.fromArray(groupDir.listFiles(File::isDirectory)).map(File::getName).sort();
File[] directories = groupDir.listFiles(File::isDirectory);
if (directories == null) {
return Flux.error(new IOException("Unknown error occured during listing directory"));
} else {
return Flux.fromArray(directories).map(File::getName).sort();
}
}
}
@@ -21,6 +21,7 @@
private final Path root;
@Override
@SuppressWarnings("nullness")
public Mono<ArtifactVersion> findLatest(String groupId, String artifactId) {
File dir = root.resolve(groupId).resolve(artifactId).toFile();
if (!dir.isDirectory()) {
@@ -42,6 +42,7 @@
return response.flatMap(this::fetchResponse);
}
@SuppressWarnings("nullness")
private Mono<ArtifactVersion> fetchResponse(ClientResponse res) {
HttpStatus status = res.statusCode();
if (status == HttpStatus.NOT_FOUND) {
@@ -70,6 +71,7 @@
return response.flatMapMany(this::listVersions);
}
@SuppressWarnings("nullness")
private Flux<ArtifactVersion> listVersions(ClientResponse res) {
HttpStatus status = res.statusCode();
if (status == HttpStatus.NOT_FOUND) {
ProTip! Use n and p to navigate between commits in a pull request.