Skip to content

Commit

Permalink
findbugs: fix warnings in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Borges committed Oct 25, 2012
1 parent 9a084a6 commit fa87784
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ private void consume(Session session, Queue queue, int numMessages, String node)

}

private class FailoverListenerImpl implements FailoverEventListener
private static class FailoverListenerImpl implements FailoverEventListener
{

public void failoverEvent(FailoverEventType eventType) {
System.out.println("Failover event triggered :"+ eventType.toString());
}

public void failoverEvent(FailoverEventType eventType)
{
System.out.println("Failover event triggered :" + eventType.toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void onMessage(final Message notif)
while (propertyNames.hasMoreElements())
{
String propertyName = (String)propertyNames.nextElement();
System.out.format(" %s: %s\n", propertyName, notif.getObjectProperty(propertyName));
System.out.format(" %s: %s%n", propertyName, notif.getObjectProperty(propertyName));
}
}
catch (JMSException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean runExample() throws Exception
for (int i = numMessages / 3; i < (numMessages / 3) * 2; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();

Expand All @@ -134,7 +134,7 @@ public boolean runExample() throws Exception
for (int i = (numMessages / 3) * 2; i < numMessages; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean runExample() throws Exception
killServer(0);

// Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the
// backup server has occured
// backup server has occurred
try
{
message0.acknowledge();
Expand All @@ -112,7 +112,7 @@ public boolean runExample() throws Exception
for (int i = numMessages / 2; i < numMessages; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean runExample() throws Exception
for (int i = numMessages / 3; i < (numMessages / 3) * 2; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();

Expand All @@ -134,7 +134,7 @@ public boolean runExample() throws Exception
for (int i = (numMessages / 3) * 2; i < numMessages; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class ExampleListener implements MessageListener
{
public static String lastMessage = null;
protected static String lastMessage = null;

public void onMessage(Message message)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.hornetq.common.example.DummyXid;
import org.hornetq.common.example.HornetQExample;
import org.hornetq.utils.UUIDGenerator;
import org.jboss.netty.util.CharsetUtil;

/**
* A simple JMS example showing how to administer un-finished transactions.
Expand All @@ -51,7 +52,7 @@ public class XAHeuristicExample extends HornetQExample

private final ArrayList<String> receiveHolder = new ArrayList<String>();

private final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi";
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi";

public static void main(final String[] args)
{
Expand Down Expand Up @@ -101,7 +102,8 @@ public boolean runExample() throws Exception
TextMessage worldMessage = session.createTextMessage("world");

// Step 12. create a transaction
Xid xid1 = new DummyXid("xa-example1".getBytes(), 1, UUIDGenerator.getInstance()
Xid xid1 =
new DummyXid("xa-example1".getBytes(CharsetUtil.ISO_8859_1), 1, UUIDGenerator.getInstance()
.generateStringUUID()
.getBytes());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hornetq.common.example.DummyXid;
import org.hornetq.common.example.HornetQExample;
import org.hornetq.utils.UUIDGenerator;
import org.jboss.netty.util.CharsetUtil;

/**
* A simple JMS example showing the usage of XA support in JMS.
Expand Down Expand Up @@ -84,7 +85,8 @@ public boolean runExample() throws Exception
TextMessage worldMessage = session.createTextMessage("world");

// Step 12. create a transaction
Xid xid1 = new DummyXid("xa-example1".getBytes(), 1, UUIDGenerator.getInstance()
Xid xid1 =
new DummyXid("xa-example1".getBytes(CharsetUtil.US_ASCII), 1, UUIDGenerator.getInstance()
.generateStringUUID()
.getBytes());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.hornetq.common.example.DummyXid;
import org.hornetq.common.example.HornetQExample;
import org.hornetq.utils.UUIDGenerator;
import org.jboss.netty.util.CharsetUtil;

/**
* A simple JMS example showing the usage of XA support in JMS.
Expand Down Expand Up @@ -92,7 +93,8 @@ public boolean runExample() throws Exception
TextMessage worldMessage = session.createTextMessage("world");

// Step 12. create a transaction
Xid xid1 = new DummyXid("xa-example1".getBytes(), 1, UUIDGenerator.getInstance()
Xid xid1 =
new DummyXid("xa-example1".getBytes(CharsetUtil.UTF_8), 1, UUIDGenerator.getInstance()
.generateStringUUID()
.getBytes());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public boolean runExample() throws Exception
}
}

public class DummyXAResource implements XAResource
public static class DummyXAResource implements XAResource
{

public DummyXAResource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ protected void setUp() throws Exception
}

/**
* Test if two servers is running and one of them is failing that we
* trigger the expected events for {@link FailoverEventListener}
* Test if two servers are running and one of them is failing, that we trigger the expected
* events for {@link FailoverEventListener}
* @throws Exception
*/
public void testFailoverListerCall() throws Exception
public void testFailoverListenerCall() throws Exception
{
createSessionFactory(2);

Expand Down Expand Up @@ -277,7 +277,7 @@ private ClientSession sendAndConsume(final ClientSessionFactory sf, final boolea

public class SessionFactoryFailoverListener implements FailoverEventListener {

private ArrayList<FailoverEventType> failoverTypeEvent = new ArrayList<FailoverEventType>();
private final ArrayList<FailoverEventType> failoverTypeEvent = new ArrayList<FailoverEventType>();

public ArrayList<FailoverEventType> getFailoverEventType()
{
Expand Down

0 comments on commit fa87784

Please sign in to comment.