Permalink
Browse files

Changed error handling from Exception to Error

  • Loading branch information...
1 parent d4a4cda commit 17949202ec01c4c23d5ce84936ad18b170117c03 @skunkiferous skunkiferous committed Mar 13, 2013
Showing with 430 additions and 372 deletions.
  1. +2 −2 src/main/java/org/agilewiki/jactor/ExceptionHandler.java
  2. +27 −23 src/main/java/org/agilewiki/jactor/JAFuture.java
  3. +21 −18 src/main/java/org/agilewiki/jactor/JAMailboxFactory.java
  4. +7 −6 src/main/java/org/agilewiki/jactor/MailboxFactory.java
  5. +98 −70 src/main/java/org/agilewiki/jactor/apc/JAPCMailbox.java
  6. +28 −21 src/main/java/org/agilewiki/jactor/concurrent/JAThreadManager.java
  7. +4 −3 src/main/java/org/agilewiki/jactor/concurrent/ThreadManager.java
  8. +116 −117 src/main/java/org/agilewiki/jactor/lpc/JLPCActor.java
  9. +1 −1 src/main/java/org/agilewiki/jactor/lpc/TransparentException.java
  10. +8 −7 src/main/java/org/agilewiki/jactor/lpc/package-info.java
  11. +1 −1 src/main/java/org/agilewiki/jactor/osgi/Activator.java
  12. +4 −3 src/test/java/org/agilewiki/jactor/basics/Actor4.java
  13. +1 −1 src/test/java/org/agilewiki/jactor/continuation/ContinuationTest.java
  14. +1 −1 src/test/java/org/agilewiki/jactor/lpc/ASATest.java
  15. +1 −1 src/test/java/org/agilewiki/jactor/lpc/EventTest.java
  16. +1 −1 src/test/java/org/agilewiki/jactor/lpc/SSATest.java
  17. +1 −1 src/test/java/org/agilewiki/jactor/lpc/ShATest.java
  18. +6 −6 src/test/java/org/agilewiki/jactor/lpc/calculatorTest/CalculatorTest.java
  19. +49 −39 src/test/java/org/agilewiki/jactor/lpc/calculatorTest/PrintingCalculator.java
  20. +2 −2 src/test/java/org/agilewiki/jactor/lpc/exceptionsTest/AsyncTest.java
  21. +6 −5 src/test/java/org/agilewiki/jactor/lpc/exceptionsTest/Driver.java
  22. +2 −2 src/test/java/org/agilewiki/jactor/lpc/exceptionsTest/SharedMailboxTest.java
  23. +2 −2 src/test/java/org/agilewiki/jactor/lpc/exceptionsTest/SyncTest.java
  24. +1 −1 src/test/java/org/agilewiki/jactor/lpc/serverTest/ServerTest.java
  25. +1 −1 src/test/java/org/agilewiki/jactor/lpc/syncTiming/Sync1Test.java
  26. +1 −1 src/test/java/org/agilewiki/jactor/lpc/timingTest/AsyncMailboxTest.java
  27. +1 −1 src/test/java/org/agilewiki/jactor/lpc/timingTest/MailboxTest.java
  28. +1 −1 src/test/java/org/agilewiki/jactor/lpc/timingTest/SharedMailboxTest.java
  29. +5 −5 src/test/java/org/agilewiki/jactor/multithreadingTest/ResponsePrinterTest.java
  30. +1 −1 src/test/java/org/agilewiki/jactor/nbLock/NBLockTest.java
  31. +1 −1 src/test/java/org/agilewiki/jactor/nbLock/exceptionsTest/NBLockExceptionsTest.java
  32. +13 −11 src/test/java/org/agilewiki/jactor/nbLock/exceptionsTest/Process.java
  33. +1 −1 src/test/java/org/agilewiki/jactor/properties/PropertiesTest.java
  34. +1 −1 src/test/java/org/agilewiki/jactor/pubsub/actorName/ActorNameTest.java
  35. +1 −1 src/test/java/org/agilewiki/jactor/pubsub/publish/PublishTest.java
  36. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/CallTest.java
  37. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/GotoTest.java
  38. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/IfFTest.java
  39. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/IfVTest.java
  40. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/IteratorTest.java
  41. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/ReturnFTest.java
  42. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/ReturnVTest.java
  43. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SendFFTest.java
  44. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SendFVTest.java
  45. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SendVFTest.java
  46. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SendVVTest.java
  47. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SetFTest.java
  48. +1 −1 src/test/java/org/agilewiki/jactor/simpleMachine/SetVTest.java
