Skip to content

Commit bb8b445

Browse files
author
Bruce Eckel
committed
Findbugs and working with gradlew run
1 parent 4f79533 commit bb8b445

File tree

18 files changed

+27
-22
lines changed

18 files changed

+27
-22
lines changed

annotations/AtUnitExample2.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ void assertFailureExample() {
2828
}
2929
@Test
3030
void exceptionExample() throws IOException {
31-
new FileInputStream("nofile.txt"); // Throws
31+
try(FileInputStream fis =
32+
new FileInputStream("nofile.txt")) {} // Throws
3233
}
3334
@Test
3435
boolean assertAndReturn() {

annotations/UseCaseTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class UseCaseTracker {
1414
if(uc != null) {
1515
System.out.println("Found Use Case " +
1616
uc.id() + "\n " + uc.description());
17-
useCases.remove(new Integer(uc.id()));
17+
useCases.remove(Integer.valueOf(uc.id()));
1818
}
1919
}
2020
useCases.forEach(i ->

arrays/SimpleSetAll.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bob {
1414

1515
public class SimpleSetAll {
1616
public static final int SZ = 8;
17-
public static int val = 1;
17+
static int val = 1;
1818
static char[] chars = "abcdefghijklmnopqrstuvwxyz"
1919
.toCharArray();
2020
static char getChar(int n) { return chars[n]; }

collections/MapOfList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.*;
99

1010
public class MapOfList {
11-
public static Map<Person, List< ? extends Pet>>
11+
public static final Map<Person, List< ? extends Pet>>
1212
petPeople = new HashMap<>();
1313
static {
1414
petPeople.put(new Person("Dawn"),

collectiontopics/CanonicalMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void main(String[] args) {
3939
int size = 1000;
4040
// Or, choose size via the command line:
4141
if(args.length > 0)
42-
size = new Integer(args[0]);
42+
size = Integer.valueOf(args[0]);
4343
Key[] keys = new Key[size];
4444
WeakHashMap<Key,Value> map =
4545
new WeakHashMap<>();

collectiontopics/References.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void main(String[] args) {
3131
int size = 10;
3232
// Or, choose size via the command line:
3333
if(args.length > 0)
34-
size = new Integer(args[0]);
34+
size = Integer.valueOf(args[0]);
3535
LinkedList<SoftReference<VeryBig>> sa =
3636
new LinkedList<>();
3737
for(int i = 0; i < size; i++) {

concurrent/CompletableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CompletableOperations {
99
static CompletableFuture<Integer> cfi(int i) {
1010
return
1111
CompletableFuture.completedFuture(
12-
new Integer(i));
12+
Integer.valueOf(i));
1313
}
1414
public static void main(String[] args) {
1515
showr(cfi(1)); // Basic test

concurrent/CountingTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CountingTask implements Callable<Integer> {
99
public CountingTask(int id) { this.id = id; }
1010
@Override
1111
public Integer call() {
12-
Integer val = new Integer(0);
12+
Integer val = 0;
1313
for(int i = 0; i < 100; i++)
1414
val++;
1515
System.out.println(id + " " +

concurrent/DiningPhilosophers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
// Hidden deadlock
6+
// {ValidateByHand} Gradle has trouble
67
import java.util.*;
78
import java.util.concurrent.*;
89
import onjava.Nap;

concurrent/InterferingTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class InterferingTask implements Runnable {
77
final int id;
8-
private static Integer val = new Integer(0);
8+
private static Integer val = 0;
99
public InterferingTask(int id) { this.id = id; }
1010
@Override
1111
public void run() {

0 commit comments

Comments
 (0)