Skip to content

Commit

Permalink
Fix PMD:AvoidUncheckedExceptionsInSignatures (cluster)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Jul 11, 2022
1 parent 481752d commit 9f1afe4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 15 deletions.
Expand Up @@ -82,8 +82,9 @@ public void reloadConfig() throws BrokerException {
config.reloadProps(Globals.getConfigName(), props, false);
}

/** @throws NoSuchElementException */
@Override
protected String addBroker(MQAddress url, boolean isLocal, boolean isConfig, UID uid) throws NoSuchElementException, BrokerException {
protected String addBroker(MQAddress url, boolean isLocal, boolean isConfig, UID uid) throws BrokerException {

if (!initialized) {
throw new RuntimeException("Cluster not initialized");
Expand Down
Expand Up @@ -583,7 +583,7 @@ public ClusteredBroker getBroker(String brokerid) {
* @return the uid associated with the new broker
*/
@Override
public String activateBroker(MQAddress URL, UID uid, String instName, Object userData) throws NoSuchElementException, BrokerException {
public String activateBroker(MQAddress URL, UID uid, String instName, Object userData) throws BrokerException {
if (!initialized) {
throw new RuntimeException("Cluster not initialized");
}
Expand All @@ -610,7 +610,7 @@ public String activateBroker(MQAddress URL, UID uid, String instName, Object use
* @return the uid associated with the new broker
*/
@Override
public String activateBroker(String brokerid, UID uid, String instName, Object userData) throws NoSuchElementException, BrokerException {
public String activateBroker(String brokerid, UID uid, String instName, Object userData) throws BrokerException {
ClusteredBroker cb = getBroker(brokerid);
if (cb == null) {
throw new BrokerException("Unknown broker " + brokerid);
Expand All @@ -637,7 +637,8 @@ protected ClusteredBroker updateBrokerOnDeactivation(ClusteredBroker broker, Obj
return broker;
}

protected String addBroker(MQAddress URL, boolean isLocal, boolean config, UID sid) throws NoSuchElementException, BrokerException {
/** @throws NoSuchElementException */
protected String addBroker(MQAddress URL, boolean isLocal, boolean config, UID sid) throws BrokerException {
ClusteredBroker cb = newClusteredBroker(URL, isLocal, sid);
((ClusteredBrokerImpl) cb).setConfigBroker(config);
synchronized (allBrokers) {
Expand Down Expand Up @@ -670,7 +671,7 @@ protected void removeFromAllBrokers(String brokerName) {
* @throws NoSuchElementException if the broker can not be found in the cluster.
*/
@Override
public void deactivateBroker(MQAddress URL, Object userData) throws NoSuchElementException {
public void deactivateBroker(MQAddress URL, Object userData) {
if (!initialized) {
throw new RuntimeException("Cluster not initialized");
}
Expand All @@ -693,7 +694,7 @@ public void deactivateBroker(MQAddress URL, Object userData) throws NoSuchElemen
* @see ClusterManagerImpl#setMQAddress
*/
@Override
public void deactivateBroker(String brokerid, Object userData) throws NoSuchElementException {
public void deactivateBroker(String brokerid, Object userData) {
if (!initialized) {
throw new RuntimeException("Cluster not initialized");
}
Expand Down
Expand Up @@ -438,7 +438,7 @@ public BrokerState getState() {
* @see ConfigListener
*/
@Override
public void setState(BrokerState state) throws IllegalAccessException, IllegalStateException, IllegalArgumentException {
public void setState(BrokerState state) throws IllegalAccessException {
BrokerState oldState = this.state;
this.state = state;
parent.brokerChanged(ClusterReason.STATE_CHANGED, this.getBrokerName(), oldState, this.state, null, null);
Expand Down
Expand Up @@ -189,7 +189,7 @@ protected LinkedHashSet parseBrokerList() throws MalformedURLException {
* @return the uid associated with the new broker
*/
@Override
protected String addBroker(MQAddress URL, boolean isLocal, boolean isConfig, UID brokerUID) throws NoSuchElementException, BrokerException {
protected String addBroker(MQAddress URL, boolean isLocal, boolean isConfig, UID brokerUID) throws BrokerException {
// NOTE we are always a config broker in the HA case, ignore this argument

if (!initialized) {
Expand Down Expand Up @@ -273,7 +273,7 @@ private ClusteredBroker updateBroker(ClusteredBroker broker) {
* @see ClusterManagerImpl#setMQAddress
*/
@Override
public void deactivateBroker(String brokerid, Object userData) throws NoSuchElementException {
public void deactivateBroker(String brokerid, Object userData) {
if (!initialized) {
throw new RuntimeException("Cluster not initialized");
}
Expand Down
Expand Up @@ -716,7 +716,7 @@ public void setStateFailoverFailed(UID brokerSession) throws Exception {
* @throws IndexOutOfBoundsException if the state value is not allowed.
*/
@Override
public void setState(BrokerState newstate) throws IllegalAccessException, IllegalStateException, IndexOutOfBoundsException {
public void setState(BrokerState newstate) throws IllegalAccessException {
if (!local && newstate != BrokerState.FAILOVER_PROCESSED && newstate != BrokerState.FAILOVER_STARTED && newstate != BrokerState.FAILOVER_COMPLETE
&& newstate != BrokerState.FAILOVER_FAILED) {
// a remote broker should only be updated during failover
Expand Down
Expand Up @@ -292,8 +292,9 @@ public ClusteredBroker getBroker(String brokerid) {
return super.getBroker(brokerid);
}

/** @throws NoSuchElementException */
@Override
protected String addBroker(MQAddress url, boolean isLocal, boolean isConfig, UID uid) throws NoSuchElementException, BrokerException {
protected String addBroker(MQAddress url, boolean isLocal, boolean isConfig, UID uid) throws BrokerException {

if (!initialized) {
throw new RuntimeException("Cluster not initialized");
Expand Down
Expand Up @@ -176,8 +176,12 @@ public void setRemoteBrokerStateOnDeactivation() {
state = BrokerState.INITIALIZING;
}

/**
* @throws IllegalStateException
* @throws IndexOutOfBoundsException
*/
@Override
public void setState(BrokerState newstate) throws IllegalAccessException, IllegalStateException, IndexOutOfBoundsException {
public void setState(BrokerState newstate) throws IllegalAccessException {
if (!local) {
// no-op
}
Expand Down
Expand Up @@ -49,9 +49,11 @@ public boolean hasNext() {

/**
* Caller must catch RuntimeException and getCause
*
* @throws RuntimeException
*/
@Override
public Object next() throws RuntimeException {
public Object next() {
try {

Consumer c = ClusterConsumerInfo.readConsumer(dis);
Expand Down
Expand Up @@ -59,9 +59,11 @@ public boolean hasNext() {

/**
* Caller must catch RuntimeException and getCause
*
* @throws RuntimeException
*/
@Override
public Object next() throws RuntimeException {
public Object next() {
try {
ConsumerUID cid = ClusterConsumerInfo.readConsumerUID(dis);
if (from != null) {
Expand Down
Expand Up @@ -42,9 +42,11 @@ public boolean hasNext() {

/**
* Caller must catch RuntimeException and getCause
*
* @throws RuntimeException
*/
@Override
public Object next() throws RuntimeException {
public Object next() {
try {
String dname = dis.readUTF();
String clientID = dis.readUTF();
Expand Down

0 comments on commit 9f1afe4

Please sign in to comment.