Replace "throws Exception" with the specific Exception(s) thrown.

This commit is contained in:
Peter Lawrey
2015-06-28 18:52:05 +01:00
parent 9f9aaa9b9e
commit 9c8fea8367
25 changed files with 67 additions and 65 deletions
@@ -180,7 +180,7 @@ public final class DataValueBytesMarshallers {
" }\n" +
"\n" +
" @Override\n" +
" " + simpleName + " getInstance() throws Exception {\n" +
" " + simpleName + " getInstance() {\n" +
" return factory.create();\n" +
" }\n" +
"}\n";
@@ -531,7 +531,7 @@ public final class DataValueBytesMarshallers {
private static void generateGetInstance(StringBuilder sb, Class cl) {
sb.append(" ").append(cl.getCanonicalName())
.append(" getInstance() throws Exception {\n");
.append(" getInstance() {\n");
sb.append(" ").append("return new ").append(cl.getName()).append("$$Native();\n");
sb.append(" ").append("}\n\n");
}
@@ -133,7 +133,7 @@ public interface EngineReplicationLangBytes extends Closeable {
* @return {@code true} if the entry was accepted by the {@code callback.onEntry()} method,
* {@code false} if the entry was not accepted or was not available
*/
boolean nextEntry(@NotNull final EngineEntryCallback callback) throws InterruptedException;
boolean nextEntry(@NotNull final EngineEntryCallback callback);
/**
* Dirties all entries with a modification time equal to {@code fromTimeStamp} or newer. It
@@ -455,7 +455,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
}
@Override
public boolean nextEntry(@NotNull final EngineEntryCallback callback) throws InterruptedException {
public boolean nextEntry(@NotNull final EngineEntryCallback callback) {
return modificationIterator.nextEntry(new EntryCallback() {
@@ -1719,7 +1719,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
* @return true if an entry was processed
*/
@Override
public boolean nextEntry(@NotNull final EntryCallback entryCallback, final int chronicleId) throws InterruptedException {
public boolean nextEntry(@NotNull final EntryCallback entryCallback, final int chronicleId) {
long position = this.position;
while (true) {
long oldPosition = position;
@@ -1866,7 +1866,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
}
private void resizeToMessageOutBuffer(long start, @NotNull Exception e) throws Exception {
private <T extends Exception> void resizeToMessageOutBuffer(long start, @NotNull T e) throws T {
assert outBytesLock.isHeldByCurrentThread();
assert !inBytesLock.isHeldByCurrentThread();
String message = e.getMessage();
@@ -1822,12 +1822,16 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
@Override
public final ReadLocked<K, KI, MKI, V, VI, MVI> readLock(
@Nullable SegmentState segmentState) throws InterruptedException {
@Nullable SegmentState segmentState) {
while (true) {
// final boolean success = segmentHeader.tryRWReadLock(LOCK_OFFSET, lockTimeOutNS);
final boolean success;
boolean success = false;
success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
try {
success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
/*
boolean success = false;
@@ -2825,11 +2829,8 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
final Segment segment = segments[segIndex];
ThreadLocalCopies copies = SegmentState.getCopies(null);
try (SegmentState segmentState = SegmentState.get(copies)) {
try {
segment.readLock(null);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (segment.hashLookup().getPositions().isClear(pos)) {
// the pos was removed after the previous advance
advance(segIndex, pos);
@@ -21,11 +21,12 @@ import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.model.constraints.MaxSize;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.fail;
public class AcquireGetUsingMain {
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("java.io.tmpdir") + "/test1");
ChronicleMap<String, Data> theSharedMap =
ChronicleMapBuilder.of(String.class, Data.class)
@@ -20,12 +20,12 @@ import junit.framework.TestCase;
public class BitUnitTest extends TestCase {
public void testToBits() throws Exception {
public void testToBits() {
}
public void testToMegaBits() throws Exception {
public void testToMegaBits() {
}
public void testToGigaBits() throws Exception {
public void testToGigaBits() {
}
}
@@ -20,6 +20,7 @@ import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.model.constraints.MaxSize;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
@@ -30,7 +31,7 @@ public class CHMTest5 {
public static final String TEST_KEY = "whatever";
public static int NUMBER_OF_PROCESSES_ALLOWED = 2;
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException {
//First create (or access if already created) the shared map
ChronicleMapBuilder<String, CHMTest5Data> builder =
ChronicleMapBuilder.of(String.class, CHMTest5Data.class)
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class CHMTestIterator1 {
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
AtomicLong alValue = new AtomicLong();
AtomicLong alKey = new AtomicLong();
int runs = 3000000;
@@ -139,7 +139,7 @@ public class ChronicleMapTest {
}
@Test
public void testRemoveWithKey() throws Exception {
public void testRemoveWithKey() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder
@@ -186,7 +186,7 @@ public class ChronicleMapTest {
@Test
public void testByteArrayPersistenceFileReuse() throws Exception {
public void testByteArrayPersistenceFileReuse() throws IOException {
final File persistenceFile = Builder.getPersistenceFile();
for (int i = 0; i < 2; i++) {
@@ -205,7 +205,7 @@ public class ChronicleMapTest {
}
@Test
public void testEqualsCharSequence() throws Exception {
public void testEqualsCharSequence() {
ChronicleMapBuilder<CharSequence, CharSequence> builder = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class);
@@ -224,7 +224,7 @@ public class ChronicleMapTest {
@Ignore("HCOLL-265 Chronicle Maps with Identical byte[] & char[] values are not equal")
@Test
public void testEqualsCharArray() throws Exception {
public void testEqualsCharArray() {
char[] value = new char[5];
Arrays.fill(value, 'X');
@@ -247,7 +247,7 @@ public class ChronicleMapTest {
@Ignore("HCOLL-265 Chronicle Maps with Identical byte[] & char[] values are not equal")
@Test
public void testEqualsByteArray() throws Exception {
public void testEqualsByteArray() {
byte[] value = new byte[5];
Arrays.fill(value, (byte) 'X');
@@ -269,7 +269,7 @@ public class ChronicleMapTest {
@Test
public void testSize() throws Exception {
public void testSize() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
@@ -315,7 +315,7 @@ public class ChronicleMapTest {
}
@Test
public void testRemoveWithKeyAndRemoveReturnsNull() throws Exception {
public void testRemoveWithKeyAndRemoveReturnsNull() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
@@ -361,7 +361,7 @@ public class ChronicleMapTest {
}
@Test
public void testReplaceWithKey() throws Exception {
public void testReplaceWithKey() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
@@ -425,7 +425,7 @@ public class ChronicleMapTest {
}
@Test
public void testReplaceWithKeyAnd2Params() throws Exception {
public void testReplaceWithKeyAnd2Params() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
@@ -467,7 +467,7 @@ public class ChronicleMapTest {
}
@Test
public void testRemoveWithKeyAndValue() throws Exception {
public void testRemoveWithKeyAndValue() {
try (final ChronicleMap<CharSequence, CharSequence> map =
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
@@ -504,7 +504,7 @@ public class ChronicleMapTest {
}
@Test
public void testAcquireWithNullContainer() throws Exception {
public void testAcquireWithNullContainer() {
try (ChronicleMap<CharSequence, LongValue> map =
ChronicleMapBuilder.of(CharSequence.class, LongValue.class)
.entries(1000)
@@ -547,7 +547,7 @@ public class ChronicleMapTest {
// 1000M users, updated 16 times, Throughput 1.3 M ops/sec, TODO FIX this
@Test
public void testGetWithNullContainer() throws Exception {
public void testGetWithNullContainer() {
try (ChronicleMap<CharSequence, LongValue> map =
ChronicleMapBuilder.of(CharSequence.class, LongValue.class)
.entries(10)
@@ -560,7 +560,7 @@ public class ChronicleMapTest {
}
@Test
public void testGetWithoutAcquireFirst() throws Exception {
public void testGetWithoutAcquireFirst() {
try (ChronicleMap<CharSequence, LongValue> map =
ChronicleMapBuilder.of(CharSequence.class, LongValue.class)
.entries(10)
@@ -696,7 +696,7 @@ public class ChronicleMapTest {
@Ignore("Possible candidate for TC JVM crashes")
@Test
public void testAcquireFromMultipleThreads() throws Exception {
public void testAcquireFromMultipleThreads() throws InterruptedException {
int entries = 1000 * 1000;
try (ChronicleMap<CharSequence, LongValue> map2 = ChronicleMapBuilder.of(CharSequence.class,
LongValue.class)
@@ -589,7 +589,7 @@ public class ConcurrentMap8Test extends JSR166TestCase {
* A deserialized serialized set is equal
*//*
@Test
public void testSerialization() throws Exception {
public void testSerialization() {
int size = 20;
Set x = populatedSet(size);
Set y = serialClone(x);
@@ -22,6 +22,7 @@ import net.openhft.lang.values.IntValue;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import static org.junit.Assert.*;
@@ -29,7 +30,7 @@ import static org.junit.Assert.*;
public class DemoChronicleMapTest {
@Test
public void testMap() throws Exception {
public void testMap() throws IOException {
File file = File.createTempFile("DummyOrders"+System.currentTimeMillis(), ".test");
file.deleteOnExit();
int maxEntries = 1000;
@@ -71,7 +72,7 @@ public class DemoChronicleMapTest {
}
@Test
public void testMapLocked() throws Exception {
public void testMapLocked() throws IOException {
File file = File.createTempFile("DummyOrders-"+System.currentTimeMillis(), ".test");
file.deleteOnExit();
int maxEntries = 1000;
@@ -26,10 +26,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.*;
import static java.lang.Math.log10;
import static java.lang.Math.round;
@@ -62,7 +59,7 @@ public class EntryCountMapTest {
@Ignore("HCOLL-279 fix net.openhft.chronicle.map.EntryCountMapTest#testVerySmall")
@Test
public void testVerySmall() throws Exception {
public void testVerySmall() throws IOException {
System.out.print("testVerySmall seeds");
for (int t = 0; t < ecmTests; t++) {
System.out.print(".");
@@ -112,7 +109,7 @@ public class EntryCountMapTest {
}
@Test
public void testSmall() throws Exception {
public void testSmall() throws IOException, ExecutionException, InterruptedException {
System.out.print("testSmall seeds");
int procs = Runtime.getRuntime().availableProcessors();
ExecutorService es = Executors.newFixedThreadPool(procs);
@@ -156,7 +153,7 @@ public class EntryCountMapTest {
@Ignore("Long running, large tests test")
@Test
public void testMedium() throws Exception {
public void testMedium() throws IOException, ExecutionException, InterruptedException {
System.out.print("testMedium seeds");
int procs = Runtime.getRuntime().availableProcessors();
ExecutorService es = Executors.newFixedThreadPool(procs);
@@ -194,7 +191,7 @@ public class EntryCountMapTest {
return es.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
public Void call() {
File f = null;
try (final ChronicleMap<CharSequence, LongValue> map =
getSharedMap(minSize, segments, maxKeySize)) {
@@ -41,8 +41,7 @@ public class IntIntMultiMapTest {
Multimap<Long, Long> referenceMap = HashMultimap.create();
private Class<? extends MultiMap> c;
public IntIntMultiMapTest(Class<? extends MultiMap> c)
throws Exception {
public IntIntMultiMapTest(Class<? extends MultiMap> c) {
this.c = c;
}
@@ -45,7 +45,7 @@ public class ProcessInstanceLimiterMain implements Runnable {
t.start();
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException, InterruptedException {
Callback callback = new Callback() {
public void tooManyProcessesOfType(String processType) {
System.out.println("Too many processes of type " + processType + " have been started, so exiting this process");
@@ -779,7 +779,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase {
/**
* A deserialized map equals original
*/
/* @Test public void testSerialization() throws Exception {
/* @Test public void testSerialization() {
Map x = map5();
Map y = serialClone(x);
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals;
public class SerializerTest {
@Test
public void testPrefixStringFunctionSerialization() throws Exception {
public void testPrefixStringFunctionSerialization() {
ByteBufferBytes b = new ByteBufferBytes(ByteBuffer.allocate(512));
@@ -64,7 +64,7 @@ public class SerializerTest {
@Test
public void testValueMarshallable() throws Exception {
public void testValueMarshallable() {
testReadWriteValue("Test");
testReadWriteValue(1);
testReadWriteValue(1L);
@@ -80,7 +80,7 @@ public class SerializerTest {
}
@Test
public void testKeyMarshallable() throws Exception {
public void testKeyMarshallable() {
testReadWriteKey("Test");
testReadWriteKey(1);
testReadWriteKey(1L);
@@ -95,7 +95,7 @@ public class SerializerTest {
testReadWriteKey(new MyTestClassObjectGraph(3));
}
public void testReadWriteValue(Object value) throws Exception {
public void testReadWriteValue(Object value) {
Class valueClass = value.getClass();
@@ -119,7 +119,7 @@ public class SerializerTest {
Assert.assertEquals(actual, value);
}
public void testReadWriteKey(Object key) throws Exception {
public void testReadWriteKey(Object key) {
Class clazz = key.getClass();
@@ -30,7 +30,7 @@ public class TcpReplicationWithAcquireUsingLockedTest {
@Test
public void testReplicationWithAcquireUsingLocked() throws Exception {
public void testReplicationWithAcquireUsingLocked() throws InterruptedException {
TcpTransportAndNetworkConfig config1 = TcpTransportAndNetworkConfig.of(8076);
@@ -85,7 +85,7 @@ public class TcpReplicationWithAcquireUsingLockedTest {
@Test
public void testReplicationWithEmptyOffHeapObject() throws Exception {
public void testReplicationWithEmptyOffHeapObject() throws InterruptedException {
TcpTransportAndNetworkConfig config1 = TcpTransportAndNetworkConfig.of(8076);
@@ -138,7 +138,7 @@ public class TcpReplicationWithAcquireUsingLockedTest {
@Test
public void testReplicationWithOffHeapObject() throws Exception {
public void testReplicationWithOffHeapObject() throws InterruptedException {
TcpTransportAndNetworkConfig config1 = TcpTransportAndNetworkConfig.of(8076);
@@ -21,6 +21,7 @@ import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
/**
@@ -71,7 +72,7 @@ public class TestReplication {
* memory with the maps that is doing the update
*/
@Test
public void testReplicationUsingAProxyMapThatsUpdatedViaSharedMemory() throws Exception {
public void testReplicationUsingAProxyMapThatsUpdatedViaSharedMemory() throws IOException {
ChronicleMap<String, String> server1 = null;
ChronicleMap<String, String> server2 = null;
@@ -33,7 +33,7 @@ public class StateMachineTutorial {
//
// *************************************************************************
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
ChronicleMap<Integer, StateMachineData> map = null;
try {
@@ -17,6 +17,7 @@
package net.openhft.chronicle.map.jsr166;
import junit.framework.AssertionFailedError;
import net.openhft.lang.Jvm;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -261,7 +262,7 @@ public class JSR166TestCase {
* Triggers test case Assert.failure if interrupt status is set in the main thread.
*/
@After
public void tearDown() throws Exception {
public void tearDown() throws InterruptedException {
Throwable t = threadFailure.getAndSet(null);
if (t != null) {
if (t instanceof Error)
@@ -269,7 +270,7 @@ public class JSR166TestCase {
else if (t instanceof RuntimeException)
throw (RuntimeException) t;
else if (t instanceof Exception)
throw (Exception) t;
throw Jvm.rethrow(t);
else {
AssertionFailedError afe =
new AssertionFailedError(t.toString());
@@ -673,7 +673,7 @@ public class ChronicleMapTest extends JSR166TestCase {
/**
* A deserialized map equals original
*/
/* @Test public void testSerialization() throws Exception {
/* @Test public void testSerialization() {
Map x = map5();
Map y = serialClone(x);
@@ -51,7 +51,7 @@ public class MapCheck {
if (!b) throw new Error("Failed Assertion");
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException, ClassNotFoundException {
int numTests = 20;
int size = 36864; // about midway of HashMap resize interval
@@ -360,7 +360,7 @@ public class MapCheck {
reallyAssert(src.size() == dst.size());
}
static void serTest(int size) throws Exception {
static void serTest(int size) throws IOException, ClassNotFoundException {
Map s = newMap();
if (!(s instanceof Serializable))
return;
@@ -142,7 +142,7 @@ public class ProcessInstanceLimiter implements Runnable {
t.start();
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessInstanceLimiter.limitTo(2);
Thread.sleep(60L * 1000L);
}
@@ -22,7 +22,7 @@ import org.junit.Test;
public class ChronicleSetBuilderTest {
@Test
public void test() throws Exception {
public void test() {
try (ChronicleSet<Integer> integers = ChronicleSetBuilder.of(Integer.class).create()) {
for (int i = 0; i < 10; i++) {