Commit c70869b0 authored by afreyssin's avatar afreyssin
Browse files

Fixes minor issues in code.

parent c48bb023
......@@ -190,26 +190,21 @@ class InboundConsumer implements javax.jms.ServerSessionPool
if (serverSessions < maxWorks) {
// Allocates a new ServerSession
return newSession();
} else {
// Wait for a free ServerSession
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
"ServerSessionPool waits for "
+ "a free ServerSession.");
pool.wait();
return (ServerSession) pool.remove(0);
}
} else {
// Allocates a new ServerSession
return newSession();
// Wait for a free ServerSession
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
"ServerSessionPool waits for a free ServerSession.");
pool.wait();
return (ServerSession) pool.remove(0);
}
} else {
return (ServerSession) pool.remove(0);
// Allocates a new ServerSession
return newSession();
}
return (ServerSession) pool.remove(0);
}
} catch (Exception exc) {
throw new JMSException("Error while getting server session from pool: "
+ exc);
throw new JMSException("Error while getting server session from pool: " + exc);
}
}
......
......@@ -1621,11 +1621,8 @@ public final class JoramAdapter implements javax.resource.spi.ResourceAdapter, J
try {
if (name.startsWith(PREFIX_NAME))
return name.substring(PREFIX_NAME.length());
else
return name;
} catch (Exception e) {
return name;
}
} catch (Exception e) {}
return name;
}
/** Binds an object to the JNDI context. */
......
......@@ -325,13 +325,11 @@ public class RAConfig {
// search fileName in jar file.
InputStream reader = zipFile.getInputStream(currEntry);
res = extractFromJAR(fileName,reader);
if (res == null)
continue;
else {
// the fileName found in jar file.
reader.close();
break;
}
if (res == null) continue;
// the fileName found in jar file.
reader.close();
break;
}
}
// extract the fileName from InputStream
......
......@@ -532,9 +532,8 @@ public class FactoryParameters implements java.io.Serializable, Cloneable {
if (it.hasNext()) cns.append(INTERCEPTOR_CLASS_NAME_SEPARATOR);
}
return cns.toString();
} else {
return null;
}
return null;
}
private void setListInInterceptorClassName(String pListInterceptorClassName){
......
......@@ -366,8 +366,7 @@ public class Message implements javax.jms.Message {
public final int getJMSDeliveryMode() throws JMSException {
if (momMsg.persistent)
return javax.jms.DeliveryMode.PERSISTENT;
else
return javax.jms.DeliveryMode.NON_PERSISTENT;
return javax.jms.DeliveryMode.NON_PERSISTENT;
}
/**
......@@ -805,11 +804,9 @@ public class Message implements javax.jms.Message {
if (name.startsWith("JMSX")) {
if (name.equals("JMSXDeliveryCount"))
return new Integer(momMsg.deliveryCount);
else
return momMsg.getOptionalHeader(name);
} else {
return momMsg.getProperty(name);
return momMsg.getOptionalHeader(name);
}
return momMsg.getProperty(name);
}
/**
......@@ -880,8 +877,8 @@ public class Message implements javax.jms.Message {
/**
* Method preparing the message for sending; resets header values, and
* serializes the body (done in subclasses).
*
* @exception MessageFormatException If an error occurs while serializing.
* @throws JMSException
*/
protected void prepare() throws JMSException {
momMsg.redelivered = false;
......
......@@ -363,11 +363,9 @@ public class MessageConsumer implements javax.jms.MessageConsumer {
*/
public javax.jms.Message receiveNoWait() throws JMSException {
checkClosed();
if (sess.getConnection().isStopped()) {
return null;
} else {
return sess.receive(-1, 0, this, targetName, selector, queueMode);
}
if (sess.getConnection().isStopped()) return null;
return sess.receive(-1, 0, this, targetName, selector, queueMode);
}
/**
......
......@@ -365,31 +365,30 @@ abstract class MessageConsumerListener implements ReplyListener {
BasicLevel.DEBUG, "MessageConsumerListener.replyReceived(" +
reply + ')');
if (status == Status.CLOSE) {
if (status == Status.CLOSE)
throw new AbortedRequestException();
} else {
if (queueMode) {
// 1- Change the status before pushing the
// messages into the session queue.
setReceiveStatus(ReceiveStatus.CONSUMING_REPLY);
}
try {
ConsumerMessages cm = (ConsumerMessages)reply;
// 2- increment messageCount (synchronized)
messageCount += cm.getMessageCount();
pushMessages(cm);
} catch (StoppedQueueException exc) {
throw new AbortedRequestException();
} catch (JMSException exc) {
throw new AbortedRequestException();
}
if (queueMode) {
return true;
} else {
return false;
}
if (queueMode) {
// 1- Change the status before pushing the messages into the session queue.
setReceiveStatus(ReceiveStatus.CONSUMING_REPLY);
}
try {
ConsumerMessages cm = (ConsumerMessages)reply;
// 2- increment messageCount (synchronized)
messageCount += cm.getMessageCount();
pushMessages(cm);
} catch (StoppedQueueException exc) {
throw new AbortedRequestException();
} catch (JMSException exc) {
throw new AbortedRequestException();
}
if (queueMode) {
return true;
}
return false;
}
/**
......
......@@ -149,21 +149,18 @@ public class MultiSessionConsumer extends MessageConsumerListener
"MultiSessionConsumer -> connection consumer closed");
}
public void onMessage(
Message msg, MessageListener listener, int ackMode)
throws JMSException {
public void onMessage(Message msg, MessageListener listener, int ackMode) throws JMSException {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "MultiSessionConsumer.onMessage(" + msg + ')');
try {
synchronized (this) {
if (getStatus() == Status.CLOSE) {
if (getStatus() == Status.CLOSE)
throw new javax.jms.IllegalStateException("Message listener closed");
} else {
if (nbActivatedListeners == 0) {
setStatus(Status.ON_MSG);
}
nbActivatedListeners++;
if (nbActivatedListeners == 0) {
setStatus(Status.ON_MSG);
}
nbActivatedListeners++;
}
activateListener(msg, listener, ackMode);
} finally {
......
......@@ -1102,8 +1102,8 @@ public class Session implements javax.jms.Session {
GetAdminTopicReply reply = (GetAdminTopicReply) requestor.request(new GetAdminTopicRequest());
if (reply.getId() != null)
return new Topic(reply.getId());
else
throw new JMSException("AdminTopic could not be retrieved.");
throw new JMSException("AdminTopic could not be retrieved.");
} catch (JMSException exc) {
throw exc;
} catch (Exception exc) {
......@@ -1730,12 +1730,12 @@ public class Session implements javax.jms.Session {
}
}
return msg;
} else {
return null;
}
} else {
return null;
}
return null;
}
} finally {
postReceive();
......
......@@ -217,8 +217,9 @@ public final class StreamMessage extends Message implements javax.jms.StreamMess
if (value == null) {
outputStream.writeInt(-1);
return;
} else
outputStream.writeInt(length);
}
outputStream.writeInt(length);
outputStream.write(value, offset, length);
} catch (IOException ioE) {
JMSException jE = new JMSException("Error while writing the value.");
......
......@@ -256,8 +256,7 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
if (reply.getFatherId() == null)
return null;
else
return new Topic(reply.getFatherId());
return new Topic(reply.getFatherId());
}
/**
......
......@@ -1321,7 +1321,7 @@ public final class AdminModule {
return localPort;
}
public static void abortRequest() throws JMSException, ConnectException {
public static void abortRequest() throws ConnectException {
if (wrapper == null)
throw new ConnectException("Administrator not connected.");
......
......@@ -168,14 +168,13 @@ public final class AdminRequestor {
String correlationId = requestMsg.getJMSMessageID();
while (true) {
replyMsg = consumer.receive(requestTimeout);
if (replyMsg == null) {
if (replyMsg == null)
throw new JMSException("Interrupted request");
} else {
if (correlationId.equals(replyMsg.getJMSCorrelationID())) break;
if (logger.isLoggable(BasicLevel.WARN))
logger.log(BasicLevel.WARN, "AdminRequestor.request() bad correlation identifier.");
}
if (correlationId.equals(replyMsg.getJMSCorrelationID())) break;
if (logger.isLoggable(BasicLevel.WARN))
logger.log(BasicLevel.WARN, "AdminRequestor.request() bad correlation identifier.");
}
} catch (JMSException exc) {
if (logger.isLoggable(BasicLevel.DEBUG))
......
......@@ -91,7 +91,7 @@ public class ClusterConnectionFactory extends org.objectweb.joram.client.jms.adm
/**
* Chooses a connection factory from the cluster definition.
*/
protected ConnectionFactory getConnectionFactory() throws JMSException {
protected ConnectionFactory getConnectionFactory() {
if ((cluster != null) && ! cluster.isEmpty()) {
ConnectionFactory cf = null;
String location = System.getProperty("location");
......
......@@ -135,12 +135,9 @@ public class Requestor implements ReplyListener, ErrorListener {
logger.log(BasicLevel.DEBUG, "Requestor.request(" + request + ',' + timeout + ')');
if (status != Status.INIT) {
if (status == Status.CLOSE) {
// throw new javax.jms.IllegalStateException("Closed requestor");
return null;
} else {
throw new javax.jms.IllegalStateException("Requestor already used");
}
if (status == Status.CLOSE) return null;
throw new javax.jms.IllegalStateException("Requestor already used");
}
mtpx.sendRequest(request, this);
setStatus(Status.RUN);
......@@ -195,16 +192,15 @@ public class Requestor implements ReplyListener, ErrorListener {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Requestor.replyReceived(" + reply + ')');
if (status == Status.RUN &&
reply.getCorrelationId() == requestId) {
if (status == Status.RUN && reply.getCorrelationId() == requestId) {
this.reply = reply;
setStatus(Status.DONE);
notify();
return true;
} else {
// The request has been aborted.
throw new AbortedRequestException();
}
// The request has been aborted.
throw new AbortedRequestException();
}
public synchronized void errorReceived(int replyId, JMSException exc) {
......
......@@ -23,8 +23,6 @@ package org.objectweb.joram.client.jms.ha.local;
import java.util.Timer;
import javax.jms.JMSException;
import org.objectweb.joram.client.jms.connection.RequestChannel;
import org.objectweb.joram.client.jms.local.LocalRequestChannel;
import org.objectweb.joram.mom.dest.AdminTopic;
......@@ -99,10 +97,10 @@ public class HALocalRequestChannel implements RequestChannel {
private LocalRequestChannel localRequestChannel;
public HALocalRequestChannel(Identity identity) throws JMSException {
public HALocalRequestChannel(Identity identity) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"HALocalConnection.<init>(" + identity + ')');
logger.log(BasicLevel.DEBUG, "HALocalConnection.<init>(" + identity + ')');
waitForStart();
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, " -> create the local connection");
......
......@@ -60,10 +60,10 @@ public class LocalRequestChannel implements RequestChannel, LocalRequestChannelM
private long receivedCount;
public LocalRequestChannel(Identity identity) throws JMSException {
public LocalRequestChannel(Identity identity) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"LocalConnection.<init>(" + identity + ')');
logger.log(BasicLevel.DEBUG, "LocalConnection.<init>(" + identity + ')');
this.identity = identity;
}
......
......@@ -106,8 +106,7 @@ public class SoapRequestChannel implements RequestChannel {
* @exception JMSSecurityException If the user identification is incorrect.
* @exception IllegalStateException If the server is not reachable.
*/
public SoapRequestChannel(FactoryParameters params,
Identity identity) throws JMSException {
public SoapRequestChannel(FactoryParameters params, Identity identity) {
factParams = params;
this.identity = identity;
}
......@@ -369,19 +368,10 @@ public class SoapRequestChannel implements RequestChannel {
nextSleep = nextSleep * 2;
continue;
}
// If timer is over, throwing an IllegalStateException:
else {
long attemptsT = (System.currentTimeMillis() - startTime) / 1000;
throw new IllegalStateException("Could not open the connection"
+ " with server on host "
+ factParams.getHost()
+ " and port "
+ factParams.getPort()
+ " after " + attemptsC
+ " attempts during "
+ attemptsT + " secs: "
+ error);
}
long attemptsT = (System.currentTimeMillis() - startTime) / 1000;
throw new IllegalStateException("Could not open the connection with server " + factParams.getHost() + '/' + factParams.getPort() +
" after " + attemptsC + " attempts during " + attemptsT + "s: " + error);
}
}
}
......
......@@ -75,7 +75,7 @@ public class SoapServiceStarter {
System.out.println("Starting the " + serverName + " embedded server.");
org.apache.soap.rpc.Response resp = call.invoke(url,"");
call.invoke(url,"");
System.out.println("Server " + serverId + " started.");
}
......
......@@ -219,16 +219,16 @@ public class ReliableTcpConnection {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"ReliableTcpConnection.ackPendingMessages(" + ackId + ')');
synchronized (pendingMessages) {
while (pendingMessages.size() > 0) {
TcpMessage pendingMsg =
(TcpMessage)pendingMessages.elementAt(0);
TcpMessage pendingMsg = (TcpMessage)pendingMessages.elementAt(0);
if (ackId < pendingMsg.id) {
// It's an old acknowledge
break;
} else {
pendingMessages.removeElementAt(0);
}
pendingMessages.removeElementAt(0);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment