This closes #685
This commit is contained in:
commit
5fe10d044a
|
@ -84,9 +84,9 @@ public abstract class AbstractJDBCDriver {
|
|||
public void destroy() throws Exception {
|
||||
try {
|
||||
connection.setAutoCommit(false);
|
||||
Statement statement = connection.createStatement();
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.executeUpdate("DROP TABLE " + sqlProvider.getTableName());
|
||||
statement.close();
|
||||
}
|
||||
connection.commit();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
|
|
|
@ -135,9 +135,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
|
|||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
ObjectInputStream ois = new ObjectInputStreamWithClassLoader(bais);
|
||||
try (ObjectInputStream ois = new ObjectInputStreamWithClassLoader(new ByteArrayInputStream(data))) {
|
||||
Serializable object = (Serializable) ois.readObject();
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -164,10 +164,8 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
break;
|
||||
case org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE:
|
||||
if (messageCompressed) {
|
||||
InputStream ois = new ByteArrayInputStream(contents);
|
||||
ois = new InflaterInputStream(ois);
|
||||
|
||||
try (org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream()) {
|
||||
try (InputStream ois = new InflaterInputStream(new ByteArrayInputStream(contents));
|
||||
org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream()) {
|
||||
byte[] buf = new byte[1024];
|
||||
int n = ois.read(buf);
|
||||
while (n != -1) {
|
||||
|
@ -258,8 +256,7 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
case org.apache.activemq.artemis.api.core.Message.BYTES_TYPE:
|
||||
if (messageCompressed) {
|
||||
Inflater inflater = new Inflater();
|
||||
org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream();
|
||||
try {
|
||||
try (org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream()) {
|
||||
int length = ByteSequenceData.readIntBig(contents);
|
||||
contents.offset = 0;
|
||||
byte[] data = Arrays.copyOfRange(contents.getData(), 4, contents.getLength());
|
||||
|
@ -275,7 +272,6 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
}
|
||||
finally {
|
||||
inflater.end();
|
||||
decompressed.close();
|
||||
}
|
||||
}
|
||||
body.writeBytes(contents.data, contents.offset, contents.length);
|
||||
|
@ -506,10 +502,10 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
if (isCompressed) {
|
||||
out = new DeflaterOutputStream(out);
|
||||
}
|
||||
DataOutputStream dataOut = new DataOutputStream(out);
|
||||
try (DataOutputStream dataOut = new DataOutputStream(out)) {
|
||||
MarshallingSupport.writeUTF8(dataOut, text.toString());
|
||||
bytes = bytesOut.toByteArray();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (coreType == org.apache.activemq.artemis.api.core.Message.MAP_TYPE) {
|
||||
|
@ -522,9 +518,9 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
if (isCompressed) {
|
||||
os = new DeflaterOutputStream(os);
|
||||
}
|
||||
DataOutputStream dataOut = new DataOutputStream(os);
|
||||
try (DataOutputStream dataOut = new DataOutputStream(os)) {
|
||||
MarshallingSupport.marshalPrimitiveMap(map, dataOut);
|
||||
dataOut.close();
|
||||
}
|
||||
bytes = out.toByteArray();
|
||||
}
|
||||
else if (coreType == org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE) {
|
||||
|
@ -545,7 +541,7 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
if (isCompressed) {
|
||||
out = new DeflaterOutputStream(bytesOut);
|
||||
}
|
||||
DataOutputStream dataOut = new DataOutputStream(out);
|
||||
try (DataOutputStream dataOut = new DataOutputStream(out)) {
|
||||
|
||||
boolean stop = false;
|
||||
while (!stop && buffer.readable()) {
|
||||
|
@ -599,7 +595,7 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
break;
|
||||
}
|
||||
}
|
||||
dataOut.close();
|
||||
}
|
||||
bytes = bytesOut.toByteArray();
|
||||
}
|
||||
else if (coreType == org.apache.activemq.artemis.api.core.Message.BYTES_TYPE) {
|
||||
|
@ -608,10 +604,9 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
buffer.readBytes(bytes);
|
||||
if (isCompressed) {
|
||||
int length = bytes.length;
|
||||
org.apache.activemq.util.ByteArrayOutputStream compressed = new org.apache.activemq.util.ByteArrayOutputStream();
|
||||
compressed.write(new byte[4]);
|
||||
Deflater deflater = new Deflater();
|
||||
try {
|
||||
try (org.apache.activemq.util.ByteArrayOutputStream compressed = new org.apache.activemq.util.ByteArrayOutputStream()) {
|
||||
compressed.write(new byte[4]);
|
||||
deflater.setInput(bytes);
|
||||
deflater.finish();
|
||||
byte[] bytesBuf = new byte[1024];
|
||||
|
@ -625,7 +620,6 @@ public class OpenWireMessageConverter implements MessageConverter {
|
|||
}
|
||||
finally {
|
||||
deflater.end();
|
||||
compressed.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,12 +88,11 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase {
|
|||
manager.register(connectionFactory2, null, null, new ConcurrentHashMap<String, String>());
|
||||
|
||||
for (XARecoveryConfig resource :manager.getResources()) {
|
||||
ServerLocator locator = resource.createServerLocator();
|
||||
try (ServerLocator locator = resource.createServerLocator();
|
||||
ClientSessionFactory factory = locator.createSessionFactory();
|
||||
ClientSession session = factory.createSession();
|
||||
session.close();
|
||||
factory.close();
|
||||
locator.close();
|
||||
ClientSession session = factory.createSession()) {
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -142,8 +142,7 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase {
|
|||
@Test
|
||||
public void testReceiveImmediateWithZeroWindow2() throws Exception {
|
||||
ActiveMQServer server = createServer(true);
|
||||
ServerLocator locator = createInVMNonHALocator();
|
||||
try {
|
||||
try (ServerLocator locator = createInVMNonHALocator()) {
|
||||
server.start();
|
||||
|
||||
locator.setConsumerWindowSize(0);
|
||||
|
@ -183,9 +182,6 @@ public class ConsumerWindowSizeTest extends ActiveMQTestBase {
|
|||
session1.close();
|
||||
sessionProd.close();
|
||||
}
|
||||
finally {
|
||||
locator.close();
|
||||
}
|
||||
}
|
||||
|
||||
// https://jira.jboss.org/jira/browse/HORNETQ-385
|
||||
|
|
|
@ -641,30 +641,15 @@ public class ActiveMQVertxUnitTest extends ActiveMQTestBase {
|
|||
private ClientMessage receiveFromQueue(String queueName) throws Exception {
|
||||
ClientMessage msg = null;
|
||||
|
||||
ServerLocator locator = null;
|
||||
ClientSessionFactory sf = null;
|
||||
ClientSession session = null;
|
||||
try (ServerLocator locator = createInVMNonHALocator();
|
||||
ClientSessionFactory sf = createSessionFactory(locator);
|
||||
ClientSession session = sf.createSession(false, true, true)) {
|
||||
|
||||
try {
|
||||
locator = createInVMNonHALocator();
|
||||
|
||||
sf = createSessionFactory(locator);
|
||||
|
||||
session = sf.createSession(false, true, true);
|
||||
ClientConsumer consumer = session.createConsumer(queueName);
|
||||
session.start();
|
||||
msg = consumer.receive(60 * 1000);
|
||||
msg.acknowledge();
|
||||
}
|
||||
finally {
|
||||
if (session != null) {
|
||||
session.commit();
|
||||
session.close();
|
||||
}
|
||||
if (sf != null)
|
||||
sf.close();
|
||||
if (locator != null)
|
||||
locator.close();
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue