Skip to content

Commit

Permalink
Suppress some warnings about auto-closeable resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bmalinowsky committed Feb 24, 2024
1 parent eb72af0 commit 2709e86
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/io/calimero/mgmt/ManagementProceduresImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2010, 2023 B. Malinowsky
Copyright (c) 2010, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -833,6 +833,7 @@ private Destination getOrCreateDestination(final IndividualAddress device)
}

// work around for implementation in TL, which unconditionally throws if dst exists
@SuppressWarnings("resource")
private Destination getOrCreateDestination(final IndividualAddress device,
final boolean keepAlive, final boolean verifyByServer)
{
Expand Down
3 changes: 2 additions & 1 deletion src/io/calimero/mgmt/TransportLayerImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2023 B. Malinowsky
Copyright (c) 2006, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -463,6 +463,7 @@ private void handleConnected(final CEMILData frame, final AggregatorProxy p)
d.destroy();
}

@SuppressWarnings({ "resource", "unused" }) // mute warnings for new Destination
final BiFunction<IndividualAddress, AggregatorProxy, AggregatorProxy> setupProxy = (__, proxy) -> {
if (proxy == null) {
// allow incoming connect requests (server)
Expand Down
3 changes: 2 additions & 1 deletion src/io/calimero/serial/SerialConnectionFactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2022, 2023 B. Malinowsky
Copyright (c) 2022, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -90,6 +90,7 @@ private record SettingsImpl(String portId, int baudrate, int databits, StopBits
* @return new connection for the specified serial communication port, port resource is in open state
* @throws KNXException on failure to open or configure serial port, or no adapter available
*/
@SuppressWarnings("resource")
public static SerialCom open(final String portId, final int baudrate, final Duration readIntervalTimeout,
final Duration receiveTimeout) throws KNXException {
final int databits = 8;
Expand Down
4 changes: 3 additions & 1 deletion src/io/calimero/serial/usb/UsbConnectionFactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2022, 2023 B. Malinowsky
Copyright (c) 2022, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -50,6 +50,7 @@ public final class UsbConnectionFactory {

private UsbConnectionFactory() {}

@SuppressWarnings("resource")
public static UsbConnection open(final Device device) throws KNXException {
try {
return factory.open(p -> p.open(device));
Expand All @@ -59,6 +60,7 @@ public static UsbConnection open(final Device device) throws KNXException {
}
}

@SuppressWarnings("resource")
public static UsbConnection open(final String device) throws KNXException {
try {
return factory.open(p -> p.open(device));
Expand Down
1 change: 1 addition & 0 deletions test/io/calimero/knxnetip/KNXnetIPRouterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ void fastSendManyRoutingBusy() throws KNXException
}

@Test
@SuppressWarnings("resource")
void initWithSystemBroadcastSocket() {
assertDoesNotThrow(() -> new KNXnetIPRouting(null, InetAddress.getByName("224.0.23.13")));
}
Expand Down

0 comments on commit 2709e86

Please sign in to comment.