Skip to content

Commit

Permalink
Merge pull request #76 from don-vip/patch-1
Browse files Browse the repository at this point in the history
Fix nonnull annotations database for java.util.concurrent.ForkJoinPool
  • Loading branch information
iloveeclipse authored Jun 11, 2016
2 parents d814aaa + c87abf8 commit a8cd246
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ public static void addDefaultNullnessAnnotations(INullnessAnnotationDatabase dat
database.addMethodParameterAnnotation("java.util.concurrent.ConcurrentHashMap", "setEntryAt",
"([Ljava/util/concurrent/ConcurrentHashMap$HashEntry;ILjava/util/concurrent/ConcurrentHashMap$HashEntry;)V", false, 1, NullnessAnnotation.NULLABLE);
database.addMethodParameterAnnotation("java.util.concurrent.ForkJoinPool", "<init>",
"(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 1, NullnessAnnotation.NULLABLE);
"(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 1, NullnessAnnotation.NONNULL);
database.addMethodParameterAnnotation("java.util.concurrent.ForkJoinPool", "<init>",
"(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 2, NullnessAnnotation.NULLABLE);
database.addMethodParameterAnnotation("java.util.concurrent.PriorityBlockingQueue", "<init>",
"(ILjava/util/Comparator;)V", false, 1, NullnessAnnotation.NULLABLE);

Expand Down
27 changes: 27 additions & 0 deletions findbugsTestCases/src/java/ghIssues/Issue0076.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ghIssues;

import java.io.Serializable;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;

import edu.umd.cs.findbugs.annotations.ExpectWarning;
import edu.umd.cs.findbugs.annotations.NoWarning;

public class Issue0076 {

private static class Handler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
}
}

@NoWarning("NP_NONNULL_PARAM_VIOLATION")
public void testNominal() {
new ForkJoinPool(2, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}

@ExpectWarning("NP_NONNULL_PARAM_VIOLATION")
public void testWarning() {
new ForkJoinPool(2, null, new Handler(), true);
}
}

0 comments on commit a8cd246

Please sign in to comment.