Remove dead code and unused imports

Fix dead exception case

Exception was previously being thrown if replyTo address was null,
however this was unreachable code as replyTo is always assigned
a new Address. Logic has been changed to throw the same exception
if the default response routing key is found to be null.
This commit is contained in:
Chris Beams
2010-07-29 18:00:58 +02:00
parent ba50092b37
commit 4bf6c675b8
13 changed files with 5 additions and 293 deletions

View File

@@ -1,242 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.amqp.core;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author Mark Fisher
*/
public class SimpleMessageProperties implements MessageProperties {
private static final String DEFAULT_CHARSET = "UTF-8";
private volatile String defaultCharset = DEFAULT_CHARSET;
private volatile String appId;
private volatile String clusterId;
private volatile String contentEncoding;
private volatile long contentLength;
private volatile String contentType = MessageProperties.CONTENT_TYPE_BYTES;
private volatile byte[] correlationId;
private volatile MessageDeliveryMode deliveryMode;
private volatile long deliveryTag;
private volatile String expiration;
private volatile Map<String, Object> headers = new HashMap<String, Object>();
private volatile Integer messageCount;
private volatile String messageId;
private volatile Integer priority;
private volatile String receivedExchange;
private volatile String receivedRoutingKey;
private volatile Address replyTo;
private volatile Date timestamp;
private volatile String type;
private volatile String userId;
private volatile Boolean redelivered;
public String getAppId() {
return this.appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getClusterId() {
return this.clusterId;
}
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
public String getContentEncoding() {
return this.contentEncoding;
}
public void setContentEncoding(String contentEncoding) {
this.contentEncoding = contentEncoding;
}
public long getContentLength() {
return this.contentLength;
}
public void setContentLength(long contentLength) {
this.contentLength = contentLength;
}
public String getContentType() {
return this.contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public byte[] getCorrelationId() {
return this.correlationId;
}
public void setCorrelationId(byte[] correlationId) {
this.correlationId = correlationId;
}
public MessageDeliveryMode getDeliveryMode() {
return this.deliveryMode;
}
public void setDeliveryMode(MessageDeliveryMode deliveryMode) {
this.deliveryMode = deliveryMode;
}
public long getDeliveryTag() {
return this.deliveryTag;
}
public void setDeliveryTag(long deliveryTag) {
this.deliveryTag = deliveryTag;
}
public String getExpiration() {
return this.expiration;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
public Map<String, Object> getHeaders() {
return this.headers;
}
public void setHeaders(Map<String, Object> headers) {
this.headers = headers;
}
public Integer getMessageCount() {
return this.messageCount;
}
public void setMessageCount(Integer messageCount) {
this.messageCount = messageCount;
}
public String getMessageId() {
return this.messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public Integer getPriority() {
return this.priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public String getReceivedExchange() {
return this.receivedExchange;
}
public void setReceivedExchange(String receivedExchange) {
this.receivedExchange = receivedExchange;
}
public String getReceivedRoutingKey() {
return this.receivedRoutingKey;
}
public void setReceivedRoutingKey(String receivedRoutingKey) {
this.receivedRoutingKey = receivedRoutingKey;
}
public Address getReplyTo() {
return this.replyTo;
}
public void setReplyTo(Address replyTo) {
this.replyTo = replyTo;
}
public Date getTimestamp() {
return this.timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public String getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Boolean isRedelivered() {
return this.redelivered;
}
public void setRedelivered(Boolean redelivered) {
this.redelivered = redelivered;
}
public void setDefaultCharset(String defaultCharset) {
this.defaultCharset = defaultCharset;
}
public void setHeader(String key, Object value) {
this.headers.put(key, value);
}
}

View File

@@ -61,7 +61,6 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
if (result instanceof OtpErlangTuple) {
OtpErlangTuple msg = (OtpErlangTuple)result;
OtpErlangObject[] elements = msg.elements();
if (msg.elementAt(0) instanceof OtpErlangAtom)
{
OtpErlangAtom responseAtom = (OtpErlangAtom)msg.elementAt(0);

View File

@@ -72,7 +72,6 @@ public class Background {
{
StringBuffer escaped;
String[] execCmd;
Runtime r;
escaped = new StringBuffer();
for(int i=0; i<cmd.length; i++){
@@ -105,10 +104,6 @@ public class Background {
File errFile, boolean appendErr)
throws IOException
{
String[] logargs;
String[] execCmd;
ArrayList tmpCmd = new ArrayList();
Runtime r;
ArrayList<String> tmpCmd = new ArrayList<String>();
tmpCmd.add("cmd");
@@ -126,7 +121,7 @@ public class Background {
(appendErr == true ? ">>" : " >") +
Escape.escape(errFile.getAbsolutePath()));
Process p = Runtime.getRuntime().exec((String [])tmpCmd.toArray(cmd));
Runtime.getRuntime().exec((String [])tmpCmd.toArray(cmd));
}
public static void main(String[] args) throws Exception {

View File

@@ -30,7 +30,7 @@ public class Escape {
* (such as whitespace, quotes, slashes, etc.)
*/
public static String escape(String in){
char[] inChars, outChars, resChars;
char[] inChars, outChars;
int numOut;
inChars = new char[in.length()];

View File

@@ -112,8 +112,6 @@ public class Execute {
return cmd;
}
else if ( Os.isFamily("windows") ) {
String osname =
System.getProperty("os.name").toLowerCase(Locale.US);
String[] cmd = {"cmd", "/c", "set" };
return cmd;
}

View File

@@ -73,16 +73,10 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
public void stop() {
if( ! running ) return;
try {
//if( log.isDebugEnabled() ) log.debug("Joining it");
// inputThread.interrupt();
inputThread.join(1000);
//if( log.isDebugEnabled() ) log.debug("Joined" );
} catch(InterruptedException e) {}
try {
//if( log.isDebugEnabled() ) log.debug("Joining it");
// errorThread.interrupt();
errorThread.join(1000);
//if( log.isDebugEnabled() ) log.debug("Joined" );
} catch(InterruptedException e) {}
try {
err.flush();
@@ -119,7 +113,4 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
return result;
}
private static org.apache.commons.logging.Log log=
org.apache.commons.logging.LogFactory.getLog( PumpStreamHandler.class );
}

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.amqp.rabbit.admin;
import java.util.Map;
/**
* This class represents a Queue that is configured on the RabbitMQ broker

View File

@@ -18,13 +18,11 @@ package org.springframework.amqp.rabbit.admin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.erlang.core.Application;
import org.springframework.erlang.core.Node;
import org.springframework.erlang.support.converter.ErlangConversionException;
@@ -34,9 +32,7 @@ import org.springframework.erlang.support.converter.SimpleErlangConverter;
import com.ericsson.otp.erlang.OtpErlangAtom;
import com.ericsson.otp.erlang.OtpErlangBinary;
import com.ericsson.otp.erlang.OtpErlangList;
import com.ericsson.otp.erlang.OtpErlangLong;
import com.ericsson.otp.erlang.OtpErlangObject;
import com.ericsson.otp.erlang.OtpErlangPid;
import com.ericsson.otp.erlang.OtpErlangTuple;
/***

View File

@@ -24,7 +24,6 @@ public class JInterfaceIntegrationTests {
@Test
public void rawApi() {
String markpCookie = "HRVDLVJTUELWREUSYOCA";
OtpConnection connection = null;
try {
OtpSelf self = new OtpSelf("rabbit-monitor");

View File

@@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.amqp.core.Queue;

View File

@@ -12,8 +12,6 @@ import org.springframework.test.context.ContextConfiguration;
@Ignore // only works on Windows at the moment
public class RabbitTestExecutionListenerIntegrationTests {
private static int count;
@Test
public void doNothing() throws InterruptedException {
Thread.sleep(1000);

View File

@@ -562,11 +562,11 @@ public class MessageListenerAdapter implements MessageListener, ChannelAwareMess
Address replyTo = request.getMessageProperties().getReplyTo();
if (replyTo == null) {
replyTo = new Address(defaultResponseRoutingKey);
if (replyTo == null) {
if (defaultResponseRoutingKey == null) {
throw new AmqpException("Cannot determine ReplyTo message property value: " +
"Request message does not contain reply-to property, and no default ReplyTo value set.");
}
replyTo = new Address(defaultResponseRoutingKey);
}
return replyTo.toString();
}

View File

@@ -16,19 +16,8 @@
package org.springframework.amqp.rabbit.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Map;
import org.junit.Test;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;
/**
*
@@ -38,16 +27,7 @@ public final class RabbitAdminNamespaceHandlerTests {
@Test
public void testParse() throws Exception {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"rabbitAdminNamespaceHandlerTests.xml", getClass());
/*
* Map<String, PropertyPlaceholderConfigurer> beans = applicationContext
.getBeansOfType(PropertyPlaceholderConfigurer.class);
assertFalse("No PropertyPlaceHolderConfigurer found", beans.isEmpty());
String s = (String) applicationContext.getBean("string");
assertEquals("No properties replaced", "bar", s);
*/
new ClassPathXmlApplicationContext("rabbitAdminNamespaceHandlerTests.xml", getClass());
}
}