Skip to content

Commit

Permalink
remove unnecessary catches of Throwable
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Browne committed Jul 2, 2016
1 parent 77a9865 commit 71d432f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public void close() {
generators_.forEach((g) -> {
try {
g.close();
} catch (Throwable t) {
logger.log(Level.SEVERE, "failed to close group generator " + g, t);
} catch (Exception e) {
logger.log(Level.SEVERE, "failed to close group generator " + g, e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public void connect_and_server_goes_away() throws Exception {
try (JmxClient jmx_client = new JmxClient(jmx_server.url)) {
try {
jmx_client.getConnection(); // Ensure connection exists.
} catch (Throwable t) {
} catch (Exception e) {
/* Ensure we catch any exception from getConnection, just in case. */
throw new AssertionError("getConnection() may not throw at this point", t);
throw new AssertionError("getConnection() may not throw at this point", e);
}

jmx_server.stop(); // Server going down...
Expand Down Expand Up @@ -277,9 +277,9 @@ public void opt_connect_and_server_goes_away() throws Exception {
try (JmxClient jmx_client = new JmxClient(jmx_server.url)) {
try {
jmx_client.getConnection(); // Ensure connection exists.
} catch (Throwable t) {
} catch (Exception e) {
/* Ensure we catch any exception from getConnection, just in case. */
throw new AssertionError("getConnection() may not throw at this point", t);
throw new AssertionError("getConnection() may not throw at this point", e);
}

jmx_server.stop(); // Server going down...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public AlreadyStartedException(String msg) {
super(msg);
}

public AlreadyStartedException(Throwable t) {
super(t);
public AlreadyStartedException(Exception e) {
super(e);
}

public AlreadyStartedException(String msg, Throwable t) {
super(msg, t);
public AlreadyStartedException(String msg, Exception e) {
super(msg, e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class BufferedIterator<T> {
private final ExecutorService work_queue_;
private final Iterator<? extends T> iter_;
private final List<T> queue_;
private Throwable t_ = null;
private Exception exception = null;
private boolean at_end_;
private final int queue_size_;
private boolean running_ = false;
Expand Down Expand Up @@ -76,16 +76,16 @@ public static <T> Stream<T> stream(ExecutorService work_queue, Stream<? extends
}

public synchronized boolean atEnd() {
return at_end_ && queue_.isEmpty() && t_ == null;
return at_end_ && queue_.isEmpty() && exception == null;
}

public synchronized boolean nextAvail() {
return !queue_.isEmpty() || t_ != null;
return !queue_.isEmpty() || exception != null;
}

@SneakyThrows
public synchronized T next() {
if (t_ != null) throw t_;
if (exception != null) throw exception;
try {
final T result = queue_.remove(0);
fire_();
Expand Down Expand Up @@ -113,7 +113,7 @@ public void setWakeup(Runnable wakeup) {
private synchronized void fire_() {
if (at_end_) return;
if (queue_.size() >= queue_size_) return;
if (t_ != null) return;
if (exception != null) return;

if (!running_) {
running_ = true;
Expand Down Expand Up @@ -153,11 +153,11 @@ private void add_next_iter_() {
running_ = false;
fire_();
}
} catch (Throwable t) {
} catch (Exception e) {
final Optional<Runnable> wakeup;
synchronized(this) {
running_ = false;
t_ = t;
exception = e;
wakeup = wakeup_;
wakeup_ = Optional.empty();
}
Expand Down

0 comments on commit 71d432f

Please sign in to comment.