This closes #683

This commit is contained in:
Clebert Suconic 2016-07-28 17:27:01 -04:00
commit c530ce1034
16 changed files with 67 additions and 46 deletions

View File

@ -81,7 +81,9 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM
@Override
public SequentialFile createSequentialFile(String fileName) {
try {
fileLocks.putIfAbsent(fileName, new Object());
if (fileLocks.get(fileName) == null) {
fileLocks.put(fileName, new Object());
}
JDBCSequentialFile file = new JDBCSequentialFile(this, fileName, executor, dbDriver, fileLocks.get(fileName));
files.add(file);
return file;

View File

@ -106,8 +106,11 @@ public class MQTTConnectionManager {
}
void disconnect() {
if (session == null) {
return;
}
try {
if (session != null && session.getSessionState() != null) {
if (session.getSessionState() != null) {
String clientId = session.getSessionState().getClientId();
if (clientId != null)
CONNECTED_CLIENTS.remove(clientId);

View File

@ -262,7 +262,7 @@ public abstract class UnaryExpression implements Expression {
return false;
}
final BinaryExpression that = (BinaryExpression) o;
final UnaryExpression that = (UnaryExpression) o;
if (!this.getExpressionSymbol().equals(that.getExpressionSymbol())) {
return false;

View File

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.activemq.artemis.selector.filter;
import org.apache.activemq.artemis.selector.impl.SelectorParser;
import org.junit.Assert;
import org.junit.Test;
public class UnaryExpressionTest {
@Test
public void testEquals() throws Exception {
BooleanExpression expr1 = UnaryExpression.createNOT(SelectorParser.parse("x = 1"));
BooleanExpression expr2 = UnaryExpression.createNOT(SelectorParser.parse("x = 1"));
Assert.assertTrue("Created unary expression 1", expr1 instanceof UnaryExpression);
Assert.assertTrue("Created unary expression 2", expr2 instanceof UnaryExpression);
Assert.assertEquals("Unary expressions are equal", expr1, expr2);
}
}

View File

@ -89,7 +89,7 @@ public class InMemoryDirectoryServiceFactory implements DirectoryServiceFactory
*/
@Override
public void init(String name) throws Exception {
if ((directoryService != null) && directoryService.isStarted()) {
if ((directoryService == null) || directoryService.isStarted()) {
return;
}

View File

@ -51,7 +51,7 @@ public class SslTransportFactoryTest extends TestCase {
for (int i = 0; i < 4; ++i) {
final boolean wantClientAuth = (i & 0x1) == 1;
final boolean needClientAuth = (i & 0x2) == 1;
final boolean needClientAuth = (i & 0x2) == 2;
String options = "wantClientAuth=" + (wantClientAuth ? "true" : "false") + "&needClientAuth=" + (needClientAuth ? "true" : "false");

View File

@ -671,12 +671,10 @@ public class JMSXDeliveryCountTest extends JMSTestBase {
if (tm == null) {
failed = true;
}
if (!tm.getText().equals("testing" + i)) {
else if (!tm.getText().equals("testing" + i)) {
failed = true;
}
if (tm.getIntProperty("JMSXDeliveryCount") != j + 1) {
else if (tm.getIntProperty("JMSXDeliveryCount") != j + 1) {
failed = true;
}
}

View File

@ -108,10 +108,7 @@ public class JournalCrashTest extends ActiveMQTestBase {
}
public void sendMessages(final int start, final int end) throws Exception {
ClientSession session = null;
try {
session = factory.createSession(false, false);
try (ClientSession session = factory.createSession(false, false)) {
try {
session.createQueue(QUEUE, QUEUE, true);
@ -132,9 +129,6 @@ public class JournalCrashTest extends ActiveMQTestBase {
session.close();
// server.stop(); -- this test was not supposed to stop the server, it should crash
}
finally {
session.close();
}
}
@Test
@ -146,11 +140,10 @@ public class JournalCrashTest extends ActiveMQTestBase {
printJournal();
ClientSession session = null;
try {
startServer();
startServer();
try (ClientSession session = factory.createSession(true, true)) {
session = factory.createSession(true, true);
ClientConsumer consumer = session.createConsumer(QUEUE);
session.start();
@ -165,14 +158,6 @@ public class JournalCrashTest extends ActiveMQTestBase {
}
session.close();
}
finally {
try {
session.close();
}
catch (Throwable ignored) {
}
}
}
/**

View File

@ -323,7 +323,7 @@ public class PagingTest extends ActiveMQTestBase {
HashMap<Integer, AtomicInteger> counts = countJournalLivingRecords(server.getConfiguration());
AtomicInteger pgComplete = counts.get(JournalRecordIds.PAGE_CURSOR_COMPLETE);
AtomicInteger pgComplete = counts.get((int) JournalRecordIds.PAGE_CURSOR_COMPLETE);
assertTrue(pgComplete == null || pgComplete.get() == 0);

View File

@ -82,14 +82,12 @@ public class NonHATopologyTest extends ActiveMQTestBase {
factory.close();
if (!isNetty) {
TopologyMemberImpl member = topology.getMembers().iterator().next();
if (isNetty) {
assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
else {
assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
TopologyMemberImpl member = topology.getMembers().iterator().next();
if (isNetty) {
assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
else {
assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
}

View File

@ -161,7 +161,7 @@ public class JmsProducerTest extends JMSTestBase {
byte value1 = producer.getByteProperty("testGetNonExistentProperties");
if (expected == null) {
assertEquals("value0: " + value0 + " value1: " + value1, value1 == value0);
assertTrue("value0: " + value0 + " value1: " + value1, value1 == value0);
}
else {
fail("non existent byte property expects exception, but got value: " + value1);

View File

@ -64,8 +64,9 @@ public class StompV11Test extends StompV11TestBase {
@After
public void tearDown() throws Exception {
try {
log.debug("Connection 11 : " + connV11.isConnected());
if (connV11 != null && connV11.isConnected()) {
boolean connected = connV11 != null && connV11.isConnected();
log.debug("Connection 11 : " + connected);
if (connected) {
connV11.disconnect();
}
}

View File

@ -67,8 +67,9 @@ public class StompV12Test extends StompV11TestBase {
@After
public void tearDown() throws Exception {
try {
log.debug("Connection 1.2 : " + connV12.isConnected());
if (connV12 != null && connV12.isConnected()) {
boolean connected = connV12 != null && connV12.isConnected();
log.debug("Connection 1.2 : " + connected);
if (connected) {
connV12.disconnect();
}
}

View File

@ -71,7 +71,7 @@ public class JMSCorrelationIDHeaderTest extends MessageHeaderTestBase {
// Private -------------------------------------------------------
private void assertByteArraysEqual(final byte[] bytes1, final byte[] bytes2) {
if (bytes1 == null | bytes2 == null) {
if (bytes1 == null || bytes2 == null) {
ProxyAssertSupport.fail();
}

View File

@ -114,7 +114,7 @@ public class ForeignMessageTest extends MessageTestBase {
}
private void assertByteArraysEqual(final byte[] bytes1, final byte[] bytes2) {
if (bytes1 == null | bytes2 == null) {
if (bytes1 == null || bytes2 == null) {
ProxyAssertSupport.fail();
}

View File

@ -486,7 +486,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase {
while (running) {
long[] ids = new long[5];
// Append
for (int i = 0; running & i < ids.length; i++) {
for (int i = 0; running && i < ids.length; i++) {
System.out.println("append slow");
ids[i] = JournalCleanupCompactStressTest.idGen.generateID();
maxRecords.acquire();
@ -500,7 +500,7 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase {
rwLock.readLock().lock();
}
// Delete
for (int i = 0; running & i < ids.length; i++) {
for (int i = 0; running && i < ids.length; i++) {
System.out.println("Deleting");
maxRecords.release();
journal.appendDeleteRecord(ids[i], false);