@@ -47,7 +47,7 @@
* protected void processRequest(final Object request, final RP rp)
* throws Exception {
* setExceptionHandler(new ExceptionHandler() {
- * public void process(Exception exception) throws Exception {
+ * public void process(Throwable exception) throws Exception {
* System.out.println("Exception caught by Doer");
* rp.process(null);
* }
@@ -68,5 +68,5 @@
* @param exception The exception to be processed.
* @throws Exception Any uncaught exceptions raised while processing the exception.
*/
- void process(Exception exception) throws Exception;
+ void process(final Throwable exception) throws Exception;
}
@@ -23,6 +23,9 @@
*/
package org.agilewiki.jactor;
+import java.util.ArrayList;
+import java.util.concurrent.Semaphore;
+
import org.agilewiki.jactor.apc.JAMessage;
import org.agilewiki.jactor.apc.JARequest;
import org.agilewiki.jactor.apc.JAResponse;
@@ -31,9 +34,6 @@
import org.agilewiki.jactor.lpc.Request;
import org.agilewiki.jactor.lpc.RequestSource;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
/**
* <p>
* Used both in the program's main method and in testing to send a request to an actor and wait for a response.
@@ -58,20 +58,19 @@
/**
* Receives the response as a bufferedEvent.
*/
- private BufferedEventsDestination<JAMessage> bufferedEventsDestination =
- new BufferedEventsDestination<JAMessage>() {
- @Override
- public void putBufferedEvents(ArrayList<JAMessage> bufferedEvents) {
- JAResponse japcResponse = (JAResponse) bufferedEvents.get(0);
- result = japcResponse.getUnwrappedResponse();
- done.release();
- }
- };
+ private final BufferedEventsDestination<JAMessage> bufferedEventsDestination = new BufferedEventsDestination<JAMessage>() {
+ @Override
+ public void putBufferedEvents(final ArrayList<JAMessage> bufferedEvents) {
+ final JAResponse japcResponse = (JAResponse) bufferedEvents.get(0);
+ result = japcResponse.getUnwrappedResponse();
+ done.release();
+ }
+ };
/**
* Serves as the originator of a request.
*/
- private RequestSource requestSource = new RequestSource() {
+ private final RequestSource requestSource = new RequestSource() {
@Override
final public Mailbox getMailbox() {
return null;
@@ -83,20 +82,23 @@ public ExceptionHandler getExceptionHandler() {
}
@Override
- public void setExceptionHandler(ExceptionHandler exceptionHandler) {
+ public void setExceptionHandler(final ExceptionHandler exceptionHandler) {
throw new UnsupportedOperationException();
}
@Override
- final public void responseFrom(final BufferedEventsQueue<JAMessage> eventQueue,
- final JAResponse japcResponse) {
+ final public void responseFrom(
+ final BufferedEventsQueue<JAMessage> eventQueue,
+ final JAResponse japcResponse) {
eventQueue.send(bufferedEventsDestination, japcResponse);
}
@Override
- final public void send(final BufferedEventsDestination<JAMessage> destination,
- final JARequest japcRequest) {
- final ArrayList<JAMessage> bufferedEvents = new ArrayList<JAMessage>(1);
+ final public void send(
+ final BufferedEventsDestination<JAMessage> destination,
+ final JARequest japcRequest) {
+ final ArrayList<JAMessage> bufferedEvents = new ArrayList<JAMessage>(
+ 1);
bufferedEvents.add(japcRequest);
destination.putBufferedEvents(bufferedEvents);
}
@@ -110,20 +112,22 @@ final public void send(final BufferedEventsDestination<JAMessage> destination,
* @return The unwrapped response.
* @throws Exception Any uncaught exceptions raised while processing the request.
*/
- public Object send(final Actor actor,
- final Request request)
+ public Object send(final Actor actor, final Request request)
throws Exception {
done = new Semaphore(0);
actor.acceptRequest(requestSource, request, new RP() {
@Override
- public void processResponse(Object response) throws Exception {
+ public void processResponse(final Object response) throws Exception {
result = response;
done.release();
}
});
done.acquire();
done = null;
- if (result instanceof Exception) throw (Exception) result;
+ if (result instanceof Exception)
+ throw (Exception) result;
+ if (result instanceof Error)
+ throw (Error) result;
return result;
}
}
@@ -23,16 +23,16 @@
*/
package org.agilewiki.jactor;
-import org.agilewiki.jactor.concurrent.JAThreadManager;
-import org.agilewiki.jactor.concurrent.ThreadManager;
-import org.agilewiki.jactor.lpc.JLPCMailbox;
-import org.agilewiki.jactor.lpc.Request;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Timer;
+import org.agilewiki.jactor.concurrent.JAThreadManager;
+import org.agilewiki.jactor.concurrent.ThreadManager;
+import org.agilewiki.jactor.lpc.JLPCMailbox;
+import org.agilewiki.jactor.lpc.Request;
+
/**
* <p>
* Implements MailboxFactory.
@@ -48,7 +48,7 @@
* </pre>
*/
public class JAMailboxFactory implements MailboxFactory {
- private List<Closable> closables = new ArrayList<Closable>();
+ private final List<Closable> closables = new ArrayList<Closable>();
private Timer timer = null;
@Override
@@ -62,9 +62,9 @@ public Timer timer() throws Exception {
/**
* The thread manager.
*/
- private ThreadManager threadManager;
+ private final ThreadManager threadManager;
- public JAMailboxFactory(ThreadManager threadManager) {
+ public JAMailboxFactory(final ThreadManager threadManager) {
this.threadManager = threadManager;
}
@@ -74,28 +74,30 @@ public JAMailboxFactory(ThreadManager threadManager) {
* @param threadCount The number of concurrent to be used.
* @return A new JAMailboxFactory.
*/
- public static JAMailboxFactory newMailboxFactory(int threadCount) {
- return new JAMailboxFactory(JAThreadManager.newThreadManager(threadCount));
+ public static JAMailboxFactory newMailboxFactory(final int threadCount) {
+ return new JAMailboxFactory(
+ JAThreadManager.newThreadManager(threadCount));
}
/**
* Returns the thread manager.
*
* @return The thread manager.
*/
+ @Override
public ThreadManager getThreadManager() {
return threadManager;
}
@Override
- public boolean addClosable(Closable closable) {
+ public boolean addClosable(final Closable closable) {
if (closable == null)
throw new IllegalArgumentException("may not be null");
return closables.add(closable);
}
@Override
- public boolean removeClosable(Closable closable) {
+ public boolean removeClosable(final Closable closable) {
return closables.remove(closable);
}
@@ -104,8 +106,8 @@ public boolean removeClosable(Closable closable) {
*/
@Override
public void close() {
- List<Closable> c = new ArrayList<Closable>(closables);
- Iterator<Closable> it = c.iterator();
+ final List<Closable> c = new ArrayList<Closable>(closables);
+ final Iterator<Closable> it = c.iterator();
while (it.hasNext())
it.next().close();
if (timer != null)
@@ -136,13 +138,14 @@ final public Mailbox createAsyncMailbox() {
}
@Override
- public void eventException(Request request, Exception exception) {
- logException(false, request.getClass().getName() +
- " event exception: ", exception);
+ public void eventException(final Request request, final Throwable exception) {
+ logException(false,
+ request.getClass().getName() + " event exception: ", exception);
}
@Override
- public void logException(boolean fatal, String msg, Exception exception) {
+ public void logException(final boolean fatal, final String msg,
+ final Throwable exception) {
threadManager.logException(fatal, msg, exception);
}
}
@@ -23,11 +23,11 @@
*/
package org.agilewiki.jactor;
+import java.util.Timer;
+
import org.agilewiki.jactor.concurrent.ThreadManager;
import org.agilewiki.jactor.lpc.Request;
-import java.util.Timer;
-
/**
* Creates Mailboxes and provides access to the thread manager.
*/
@@ -53,18 +53,19 @@
*/
Mailbox createAsyncMailbox();
- public boolean addClosable(Closable closable);
+ public boolean addClosable(final Closable closable);
- public boolean removeClosable(Closable closable);
+ public boolean removeClosable(final Closable closable);
/**
* Stop all the threads as they complete their tasks.
*/
public void close();
- public void eventException(Request request, Exception exception);
+ public void eventException(final Request request, final Throwable exception);
- public void logException(boolean fatal, String msg, Exception exception);
+ public void logException(final boolean fatal, final String msg,
+ final Throwable exception);
public Timer timer() throws Exception;
}
Oops, something went wrong.

0 comments on commit 1794920

Please sign in to comment.