Skip to content

Commit d24a53f

Browse files
committed
Make code less "error prone"
1 parent d43b66c commit d24a53f

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/allocator/Spalloc.java

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
import com.fasterxml.jackson.annotation.JsonIgnore;
5959
import com.google.errorprone.annotations.FormatMethod;
60+
import com.google.errorprone.annotations.MustBeClosed;
6061
import com.google.errorprone.annotations.concurrent.GuardedBy;
6162

6263
import uk.ac.manchester.spinnaker.alloc.SpallocProperties.AllocatorProperties;
@@ -1746,6 +1747,7 @@ public TransceiverInterface getTransceiver() throws IOException,
17461747
}
17471748

17481749
@Override
1750+
@SuppressWarnings("MustBeClosed")
17491751
public FastDataIn getFastDataIn(CoreLocation gathererCore, IPTag iptag)
17501752
throws ProcessException, IOException, InterruptedException {
17511753
var fdi = rememberer.getFastDataIn(id, iptag.getDestination());
@@ -1758,6 +1760,7 @@ public FastDataIn getFastDataIn(CoreLocation gathererCore, IPTag iptag)
17581760
}
17591761

17601762
@Override
1763+
@SuppressWarnings("MustBeClosed")
17611764
public Downloader getDownloader(IPTag iptag)
17621765
throws ProcessException, IOException, InterruptedException {
17631766
var downloader = rememberer.getDownloader(id,

SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/allocator/SpallocAPI.java

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.security.access.prepost.PreAuthorize;
4343

4444
import com.google.errorprone.annotations.Keep;
45+
import com.google.errorprone.annotations.MustBeClosed;
4546

4647
import uk.ac.manchester.spinnaker.alloc.compat.V1CompatService;
4748
import uk.ac.manchester.spinnaker.alloc.model.BoardCoords;
@@ -1007,6 +1008,7 @@ TransceiverInterface getTransceiver()
10071008
* @throws IOException if there is an issue communicating.
10081009
* @throws InterruptedException if the operation is interrupted.
10091010
*/
1011+
@MustBeClosed
10101012
FastDataIn getFastDataIn(CoreLocation gathererCore, IPTag iptag)
10111013
throws ProcessException, IOException, InterruptedException;
10121014

@@ -1019,6 +1021,7 @@ FastDataIn getFastDataIn(CoreLocation gathererCore, IPTag iptag)
10191021
* @throws IOException if there is an issue communicating.
10201022
* @throws InterruptedException if the operation is interrupted.
10211023
*/
1024+
@MustBeClosed
10221025
Downloader getDownloader(IPTag iptag)
10231026
throws ProcessException, IOException, InterruptedException;
10241027
}

SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/web/SpallocServiceAPIImplBuilder.java

+2
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ public void readDataFromJob(int x, int y, long address, int size,
316316
}
317317

318318
@Override
319+
@SuppressWarnings("MustBeClosed")
319320
public void fastDataWrite(@ValidX int gatherX, @ValidY int gatherY,
320321
@Positive int gatherP, @ValidX int ethX,
321322
@ValidY int ethY, @IPAddress String ethAddress, int iptag,
@@ -333,6 +334,7 @@ public void fastDataWrite(@ValidX int gatherX, @ValidY int gatherY,
333334
}
334335

335336
@Override
337+
@SuppressWarnings("MustBeClosed")
336338
public void fastDataRead(@ValidX int gatherX, @ValidY int gatherY,
337339
@ValidX int ethX, @ValidY int ethY,
338340
@IPAddress String ethAddress, int iptag,

SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/protocols/download/Downloader.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @author Donal Fellows
4848
*/
49-
public class Downloader {
49+
public class Downloader implements AutoCloseable {
5050

5151
/** The maximum number of times to retry. */
5252
private static final int TIMEOUT_RETRY_LIMIT = 15;
@@ -131,6 +131,7 @@ public Downloader(IPTag iptag)
131131
conn = new GatherDownloadConnection(iptag);
132132
}
133133

134+
@Override
134135
public void close() throws IOException {
135136
conn.close();
136137
}

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/download/DataGatherer.java

+4
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ private void parallel(Stream<SimpleCallable> tasks) throws IOException,
287287
* @throws InterruptedException
288288
* If communications are interrupted.
289289
*/
290+
@SuppressWarnings("MustBeClosed")
290291
private void fastDownload(List<WorkItems> work,
291292
ChipLocation gathererChip, IPTag ipTag)
292293
throws IOException, StorageException,
@@ -321,6 +322,9 @@ private void fastDownload(List<WorkItems> work,
321322
}
322323
}
323324
}
325+
if (downloader != null) {
326+
downloader.close();
327+
}
324328
}
325329

326330
private void sanityCheck(List<Gather> gatherers) {

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/download/DataReceiver.java

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import org.slf4j.Logger;
3030

31+
import com.google.errorprone.annotations.MustBeClosed;
32+
3133
import uk.ac.manchester.spinnaker.front_end.BasicExecutor;
3234
import uk.ac.manchester.spinnaker.front_end.BoardLocalSupport;
3335
import uk.ac.manchester.spinnaker.front_end.download.request.Placement;
@@ -73,6 +75,8 @@ public class DataReceiver extends BoardLocalSupport implements AutoCloseable {
7375
* @throws StorageException
7476
* If the database access fails.
7577
*/
78+
@MustBeClosed
79+
@SuppressWarnings("MustBeClosed")
7680
public DataReceiver(Machine machine, BufferManagerStorage storage)
7781
throws IOException, StorageException, SpinnmanException,
7882
InterruptedException {

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/dse/FastExecuteDataSpecification.java

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class FastExecuteDataSpecification extends ExecuteDataSpecification {
9191
* this constructor should not be doing that!
9292
*/
9393
@MustBeClosed
94+
@SuppressWarnings("MustBeClosed")
9495
public FastExecuteDataSpecification(
9596
Machine machine, List<Gather> gatherers, File reportDir,
9697
DSEDatabaseEngine db) throws IOException, InterruptedException,
@@ -187,6 +188,7 @@ private List<RegionInfo> loadBoardTables(Ethernet board, DSEStorage storage)
187188
return regionsToWrite;
188189
}
189190

191+
@SuppressWarnings("MustBeClosed")
190192
private void loadBoardData(Gather gather, List<RegionInfo> regionsToWrite)
191193
throws IOException, StorageException, ProcessException,
192194
InterruptedException {
@@ -206,6 +208,9 @@ private void loadBoardData(Gather gather, List<RegionInfo> regionsToWrite)
206208
core, info.pointer, info.content);
207209
}
208210
}
211+
if (fastDataIn != null) {
212+
fastDataIn.close();
213+
}
209214
}
210215

211216
private HasChipLocation getBoardLocalDestination(

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/dse/HostExecuteDataSpecification.java

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class HostExecuteDataSpecification extends ExecuteDataSpecification {
6464
* this constructor should not be doing that!
6565
*/
6666
@MustBeClosed
67+
@SuppressWarnings("MustBeClosed")
6768
public HostExecuteDataSpecification(
6869
Machine machine, DSEDatabaseEngine db)
6970
throws IOException, InterruptedException,

0 commit comments

Comments
 (0)