Clean up argument finality and whitespace in for(:) constructs.
Change-Id: If22f693e6c499aafc8fe0a606b2abb40a9f67cfc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
new RoleChangeNotification(roleChanged.getMemberId(),
roleChanged.getOldRole(), roleChanged.getNewRole());
new RoleChangeNotification(roleChanged.getMemberId(),
roleChanged.getOldRole(), roleChanged.getNewRole());
- for (ActorRef listener: registeredListeners.values()) {
+ for (ActorRef listener : registeredListeners.values()) {
listener.tell(latestRoleChangeNotification, getSelf());
}
} else if (message instanceof LeaderStateChanged leaderStateChanged) {
listener.tell(latestRoleChangeNotification, getSelf());
}
} else if (message instanceof LeaderStateChanged leaderStateChanged) {
- for (byte[] chunk: assertFinishedStream(size, 2)) {
- for (byte actual: chunk) {
+ for (byte[] chunk : assertFinishedStream(size, 2)) {
+ for (byte actual : chunk) {
assertEquals((byte) counter++, actual);
}
}
assertEquals((byte) counter++, actual);
}
}
import com.google.common.util.concurrent.Uninterruptibles;
import java.io.File;
import java.io.IOException;
import com.google.common.util.concurrent.Uninterruptibles;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.junit.After;
assertEquals("Temp file", tempFileName, findTempFileName(TEMP_DIR));
assertEquals("Size", bytes.length, fbos.asByteSource().size());
assertEquals("Temp file", tempFileName, findTempFileName(TEMP_DIR));
assertEquals("Size", bytes.length, fbos.asByteSource().size());
- InputStream inputStream = fbos.asByteSource().openStream();
+ try (var inputStream = fbos.asByteSource().openStream()) {
+ assertArrayEquals("Read bytes", bytes, fbos.asByteSource().read());
- assertArrayEquals("Read bytes", bytes, fbos.asByteSource().read());
-
- byte[] inBytes = new byte[bytes.length];
- assertEquals("# bytes read", bytes.length, inputStream.read(inBytes));
- assertArrayEquals("Read InputStream", bytes, inBytes);
- assertEquals("End of stream", -1, inputStream.read());
-
- inputStream.close();
+ byte[] inBytes = new byte[bytes.length];
+ assertEquals("# bytes read", bytes.length, inputStream.read(inBytes));
+ assertArrayEquals("Read InputStream", bytes, inBytes);
+ assertEquals("End of stream", -1, inputStream.read());
+ }
fail("Temp file was not deleted");
}
fail("Temp file was not deleted");
}
- static String findTempFileName(String dirPath) {
+ static String findTempFileName(final String dirPath) {
String[] files = new File(dirPath).list();
assertNotNull(files);
assertTrue("Found more than one temp file: " + Arrays.toString(files), files.length < 2);
return files.length == 1 ? files[0] : null;
}
String[] files = new File(dirPath).list();
assertNotNull(files);
assertTrue("Found more than one temp file: " + Arrays.toString(files), files.length < 2);
return files.length == 1 ? files[0] : null;
}
- static boolean deleteFile(String file) {
+ static boolean deleteFile(final String file) {
return new File(file).delete();
}
return new File(file).delete();
}
- static void deleteTempFiles(String path) {
+ static void deleteTempFiles(final String path) {
String[] files = new File(path).list();
if (files != null) {
String[] files = new File(path).list();
if (files != null) {
- for (String file: files) {
+ for (String file : files) {
deleteFile(path + File.separator + file);
}
}
}
deleteFile(path + File.separator + file);
}
}
}
- static void createDir(String path) {
+ static void createDir(final String path) {
File dir = new File(path);
if (!dir.exists() && !dir.mkdirs()) {
throw new RuntimeException("Failed to create temp dir " + path);
File dir = new File(path);
if (!dir.exists() && !dir.mkdirs()) {
throw new RuntimeException("Failed to create temp dir " + path);